Isotropix Forums

Python - Get shape name/path from GeometryAbcMesh

Clarisse Scripting related topics

Python - Get shape name/path from GeometryAbcMesh

Unread postby dziga » Thu Feb 06, 2020 5:05 pm

Hello again!

Is there a way to grab which shape is being used from within an Alembic?

I have a file here with multiple GeometryAbcMesh objects and usually the "name" attribute matches the actual shape name from the Alembic.

Now, there are occasions when either the artist renamed the object inside Clarisse or imported an object multiple times (don't ask me why^.^) and Clarisse then creating "shapeName1" instead of "shapeName". How can I find out which shape/path is being used?

Is there something deeper than using the "name" attribute for objects of GeometryAbcMesh type?

I really appreciate any help!

I am not sure if I explained the scenario understandably, please let me know if you need further info.

Thank you in advance and talk soon,
Dziga
dziga
 
Posts: 6
Joined: Thu Apr 25, 2019 5:17 pm

Re: Python - Get shape name/path from GeometryAbcMesh

Unread postby anemoff » Thu Feb 06, 2020 5:53 pm

Hi,

In Clarisse, the type GeometryAbcMesh corresponds to Alembic's PolyMesh or SubD.

For reference, these are all the supported Alembic types and their corresponding type in Clarisse:
- PolyMesh and SubD -> GeometryAbcMesh
- Points -> GeometryAbcPointCloud
- Curves -> GeometryAbcFur
- Xform -> AbcXform
- Camera -> CameraAlembic

Could you give us an example of the different shape types that you need to identify?

It seems to me that you want to get the Clarisse type of the object (for example "GeometryAbcMesh"), instead of using the object name.
If yes, use the following python code:

python code

obj_class = ix.get_item('path/to/object').get_class_name()

Regards,
Anthony Nemoff
Isotropix
R&D Engineer
User avatar
anemoff
 
Posts: 281
Joined: Wed Jan 13, 2016 10:10 am

Re: Python - Get shape name/path from GeometryAbcMesh

Unread postby dziga » Fri Feb 07, 2020 10:21 am

Hey Anthony,

thanks for the quick response. I think I didn't explain it in the best way^^

Unfortunately, I cannot show you the scene file from here but I will prepare a small example..

..Okay, I had to figure out myself how the artist ended up with this result. This is the scenario:

1. Artist references an alembic with multiple meshes/objects inside. This is what I get:
Screenshot 2020-02-07 at 10.18.18.png
abc_ref


2. Artist then creates a different context and copies the items there. The geometry type stays GeometryAbcMesh linking to the .abc which contains all 3 objects. The name right now is still the exact mesh name from the .abc:
Screenshot 2020-02-07 at 10.18.28.png
object_copy_1


3. Artist copies the referenced objects again into the same context. Now Clarisse auto renames them:
Screenshot 2020-02-07 at 10.18.37.png
object_copy_2


With this renamed copy, how can I find out which mesh is being loaded from the "master" .abc?
Since now box2 only links to the "master" Alembic and I don't see that it uses the mesh box1.

I am thankful for any pointers^.^ Please let me know, if something is unclear.

Take care,
Dziga
dziga
 
Posts: 6
Joined: Thu Apr 25, 2019 5:17 pm

Re: Python - Get shape name/path from GeometryAbcMesh

Unread postby anemoff » Fri Feb 07, 2020 10:40 am

OK, I see what you mean. You need to access the real path of the object in the Alembic.

This is possible but you need to read a hidden attribute named "object_name" that all Clarisse Alembic objects have.
This attribute stores the full path of the object in the Alembic file (called "full name" in Alembic API).
Historically this attribute has always been hidden because it is internal and not meant to be modified after loading the Alembic. If you respect these restrictions you are safe to read it.

In USD we have a similar attribute named "prim_path" that is public and read-only. We could potentially make changes to Alembic objects to make "object_name" public and read-only, but we need to investigate the feasibility first.

Here is the python code to access Alembic object_name:

python code

abc_path = ix.get_item('path/to/object').get_attribute('object_name').get_string()
print(abc_path)

Output example:
Code: Select all
/Trex:TREX/Trex:TrexMod/Trex:LeftLegGrp/Trex:L_Hip/Trex:L_HipShape

Cheers,
Anthony Nemoff
Isotropix
R&D Engineer
User avatar
anemoff
 
Posts: 281
Joined: Wed Jan 13, 2016 10:10 am

Re: Python - Get shape name/path from GeometryAbcMesh

Unread postby dziga » Fri Feb 07, 2020 10:54 am

Perfect!!

That is exactly what I was looking for.

I only need to read it to re-assign the correct objects to the instancer in Houdini and by using the name attribute this becomes very risky ^^

Thank you!!:)

Have a gread weekend!
Dziga
dziga
 
Posts: 6
Joined: Thu Apr 25, 2019 5:17 pm

Re: Python - Get shape name/path from GeometryAbcMesh

Unread postby anemoff » Fri Feb 07, 2020 11:05 am

Glad it helps.

In any case, just a friendly reminder to be clear: do not edit the attribute "object_name" in Clarisse (using "set_string" for example), as this attribute is not designed to be modified directly and it will not have the expected behavior (like loading the new object). As long you only read it, it's OK.
Anthony Nemoff
Isotropix
R&D Engineer
User avatar
anemoff
 
Posts: 281
Joined: Wed Jan 13, 2016 10:10 am

Re: Python - Get shape name/path from GeometryAbcMesh

Unread postby dziga » Fri Feb 07, 2020 11:09 am

anemoff wrote:Glad it helps.

In any case, just a friendly reminder to be clear: do not edit the attribute "object_name" in Clarisse (using "set_string" for example), as this attribute is not designed to be modified directly and it will not have the expected behavior (like loading the new object). As long you only read it, it's OK.


Thanks, yes, I won't touch the attribute at all. Simple read and store into json:)
dziga
 
Posts: 6
Joined: Thu Apr 25, 2019 5:17 pm


Return to Scripting