Isotropix Forums

Can we make custom attributes that are dropdown lists?

General Discussion about Isotropix and CG related topics

Can we make custom attributes that are dropdown lists?

Unread postby bvz » Wed Nov 20, 2019 3:01 am

For example:

Add
Mutliply
Screen
Linear Dodge

etc.
bvz
 
Posts: 59
Joined: Tue Dec 03, 2013 9:55 am

Re: Can we make custom attributes that are dropdown lists?

Unread postby anemoff » Wed Nov 20, 2019 10:02 am

Hi bvz!

Check out this similar topic: viewtopic.php?p=21767#p21767

Let me know if you need more help.
Anthony Nemoff
Isotropix
R&D Engineer
User avatar
anemoff
 
Posts: 250
Joined: Wed Jan 13, 2016 10:10 am

Re: Can we make custom attributes that are dropdown lists?

Unread postby bvz » Wed Nov 20, 2019 7:20 pm

That is exactly what I needed.

Thanks!
bvz
 
Posts: 59
Joined: Tue Dec 03, 2013 9:55 am

Re: Can we make custom attributes that are dropdown lists?

Unread postby bvz » Wed Nov 20, 2019 8:52 pm

Ok, one more hurdle.

I have a list now that allows the user to select from a set of pre-defined items. But it only appears to work with strings.

In the project file I have this right now:

Code: Select all
                        string "color_projection_blend_mode" {
                            doc "Select the blending mode to use when applying the projection. Your options are: 0=Normal, 1=Alpha Replace, 2=Alpha Add, 3=Alpha Subtract, 4=Alpha Multiply, 5=Alpha Divide, 6=Add, 7=Multiply, 8=Screen, 9=Linear Dodge, 10=Overlay, 11=Difference, 12=Hue, 13=Saturation, 14=Color, 15=Brightness, 16=Mix (simple fade)"
                            preset "Normal" "0"
                            preset "Alpha Replace" "1"
                            preset "Alpha Add" "2"
                            preset "Alpha Subrtract" "3"
                            preset "Alpha Mutliply" "4"
                            preset "Alpha Divide" "5"
                            preset "Add" "6"
                            preset "Multiply" "7"
                            preset "Screen" "8"
                            preset "Linear Dodge" "9"
                            preset "Overlay" "10"
                            preset "Difference" "11"
                            preset "Hue" "12"
                            preset "Saturation" "13"
                            preset "Color" "14"
                            preset "Brightness" "15"
                            preset "Keymix" "16"
                            value "7"
                        }



But to hook this up to the node that is using this custom settings I use the expression:

Code: Select all
settings_loc = get_context(get_context()) + "/settings_leaf";   

get_double(settings_loc + ".color_projection_blend_mode")



This does not work because it is expecting a numerical value, not a string. But if I switch it to:

Code: Select all
settings_loc = get_context(get_context()) + "/settings_leaf";   

get_string(settings_loc + ".color_projection_blend_mode")


It complains that it needs a type "float".

If I try to set the dropdown list to be a type of anything other than "string", it does not show up as a dropdown list. For example:

Code: Select all
                        long "color_projection_blend_mode" {
                            doc "Select the blending mode to use when applying the projection. Your options are: 0=Normal, 1=Alpha Replace, 2=Alpha Add, 3=Alpha Subtract, 4=Alpha Multiply, 5=Alpha Divide, 6=Add, 7=Multiply, 8=Screen, 9=Linear Dodge, 10=Overlay, 11=Difference, 12=Hue, 13=Saturation, 14=Color, 15=Brightness, 16=Mix (simple fade)"
                            preset "Normal" 0
                            preset "Alpha Replace" 1
                            preset "Alpha Add" 2
                            preset "Alpha Subrtract" 3
                            preset "Alpha Mutliply" 4
                            preset "Alpha Divide" 5
                            preset "Add" 6
                            preset "Multiply" 7
                            preset "Screen" 8
                            preset "Linear Dodge" 9
                            preset "Overlay" 10
                            preset "Difference" 11
                            preset "Hue" 12
                            preset "Saturation" 13
                            preset "Color" 14
                            preset "Brightness" 15
                            preset "Keymix" 16
                            value 16
                        }


Does not show a dropdown list, but rather an integer field.

How can I use the dropdown list in an expression that expects a numerical value?
bvz
 
Posts: 59
Joined: Tue Dec 03, 2013 9:55 am

Re: Can we make custom attributes that are dropdown lists?

Unread postby dboude » Thu Nov 21, 2019 10:18 am

Hi,

You have to define the type of values you want to store in the drop-down menu.

I made a quick test. I create the dropdown menu with this :

Code: Select all
config = ix.create_object("Presets", "ProjectItem")
attr = config.add_attribute("my_presets", ix.api.OfAttr.TYPE_LONG)
attr.add_preset("label A", "0")
attr.add_preset("label B", "1")
attr.add_preset("label C", "3")
attr.add_preset("label D", "4")
attr.add_preset("label E", "5")
attr.set_long(0)


Then I grab those values by using :

Code: Select all
get_double(presets.my_presets)


If you want to use strings just change the type when you create the custom attribute.

Cheers !
Démian
Isotropix
Technical Artist - Clarisse Specialist
User avatar
dboude
 
Posts: 1302
Joined: Mon Jul 03, 2017 10:51 am

Re: Can we make custom attributes that are dropdown lists?

Unread postby anemoff » Thu Nov 21, 2019 11:53 am

If you are adding the presets on your custom attribute by editing the .project file, you'll need to reload the project so that Clarisse reads the new attribute definition.

This is what I did:
1. create a long attribute using the Create Custom Attribute tool from the Attribute Editor: at this point, the attribute shows as an integer field;
2. edit the custom attribute directly in the project file to add the presets (using this syntax: `preset "name" "long_value"`);
3. reload the project;
4. now the attribute shows as a dropdown list with the presets I added manually in the project file.

Note: when defining presets, the attribute type should be of type "long" and the preset values must be within quotes.
Anthony Nemoff
Isotropix
R&D Engineer
User avatar
anemoff
 
Posts: 250
Joined: Wed Jan 13, 2016 10:10 am


Return to General Discussion