Page 1 of 1

Get all geos from a context and get the shading groups

Unread postPosted: Wed Jan 09, 2019 12:00 pm
by qinyao
Hi, great Clarisse team,

How can I get all geometries from a abc referenced context and get the shading groups of each geometry?

Re: Get all geos from a context and get the shading groups

Unread postPosted: Wed Jan 09, 2019 2:59 pm
by bvaldes
Hi

Take a look to the following code:

python code

context = ix.get_item("project://scene/context") # The context whenre you want to looking for


objects_array = ix.api.OfObjectArray(context.get_object_count()) # Grab all the items in the context and put it in the array
context.get_objects(objects_array)# An array that will contain the content of the context

# Look at all the items in the context with the for loop
for j in range(objects_array.get_count()):
item = objects_array[j]
print item
# Only geometry have shading groups so you just want to affect Geometries objects
if item.is_kindof("Geometry"):
for i in range(item.get_module().get_shading_group_count()):
print " " + item.get_module().get_shading_group(i)

I hope this is enough, feel free to ask if you need more help.
Regards

Re: Get all geos from a context and get the shading groups

Unread postPosted: Thu Jan 10, 2019 2:35 am
by qinyao
cool, thank you!

Re: Get all geos from a context and get the shading groups

Unread postPosted: Thu Jan 10, 2019 9:25 am
by qinyao
BTW, how tho make my GuiWindow always on the top of the application.

Re: Get all geos from a context and get the shading groups

Unread postPosted: Fri Jan 11, 2019 2:13 pm
by guillaume
Hi,

qinyao wrote:BTW, how tho make my GuiWindow always on the top of the application.


You have to parent your new window to the application window, like this:

python code

clarisse_win = ix.application.get_event_window()
window = MyWindow(clarisse_win, x, y, width, height)
Regards

Re: Get all geos from a context and get the shading groups

Unread postPosted: Sat Jan 12, 2019 2:40 pm
by qinyao
wow, it works, thank you!