Isotropix Forums

[AbcXform] Read transform loaded from an abc

Clarisse Scripting related topics

[AbcXform] Read transform loaded from an abc

Unread postby cchampet » Thu Aug 10, 2017 2:31 pm

Hello,

I would like to have access, in python, to the transform operations loaded from an Alembic file.
When I import an Alembic file, Clarisse creates for me as many GeometryAbcMesh as objects in my file, and an AbcXform that handles the transformations. The transformation that can be set by its attributes is applied on the orginal matrix: this is really nice :) But is it possible to get the original operations in python?
Something like:

Code: Select all
abcTransform = abcXformItem.get_attribute('transform')
abcTransform.translate
abcTransform.rotate
abcTransform.scale
...


Thank you for your time.

Cheers,
Clement
cchampet
 
Posts: 12
Joined: Fri May 19, 2017 9:20 am

Re: [AbcXform] Read transform loaded from an abc

Unread postby anemoff » Fri Aug 11, 2017 5:12 pm

Hi,

Currently, there is no straightforward API but you can do this:

python code

obj = #... your object ...

# Move to frame N to get values at that time (or you can disable this line to alway get values at the current frame)
ix.set_current_frame(0)

# Get Clarisse transform
obj.get_attribute("pivot_mode").set_long(0) # "Use matrix"
translate = obj.get_attribute("translate")
print "Clarisse translate: (" + str(translate[0]) + ", " + str(translate[1]) + ", " + str(translate[2]) + ")"

# Get Alembic transform
obj.get_attribute("pivot_mode").set_long(1) # "Use Attributes"
translate = obj.get_attribute("translate")
print "Alembic translate: (" + str(translate[0]) + ", " + str(translate[1]) + ", " + str(translate[2]) + ")"

# Revert pivot mode to remove the override (if the alembic is referenced)
obj.get_attribute("pivot_mode").revert()


Hope this helps.
Anthony Nemoff
Isotropix
R&D Engineer
User avatar
anemoff
 
Posts: 65
Joined: Wed Jan 13, 2016 11:10 am

Re: [AbcXform] Read transform loaded from an abc

Unread postby cchampet » Fri Aug 18, 2017 6:00 pm

Thank you for your answer Anthony.
I decided to switch to a more naive solution based on hardcoded known values, but this code snippet could help us next time :)
Cheers,
cchampet
 
Posts: 12
Joined: Fri May 19, 2017 9:20 am

Re: [AbcXform] Read transform loaded from an abc

Unread postby cchampet » Tue Aug 29, 2017 10:49 am

Anthony your solution seems to work like a charm :)

# Revert pivot mode to remove the override (if the alembic is referenced)
obj.get_attribute("pivot_mode").revert()

I have only one small issue: OfAttr.revert method is only available since Clarisse 3.5 apparently. Can you confirm? Do you know an equivalent way to do this on Clarisse 3.0?

Cheers,
Clement
cchampet
 
Posts: 12
Joined: Fri May 19, 2017 9:20 am

Re: [AbcXform] Read transform loaded from an abc

Unread postby anemoff » Wed Aug 30, 2017 4:35 pm

Indeed, the function revert is available since 3.5.
In 3.0 you can use the function reset instead. However, this only resets the attribute to its default value. It doesn't remove the overridden status.

In 3.5 you can revert an override on an attribute (Right Mouse Button > Revert attribute), or even revert all overrides of an object (RMB > Revert overrides).
Anthony Nemoff
Isotropix
R&D Engineer
User avatar
anemoff
 
Posts: 65
Joined: Wed Jan 13, 2016 11:10 am


Return to Scripting