Help needed with dc function

Hi everyone ,
I have a question.
If I have custom attribute let say my_material that is a list of
Label - hickory , Value 1111
Label - maple, value 2222
And so on…
Can I set my_material value by typing hickory or maple from another custom attribute let say “b” ?
Is there a way to use optionlabel or other function do so?
Any advice appreciated . Thank you

The optionlabel could be used as an index,combined with choose-function, but the values should be the in the same order eg:

@MikeWayzovski thanks for reply,
I think I want it all the way around.
Just to for you to understand what I want to achieve.
I want to apply texture with name maple to component . Now when I do it I have text maple in material attribute.
I need to set value of my_material custom attribute to value that is labelled maple.

The material needs to be in the model, then

Do you apply it manually, eg. by using the Paintbucket tool?

Now, I am confused, because the formula in my post does that.
Consider the values in the ‘List’ in my_material as an ‘arrays’, eg. {1111,2222,3333,4444}
The Labels in that ‘List’ are now called ‘Maple’, ‘Hickory’, ‘Pine’,‘Steel’ , but are ‘indexed’ : 1,2,3,4

Choose( 2,Maple,Hickory,Pine,Steel) results in Hickory
The Optionlabel-function replaces the first argument of Choose()

EDIT: I just spotted a wrong ‘)’ I will edit my former post

I apply it by bucket.
So if the material changes to maple I need custom my_material to be set to maples value automatically otherwise I have to set it manually…
That my plugin can read it and write to csv export. (The maples value is “material code description of my suplier”. )
the texture image just colours the component to material used in project.

Ah, so in your case, it would be something like:

Note: then, you won’t bother the enduser with the values, the ‘array’ of values is not exposed in Component Option dialog.

If you want the user to choose the material with a list of options, you must edit the Material attribute to be ‘user can select from list’, not the ‘my_material’ attribute, because this gets now defined by formula.

@MikeWayzovski that makes more sense to me now. I will check it in the morning and let you know if I get stuck. Thanks a million

Edit: oh by the way do I have to make the material attribute ’ choose from the list ’ anyway?
Seems that I am missing this part. Because I don’t want the end user to choose from the list but just apply material with paint bucket…

Then, I guess that you would need a ‘Redraw’ or something. Everytime a user paints the object, it needs to be triggered.
my_material.skp (84.1 KB)

1 Like

sometime just as little help will do so much good. thanks