Profile Picture

Finding files in iC8 (Smart Manager)

Posted By gordryd Last Year
You don't have permission to rate!
Author
Message
gordryd
gordryd
Posted Last Year
View Quick Profile
Distinguished Member

Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)

Group: Forum Members
Last Active: Yesterday
Posts: 730, Visits: 8.0K
Hi, my plugs worked OK in iC7 (and mostly in iC8) but some users have complained about "File Not Found" error in iC8 when looking for default content.
Currently I find the "Box.iProp" in the "Beveled" sub-folder like this:
    Registry = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE)
    RawKey = winreg.OpenKey(Registry, r"SOFTWARE\Reallusion\iClone\8.0")
    ic_template_path = os.path.abspath(winreg.QueryValueEx(RawKey, "Template Data" )[0])  
    RLPy.RFileIO.LoadFile(ic_template_path + "//Props//3D Blocks//Beveled//Box.iProp")
It seems that if the user has modified something in the default template path, this method no longer works.
The iC8 Wiki has some examples here, but I can't seem to get anything below the 'root' Prop directory working.  Any tips?


Reallusion Certified Director / Reallusion Best Visual Award / Reallusion Certified Content Developer
See all the G-Tools Plug-Ins available for iClone here: G-Tools Plug-Ins


4u2ges
4u2ges
Posted Last Year
View Quick Profile
Distinguished Member

Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)

Group: Forum Members
Last Active: 1 hour ago
Posts: 5.3K, Visits: 16.6K
There were reasons I gave up on going deeply into RL Python:
Lack of time, poorly written documentation and most annoying - inconsistency in sample snippets!
It may not be so bad for those who develop for living, but for the rest of us....

Just sample the code which could be tested by copy/paste right away! :crazy:
Not just some random lines where we have to figure how to put it all together and clear the syntax errors and misplaced variables in a way!



Sorry for the rant, I hope this is what you've been looking to get.... :)

import RLPy

rl_plugin_info = {"ap": "iClone", "ap_version": "8.0"}

def get_all_content_folders(_folder, all_content_folders):
    content_folders = RLPy.RApplication.GetContentFoldersInFolder(_folder)
    for sub_folder in content_folders:
        all_content_folders.append(sub_folder)
        print("sub_folder :"+sub_folder)
        real_files = RLPy.RApplication.GetContentFilesInFolder(sub_folder)
        for files in real_files:
            print("files :"+files )
        get_all_content_folders(sub_folder, all_content_folders)
       


content_key = RLPy.ETemplateRootFolder_Props
def_folder = RLPy.RApplication.GetDefaultContentFolder(content_key)
print(def_folder)

all_content_folders = []
get_all_content_folders(def_folder, all_content_folders)




gordryd
gordryd
Posted Last Year
View Quick Profile
Distinguished Member

Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)

Group: Forum Members
Last Active: Yesterday
Posts: 730, Visits: 8.0K
Thanks Gurgen,
This is similar to what is in the WIKI.  Where I'm stuck is loading a specific file from a specific sub-folder below the root "Props" folder (let's use the previously mentioned path "//Props//3D Blocks//Beveled//Box.iProp" as an example)
Do I need to iterate through all the files in each sub-folder until I find one that matches my filename?  Seems very inefficient, plus RL in their infinite wisdom has named several of the props the same (Box.iProp can be found in several sub-folders and they are all different props).
Sorry for the probably basic question, but I'm not a programmer - just bought a book on Python and brute-forced most of my code.


Reallusion Certified Director / Reallusion Best Visual Award / Reallusion Certified Content Developer
See all the G-Tools Plug-Ins available for iClone here: G-Tools Plug-Ins


4u2ges
4u2ges
Posted Last Year
View Quick Profile
Distinguished Member

Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)

Group: Forum Members
Last Active: 1 hour ago
Posts: 5.3K, Visits: 16.6K
I am not a programmer either ;)

The code I supplied is basically what should have been posted in WIKI so that we can run it and based on the printed output figure how to manipulate it for our specific needs.

In your case you just need to get the path to Templates (which you said is not accurate in registry if it's not default).

So given 3D blocks location (for instance) is a constant, you may run this code to get an absolute path to the first available prop in that folder and then extract the path from there.
(unless there is some other, direct way to get the templates location which I do not know).

FIRST_3D_BLOCK=RLPy.RApplication.GetContentFilesInFolder("$/Props/3D Blocks/")[0]
print(FIRST_3D_BLOCK)


Or you can recurse specific folder for that matter if that is necessary...




gordryd
gordryd
Posted Last Year
View Quick Profile
Distinguished Member

Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)

Group: Forum Members
Last Active: Yesterday
Posts: 730, Visits: 8.0K
Thanks again -- that last line was the ticket -- eliminated all that extraneous code that RL suggested (and SO much faster).

Reallusion Certified Director / Reallusion Best Visual Award / Reallusion Certified Content Developer
See all the G-Tools Plug-Ins available for iClone here: G-Tools Plug-Ins


gordryd
gordryd
Posted Last Year
View Quick Profile
Distinguished Member

Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)

Group: Forum Members
Last Active: Yesterday
Posts: 730, Visits: 8.0K
Very frustrating -- this line works if I load the .py script manually in iC8 (prop_folder location is gathered using "prop_folder = RLPy.RApplication.GetDefaultContentFolder(RLPy.ETemplateRootFolder_Props" in earlier step):

    first_prop_file = RLPy.RApplication.GetContentFilesInFolder(prop_folder)[0]

It throws this error if I put the script in OpenPlugins and let iClone try to load it:

<class 'IndexError'>, File: C://MyPath//MyFile_main.py, Line: 39, Function: <module>
(line 39 is the line shown earlier)

Another strange thing is that it is referencing "MyFile_main.py" which is the location of the file where I edit, not the "OpenPlugin" directory (which contains only "main.py").  I also tried compiling to .pyc but it still gives the same error.

One last strange thing:  Usually when I edit anything in "OpenPlugin" it complains and asks for Administrative rights.  In this folder for this plugin it never complains???



Reallusion Certified Director / Reallusion Best Visual Award / Reallusion Certified Content Developer
See all the G-Tools Plug-Ins available for iClone here: G-Tools Plug-Ins


4u2ges
4u2ges
Posted Last Year
View Quick Profile
Distinguished Member

Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)

Group: Forum Members
Last Active: 1 hour ago
Posts: 5.3K, Visits: 16.6K
I would not put anything to run from main.py.
You are getting that error, because the script execution precedes the iClone routine which sets all necessary constants in place during startup.
It does not know the Content location yet... Thus the error about empty array.





gordryd
gordryd
Posted Last Year
View Quick Profile
Distinguished Member

Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)Distinguished Member (5.2K reputation)

Group: Forum Members
Last Active: Yesterday
Posts: 730, Visits: 8.0K
I'm using main.pyc for my plug-ins (most plugs use this method, including RL plugs).  So I looked at an RL plug and it uses a much simpler method to find the Template path -- I tried this and it works in the main.pyc version.  I don't know why they included all that other nonsense in the WIKI -- all you need is this:

ic_template_path = RLPy.RApplication.GetTemplateDataPath()

:crazy:


Reallusion Certified Director / Reallusion Best Visual Award / Reallusion Certified Content Developer
See all the G-Tools Plug-Ins available for iClone here: G-Tools Plug-Ins


4u2ges
4u2ges
Posted Last Year
View Quick Profile
Distinguished Member

Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)Distinguished Member (22.3K reputation)

Group: Forum Members
Last Active: 1 hour ago
Posts: 5.3K, Visits: 16.6K
lol that's more like it. I wonder how different that is from the string in registry.







Reading This Topic