Isotropix Forums

Path Manager functionality in Python

Clarisse Scripting related topics

Path Manager functionality in Python

Unread postby briansilva » Tue Aug 20, 2019 12:45 pm

Hello!

From Python, I'd like to be able to list all file paths referenced from a project file the same way that the Path Manager does. Is this possible in Python, and can someone point me to it?

Thank you!
briansilva
 
Posts: 70
Joined: Mon Mar 25, 2019 12:43 pm

Re: Path Manager functionality in Python

Unread postby julian » Tue Aug 20, 2019 3:33 pm

This will print all path attributes along with their value and whether input or output

python code

attrs = ix.api.OfAttr.get_path_attrs()
for attr in attrs:
path = attr.get_string()
attr_name = attr.get_name()
obj_name = attr.get_parent_object().get_name()
is_output = ix.api.OfAttr.get_visual_hint_name(
attr.get_visual_hint()) == "VISUAL_HINT_FILENAME_SAVE"
type_val = "output" if is_output else "input"
info = {"object": obj_name, "attribute":attr_name, "path": path, "type": type_val}
ix.log_info(info)
julian
 
Posts: 25
Joined: Tue Feb 05, 2019 2:51 pm

Re: Path Manager functionality in Python

Unread postby briansilva » Wed Aug 21, 2019 4:42 pm

That works great, and using the VISUAL_HINT to differentiate input/output is very useful. Thanks!
briansilva
 
Posts: 70
Joined: Mon Mar 25, 2019 12:43 pm

Re: Path Manager functionality in Python

Unread postby mr_asa » Wed Jul 07, 2021 4:58 pm

Hello. How does this functionality work in Clarisse 5?
When i use code like this:

python code

attrs = ix.api.OfAttr.get_path_attrs()
for i in range(attrs.get_count()):
attr = attrs[i]

I get an error

python code

Traceback (most recent call last):
File "<string>", line 5, in <module>
File "/opt/clarisse5/clarisse/python2/base.py", line 981, in <lambda>
__getattr__ = lambda self, name: _swig_getattr(self, CoreBaseObject, name)
File "/opt/clarisse5/clarisse/python2/base.py", line 80, in _swig_getattr
raise AttributeError("'%s' object has no attribute '%s'" % (class_type.__name__, name))
AttributeError: 'CoreBaseObject' object has no attribute 'get_count'


I see that some characteristics have changed, but I do not understand what exactly has changed and how to work with it

python code

attrs = ix.api.OfAttr.get_path_attrs()
print(attrs.get_class_info())
# same сlass in 4 and 5 versions
<base.CoreClassInfo; proxy of <Swig Object of type 'CoreClassInfo *' at 0x7fb153b30ba0> >
# but in errors as on this command:
print(attrs.get_name())
# I get different information
#Clarisse 4
Traceback (most recent call last):
...
AttributeError: 'OfAttrSet' object has no attribute 'get_name'

#Clarisse 5
Traceback (most recent call last):
...
AttributeError: 'CoreBaseObject' object has no attribute 'get_name'


Thank you!
mr_asa
 
Posts: 1
Joined: Fri May 14, 2021 12:41 pm

Re: Path Manager functionality in Python

Unread postby dcourtois » Thu Jul 08, 2021 1:04 pm

Hi,

I believe that this has been fixed in Clarisse 5.0 SP1.
In Clarisse 4, the type returned in `OfAttrSet` which is the Python version of a C++ `CoreSet<OfAttr>` and in SP1 we fixed a regression on the Python binding of the `CoreSet` class, which would explain this error.
User avatar
dcourtois
 
Posts: 104
Joined: Tue Jul 25, 2017 3:15 pm


Return to Scripting