Isotropix Forums

Query Reference Items immediate after creation

Clarisse Scripting related topics

Query Reference Items immediate after creation

Unread postby rahulmishra » Thu Jun 10, 2021 5:05 pm

Hi,

I'm trying to list all the objects of a USD reference immediately after reference creation. the code works if I run first and second part separately, but fails when I run all at once. Could you please let me know what am I missing..

First Part

Code: Select all
import ix
model_ctx = ix.application.get_current_context()
ref = ix.cmds.CreateFileReference(str(model_ctx), [r"X:\Testing\cubes.usd"])


Second Part

Code: Select all
geom_objects = ix.api.OfObjectArray()
model_ctx.get_all_objects(geom_objects)
for obj in geom_objects:
    print(obj)



Thank you
rahulmishra
 
Posts: 1
Joined: Thu Jun 10, 2021 4:39 pm

Re: Query Reference Items immediate after creation

Unread postby anemoff » Fri Jun 11, 2021 10:39 am

Hi,

To let the loading finish before calling the 2nd part, you need to let the application process pending events to finish executing the USD reference loading.
I've also edited the script to list only objects in the reference context.

Code: Select all
import ix
model_ctx = ix.application.get_current_context()
ref = ix.cmds.CreateFileReference(str(model_ctx), [r"X:\Testing\cubes.usd"])

# Process application events to finish loading the USD reference
ix.application.check_for_events()

geom_objects = ix.api.OfObjectArray()
ref.get_all_objects(geom_objects)
for obj in geom_objects:
    print(obj)


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


Return to Scripting
cron