Isotropix Forums

Tracking USD Overrides like a Session Layer

Clarisse Scripting related topics

Tracking USD Overrides like a Session Layer

Unread postby briansilva » Wed Nov 20, 2019 11:39 am

Hello!

With a USD file referenced into a Clarisse project, I'd like to track the interactive changes layered onto it, like the Session Layer that's created as part of a USD Stage.

I can imagine ways of mimicking this functionality through the Clarisse API with callbacks and reading overrides from the context engine. But is there actually a USD Stage and a Session Layer sitting somewhere behind the scenes that I can access from Python? Or can anyone recommend another approach?

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

Re: Tracking USD Overrides like a Session Layer

Unread postby dcourtois » Wed Nov 20, 2019 11:54 am

Hi,

We're loading USD stages in a "read-only" fashion, and internally we have our own structures, so no: we don't have an edit layer that you could export separately. BUT: in the Python API you can quite easily get all overridden values on your reference, and dump them to a file. Here is the bit of code that you'll need. It will print all overridden attributes of the currently selected context:

python code

context = ix.selection[0]
engine = context.get_engine()
objects = ix.api.OfObjectVector()
engine.get_overridden_objects(objects)
print objects.get_count()
for obj in objects:
print obj
attrs = ix.api.OfAttrVector()
engine.get_overridden_attributes(obj, attrs)
print attrs.get_count()
for at in attrs:
print at
User avatar
dcourtois
 
Posts: 62
Joined: Tue Jul 25, 2017 3:15 pm

Re: Tracking USD Overrides like a Session Layer

Unread postby briansilva » Wed Nov 20, 2019 12:15 pm

Ah that's great, looks like it will be fairly straightforward to translate those overrides into a USD format.

Thanks Damien!
briansilva
 
Posts: 41
Joined: Mon Mar 25, 2019 12:43 pm

Re: Tracking USD Overrides like a Session Layer

Unread postby briansilva » Thu Nov 21, 2019 12:28 pm

Hey Damien,

I'm trying this out, and I see the get_overridden_objects method in the API docs, but I'm getting this in Clarisse -- maybe a Python bindings issue?

Code: Select all
<framework.OfFileReferenceContextEngine; proxy of <Swig Object of type 'OfFileReferenceContextEngine *' at 0x000001EAF1917030> >
Traceback (most recent call last):
  File "<string>", line 5, in <module>
  File "C:/Program Files/Isotropix/Clarisse iFX 4.0 SP3/Clarisse/python\framework.py", line 4750, in <lambda>
    __getattr__ = lambda self, name: _swig_getattr(self, OfFileReferenceContextEngine, name)
  File "C:/Program Files/Isotropix/Clarisse iFX 4.0 SP3/Clarisse/python\framework.py", line 80, in _swig_getattr
    raise AttributeError("'%s' object has no attribute '%s'" % (class_type.__name__, name))
AttributeError: 'OfFileReferenceContextEngine' object has no attribute 'get_overridden_objects'


I see other get_override_* methods that do seem to be working, so I'll use those for now.
briansilva
 
Posts: 41
Joined: Mon Mar 25, 2019 12:43 pm

Re: Tracking USD Overrides like a Session Layer

Unread postby briansilva » Thu Nov 21, 2019 1:03 pm

Actually I'm struggling to get this to work with anything dealing with OfOverride objects. The only thing I've managed to get working is this:

python code

context = ix.selection[0]
engine = context.get_engine()
print engine.get_overrides_as_text()


which prints something like this:

Code: Select all
overrides {
    object "pCylinder1" {
        scale 0.605995717344754 0.605995717344754 0.605995717344754
    }
    object "pSphere1" {
        translate 0.0 3.95999687534193 -1.39582825087079
        rotate 45.8947889055529 -180.000000000045 -180.000000000045
    }
}


Looks like this would be fairly straightforward to parse, but I'd prefer not to have to. Any ideas?
briansilva
 
Posts: 41
Joined: Mon Mar 25, 2019 12:43 pm

Re: Tracking USD Overrides like a Session Layer

Unread postby sam » Thu Nov 21, 2019 1:09 pm

Hi there,

Which version of Clarisse are you using. The above code only works from 4.0 SP4
Sam Assadian
Isotropix
CEO/Founder
User avatar
sam
 
Posts: 1467
Joined: Fri Jan 25, 2013 11:33 pm

Re: Tracking USD Overrides like a Session Layer

Unread postby briansilva » Thu Nov 21, 2019 1:11 pm

Ah, I am on SP3 still -- I'll get SP4 setup and give it another spin. I assume this will work with SP4c, but let me know if not. Thanks!
briansilva
 
Posts: 41
Joined: Mon Mar 25, 2019 12:43 pm

Re: Tracking USD Overrides like a Session Layer

Unread postby sam » Thu Nov 21, 2019 1:15 pm

Yes, it works from SP4
Sam Assadian
Isotropix
CEO/Founder
User avatar
sam
 
Posts: 1467
Joined: Fri Jan 25, 2013 11:33 pm

Re: Tracking USD Overrides like a Session Layer

Unread postby briansilva » Thu Nov 21, 2019 1:47 pm

Yes, that code is working now, thanks a lot guys!
briansilva
 
Posts: 41
Joined: Mon Mar 25, 2019 12:43 pm


Return to Scripting
cron