Isotropix Forums

Select Objects via python

Clarisse Scripting related topics

Select Objects via python

Unread postby K4341 » Mon Feb 10, 2020 7:21 pm

Hi :) , How to select objects using python ?
Thank you
K4341
 
Posts: 7
Joined: Thu Oct 03, 2019 3:32 pm

Re: Select Objects via python

Unread postby mhamid3d » Mon Feb 10, 2020 10:26 pm

Assuming 'items' is your list of items that you want to select

Code: Select all
ix.application.get_selection().set_selection('global','Global', items)
mhamid3d
 
Posts: 8
Joined: Wed Dec 04, 2019 5:20 pm

Re: Select Objects via python

Unread postby K4341 » Tue Feb 11, 2020 1:38 pm

Thanks alot mhamid3d

It works fine with one item but didn't work with array of items :
Code: Select all
import ix
item_List = ix.api.OfObjectArray()
ix.application.get_factory().get_all_objects("ProjectItem", item_List)
ix.application.get_selection().set_selection('global','Global', item_List)


I've got this Error :
Code: Select all
00:05:50    Traceback (most recent call last):
00:05:50        return _framework.AppSelection_set_selection(self, *args)
00:05:50    TypeError: in method 'AppSelection_set_selection', argument 4 of type 'CoreVector< OfItem * > const &'
00:05:50
K4341
 
Posts: 7
Joined: Thu Oct 03, 2019 3:32 pm

Re: Select Objects via python

Unread postby K4341 » Tue Feb 11, 2020 2:22 pm

Now it's doing well :

Code: Select all
"""
    select all Texture Nodes in the scene

"""

import ix

item_List = ix.api.OfObjectArray()


ix.application.get_factory().get_all_objects("ProjectItem", item_List)


selection = []


for i in range(item_List.get_count()):


    if item_List[i].is_kindof("TextureStreamedMapFile") == True or item_List[i].is_kindof("TextureMapFile") or item_List[i].is_kindof("TextureMap"):


        selection.append(item_List[i]) # append to selection list 



ix.application.get_selection().set_selection('global','Global',selection[0] ) # select first item in selection list



for sel in range(len(selection)-1):


    ix.application.get_selection().add_item('global',selection[sel+1],'Global') # select all items
K4341
 
Posts: 7
Joined: Thu Oct 03, 2019 3:32 pm


Return to Scripting