Isotropix Forums

item choose window in python

Clarisse Scripting related topics

item choose window in python

Unread postby K4341 » Fri Apr 03, 2020 6:04 pm

Is there any way to deal with "clarisse choose item window" in python
Attachments
Capture.JPG
Capture.JPG (20.88 KiB) Viewed 1121 times
K4341
 
Posts: 7
Joined: Thu Oct 03, 2019 3:32 pm

Re: item choose window in python

Unread postby K4341 » Fri Apr 03, 2020 7:54 pm

I've found this script in the forum:

Code: Select all
import ix
myArray = ix.api.CoreStringArray()
     
cam = ix.api.IOHelpers.pick_item(ix.application,myArray,"Dialog Title")


if cam:
    class_name = cam.get_class_name()
    if class_name == "CameraPerspective":
        print('You selected context "{}"'.format(cam))
else:
    print('No context selected.')
   


Original post is here : https://forum.isotropix.com/viewtopic.php?f=21&t=2820

But I can't set a filter for items , for example I want to view only just cameras
K4341
 
Posts: 7
Joined: Thu Oct 03, 2019 3:32 pm

Re: item choose window in python

Unread postby anemoff » Wed Apr 15, 2020 1:49 pm

Hi!

Sorry for the late response.
Here is how to specify the filter array:

python code

import ix

# Create the class filter array with enough capacity for all the desired classes.
# Here we will only filter on "Camera" so 1 is enough.
filter = ix.api.CoreStringArray(1)

# Fill the array with the names of classes to filter.
filter[0] = "Camera"

# Show the item picker
cam = ix.api.IOHelpers.pick_item(ix.application, filter , "Dialog Title")

if cam:
class_name = cam.get_class_name()
if class_name == "CameraPerspective":
print('You selected the camera "{}"'.format(cam.get_full_name()))
# do something with the camera...
else:
print('No camera was selected.')

Class names use the CamelCase syntax and are hierarchical. Each "word" is a sub-class.
For example, "Camera" will also allow picking derived camera types like "CameraPerspective", "CameraAlembic", "CameraUsd", etc.
If you want to filter "CameraPerspective" then use that as a class name in the array.

Use the Class Explorer to find class names. Or visit https://www.clarissewiki.com/4.0/_modul ... neric.html.

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


Return to Scripting