Isotropix Forums

Accessing items in Slots (1-8)

Clarisse Scripting related topics

Accessing items in Slots (1-8)

Unread postby horhew » Fri Sep 14, 2018 1:30 pm


I'm trying to figure out how to use
Code: Select all
ix.application.get_selection().get_item(group, index)

to access selected items in a particular Slot (1...8).Unfortunately I can't figure out what to pass as "group" in order to achieve that. It works with "global" and by the same logic I tried passing in "slot_1", "slot1" etc, but to no avail. Anyone knows how to do this?

Posts: 2
Joined: Wed Sep 12, 2018 6:05 pm

Re: Accessing items in Slots (1-8)

Unread postby desmond » Sat Sep 15, 2018 6:18 am

If you select few items in a context and paste this into the script editor, it works.
You first call the selection, which gets filled with items then you have to select an item to work over. What you think its a group its already there, so you basically call just the index from the list of the selected items.
Code: Select all
selection = ix.application.get_selection().get_item(0)
print selection

group = ix.application.get_selection()
print group.get_item(1)

pythonselection = ix.selection[0]
print pythonselection

groupselect = ix.application.get_selection()
cam = group.get_item(1)
do_move = cam.attrs.translate[0] = 10

hope this helps
User avatar
Posts: 48
Joined: Mon Feb 05, 2018 8:46 am

Re: Accessing items in Slots (1-8)

Unread postby horhew » Tue Sep 18, 2018 12:24 pm

Thanks for the help, Desmond,

The code you provided does work correctly, but it's not exactly what I was after. In the API there is a get_item() function of AppSelection (of course this gets wrapped by swig in the python api):

Code: Select all
OfItem * get_item (const CoreString &group, const unsigned int &index) const

So my question was about this overload, where a group can be specified as an argument before the index.

For instance, let's say I have a scene with 3 boxes and 1 sphere. In the Browser, I select the 3 boxes, then I lock the selection with the padlock button. Now I select the sphere (this happens at a Local level), which doesn't seem to change the selection. Then I switch to Slot 1 and select a single box. At this moment I have:
- 3 boxes selected at a global level
- 1 sphere selected at a local level
- 1 box selected in Slot 1

My question is, how can I access the 1 sphere and the 1 box at the "local" and "Slot 1" levels? I thought passing "local" to get_item() on the selection object would do the trick, but apparently even calling ix.application.get_selection() only seems to retrieve the global selection, so now I'm even more confused on whether such a thing is possible. Or perhaps I am getting confused and "group" is not what I think it is?

Posts: 2
Joined: Wed Sep 12, 2018 6:05 pm

Re: Accessing items in Slots (1-8)

Unread postby guillaume » Mon Oct 01, 2018 1:50 pm


The local selection is not accessible, however you can get the Global and all slots with get_item(). Take a look at the following example:

python code

app_selection = ix.application.get_selection()

print "Group list:"
groups = ix.api.CoreStringVector()
for i in range(groups.get_count()):
print " " + groups[i]
print ""

print "Slot list:"
slots = ix.api.CoreStringVector()
for i in range(slots.get_count()):
print " " + slots[i]

print ""
print "Selection Global:"
selection = app_selection.get_items()
for i in range(selection.get_count()):
print " " + selection[i].get_full_name()

print ""
print "Selection Slot 1:"
slot = "Slot 1"
selection_slot1 = app_selection.get_items(app_selection.get_global_group_label(), slot)
for i in range(selection_slot1.get_count()):
print " " + selection_slot1[i].get_full_name()

R&D Engineer
User avatar
Posts: 140
Joined: Fri Feb 01, 2013 12:14 pm

Return to Scripting