Isotropix Forums

Getting imported volume file object

Clarisse Scripting related topics

Getting imported volume file object

Unread postby jboissinot » Wed Apr 10, 2019 10:08 pm

Hi,

I was wondering if it'd be possible to get the newly created object of an imported volume file.

Basically, I import a volume file with the import_volume() method, which returns the context that contains the volume file for some reason, while I was expecting to get the volume file object instead so that I can rename it and set some of its attributes.

Any idea on how I could get the volume file object?

In the meantime, I was also wondering why we need to use the IOHelpers API - ix.api.IOHelpers.import_volume() - while we can simply do ix.reference_file() for importing a reference file. I tried importing a volume file with ix.import_volume() but got an argument error.

Code: Select all
TypeError: import_volume() takes exactly 1 argument (2 given)


Thanks,
Jeremy
jboissinot
 
Posts: 39
Joined: Tue Jan 29, 2019 10:36 pm

Re: Getting imported volume file object

Unread postby sam » Thu Apr 11, 2019 1:04 am

Hi Jeremy,

Have you looked at the documentation of IOHelpers? https://clarissewiki.com/4.0/sdk/class_i_o_helpers.html

I admit I'm also a little bit puzzled by the fact that the method returns a OfContext and not a OfObject. While it can make sense for the import_volumes it doesn't for import_volume

It looks to me that it's a typical case of copy/paste...

We should definitely improve it.

Anyway, that being said, I advise you to create the Volume Object yourself using the API and set the attribute.

python code

my_vdb = ix.application.get_current_context().add_object("my_vdb", "GeometryVolumeFile")
Sam Assadian
Isotropix
CEO/Founder
User avatar
sam
 
Posts: 1395
Joined: Fri Jan 25, 2013 11:33 pm

Re: Getting imported volume file object

Unread postby jboissinot » Thu Apr 11, 2019 3:00 pm

Hi Sam,

I did look at the IOHelpers doc and this is how I found out about the import_volume() method returning the context instead of the volume file object, and was therefore curious to ask about it.

Maybe this is something you could improve indeed.

I was thinking to get it by getting the objects of the context with the get_objects() method, but adding the volume file to a given context with add_object() and set its filename attribute seems to be a good workaround to me and does work fine.

Thanks for your advice,
Jeremy
jboissinot
 
Posts: 39
Joined: Tue Jan 29, 2019 10:36 pm

Re: Getting imported volume file object

Unread postby sam » Thu Apr 11, 2019 6:42 pm

It's actually calling the low level API and it's fairly straight forward. So you should use this when creating items in Clarisse.
Sam Assadian
Isotropix
CEO/Founder
User avatar
sam
 
Posts: 1395
Joined: Fri Jan 25, 2013 11:33 pm

Re: Getting imported volume file object

Unread postby jboissinot » Thu Apr 11, 2019 7:48 pm

Ok thanks for the info Sam.

Quick questions though regarding your comment:

So you should use this when creating items in Clarisse.


- if add_object() works fine for importing a volume file, do you mean that it'd be better use rather than reference_file() for importing an alembic file?
- and generally speaking, will you use add_object() instead of create_object(), or it doesn't really make a difference?

Thanks,
Jeremy
jboissinot
 
Posts: 39
Joined: Tue Jan 29, 2019 10:36 pm

Re: Getting imported volume file object

Unread postby sam » Thu Apr 11, 2019 7:55 pm

No, referencing is something else. Referencing creates a context (and not an object) of type Reference. Here you create an object of type GeometryVolumeFile inside a specified context.

Internally create_object uses at somepoint OfContext::add_object
Sam Assadian
Isotropix
CEO/Founder
User avatar
sam
 
Posts: 1395
Joined: Fri Jan 25, 2013 11:33 pm

Re: Getting imported volume file object

Unread postby jboissinot » Thu Apr 11, 2019 8:14 pm

Oh yes that's right, I was simply curious to see if we could use add_object() for alembic files just as the same way we could for volume files, but yes since there's no such object type for alembic files as they are created as contexts, we have no choice to use reference_file() then, which I'll keep using.

Ok thanks for the create_object() vs add_object() info.

Jeremy
jboissinot
 
Posts: 39
Joined: Tue Jan 29, 2019 10:36 pm

Re: Getting imported volume file object

Unread postby sam » Fri Apr 12, 2019 12:41 am

Well you can if you use Alembic Bundles.
Sam Assadian
Isotropix
CEO/Founder
User avatar
sam
 
Posts: 1395
Joined: Fri Jan 25, 2013 11:33 pm


Return to Scripting
cron