DC's and Multiple Material Selection Options - Coding Help

Hi All,

I’m kind of stuck on a Dynamic Component I’m trying to build. I’m trying to build a Dynamic Logo with multiple Sizing/Layer Dimension functions AND Material Preset functions based on a Brand Guide. For this example I’ve been working with TCU’s logo because there’s only 4 Brand Colors to choose from.

The problem is I’m not super familiar with the CHOOSE and OPTIONINDEX functions. I’m attaching the SketchUp file below with a stab at trying to get it to work in one of the components.

So to help narrow you down, I’m trying to create a Dynamic Logo that can change between 10 Preset Color Configurations AND be able to switch between Gloss, Matte, Emissive, and Metal Logo Material types.

So ideally I’d be able to select “Gloss” from the Material Type Drop Down in Options, and then Select “2-Color, Purple, Black” so that it returns a 2 Color Logo with the Gloss Material Set showing on the face.

You can see the materials are all labeled uniquely and placed in the individual objects so that the Material Function references them. But I can’t seem to get the Material to reference anything beyond “TCU_PURPLE_Matte”

Any help would be greatly appreciated. I know it’s a pretty big ask but hopefully it’s not as complicated as I think it’ll be.

Thanks,

T.

TCU_DYN_LogoTest.skp (3.4 MB)

I have tried another method. Instead of listing the colors in the individual components I’m putting them in the drop down menu’s up top and using numbers in the code lines.

It seems to work better in that I can get the series of materials to reference correctly, but now it’s throwing an error that the materials aren’t in the model… But there are swatches in each one so I guess that’s a new problem?

I’m attaching a revised file.

Thanks,

t.TCU_DYN_LogoTest_Rev1.skp (3.1 MB)

The swatches are not the problem, but your understanding of choose is. You can’t pick from a string variable,
astring = “blue”,“red”,“orange”
choose(2,astring) does not work
whereas choose(2,“blue”,“red”,“orange”) does

the optionindex returns the index of a chosen dropdown value, so in a dropdown choice of fruit, being orange, apple, pear, banana. Then pear would return 3, if placed in the above choose index parameter it will return “orange”

so with your choice of “Material Configuration” dropdown, the returned index can be used to select from a list of colors for inner, outer, main strokes

TCU_DYN_LogoTest_Rev1 (2).skp (3.1 MB)

2 Likes

Thank You So Much. I didn’t realize you could break up the syntax the way you did so that it references the materials differently. Thanks for the help. I’ll take this and try to replicate it on my own to try and nail this workflow down.

I have a quick question. I’m trying to replicate the variables with a slightly more organized tree and material name. I’ve noticed the line

“IF(OPTIONINDEX(“MAT_Config”)<10, MAT_Type”")"

I’m pretty sure the 10 comes from the number of materials listed in the Option Index line before this where you list out the materials individually. I’ve added a couple more options in an attempt to broaden it and expand on what you helped lay down. However I’m coming up where the additional options are returning the wrong values.

May I ask for some advice on the thought process behind how many of those materials you listed? I can try to figure it out myself if you’re willing to just shed some light on it.

Is it just listing out the total number of times that Component will have a material assigned to it and then just listing those out?

Thanks,

T.

you are correct, the metal option has a different syntax so need to separate this.

The basic four colors have option to change their finish, gloss,…
So rather creating a list of all, allowed this to be appended to the color, of course the metal is an exception
You could change this so the full material name be place in each choice for the strokes, as you add to the dropdown you must also add to to the choose formulas
However this would mean the finish dropdown would be redundant

you could make a rule if metal is part of the mix,
if(find(“metal”,amaterial & “metal”,1)< len(amaterial),1,0) would show if “metal” is in the attribute amaterial
find requires the item it is searching for to be part of the string,otherwise it fails

1 Like

Thank You So Much. After posting that previous comment I went through and basically read the code out manually and figured the material naming stuff out. I now have 12 combinations including a “Null Material” if needed for something super unique. But so far the team seems happy with it and I’ll take the new Logo I just built from scratch and try to get a full logo set on Monday with other TCU assets.

Again, Thanks.

T.

1 Like