Custom attribute for onClick material changing "invalid"

I tried creating a dynamic component that would change material using the onClick function, but the error message pops up either as "Invalid entity to animate: “Light!Material” ". I will try deleting quotation marks, but it pops as "ERROR: could not parse formula: “lgt1”,“lgt2” “. I have the size constrained to 100"x100”. Am I missing something?45 PM

The material name in the colors window “lgtG” doesn’t match any of the names you’re trying to set it to: “lgt1”, “lgt2”. You should be able to refer to the Material without “Light!” before it.

Alright, thank you, now this works perfectly!

I am trying another dynamic component light system, where the three objects are nested in one component, and when clicked, the object visible becomes hidden, and the next one in succession becomes visible. When I unhide all of the nested objects for testing purposes, each object I click on hides a certain two, and always leaves the same one visible, and only the value in the parent component’s attribute changes. I have the attributes below:
30 PM
In the “Hidden” behavior attributes of LightY is =IF(“LightSet!LightShow”=1,0,1).
LightR has =IF(“LightSet!LightShow”=2,0,1).
LightG has =IF(“LightSet!LightShow”=3,0,1).
How can I fix this, and what would the proper order of these attributes be?

You have set the onClick attribute to res. 3,1,3 for LightY,LightR and LightG, thus changing the LightShow attribute to the wrong values. It should be 1,2,3?

It would be easier to help if you’d shared your model. If you don’t want to share your whole file, just upload a small sample that shows the problem you’re having, like just this one dynamic component. By the way, is that your own custom train drawing extension you’re using? I saw the toolbar in your screenshot.

This would be simpler if you could click the parent component and its onClick would set the LightShow variable to cycle through {1, 2, 3}. Each light would then have


Like this:

I know that’s not a real traffic light sequence, but I think that’s the sequence you wanted.

I haven’t tried it with clicking on each light, I’ll try that now.

Here you go with clicking on each light:

Traffic Lights 2.skp (44.0 KB)

As @MikeWayzovski said, you had the number wrong for the next light in the sequence.

1 Like

I may have gotten the numbers wrong when I took the screen shot, but when I tested it with the correct values, the result was the same.

This is good. The error may be because of the values, but there might also be something else wrong. The file you sent is a couple of versions later than I have, since I am using SU2016. The train drawing/animating plugin is actually Julia Eneroth(3)'s plugin. Sadly, I am not a developer, but I do wish to be, soon.
TypeGSignal2016.skp (1.7 MB)

Here’s a SketchUp 2016 version:
Traffic Lights 2016.skp (68.3 KB)

Thank you so much for this. The DC will surely help with making color changing signals! I have posted my file, if you would want to get that working…

In this hidden variable:

You aren’t comparing anything in the IF function and you have an extra argument. I’m not sure what that returns, probably zero as its taking it as FALSE, so the yellow light will never hide.

I’m not sure why you have double-quotes around your variables. I don’t think you need them and don’t know what difference it makes.

I’ve altered your file so that you click yellow, then green, then red. I don’t know anything about train signals but this seems weird. You can change them to what you want. I removed all the double quotes and changed the numbers to what I think you wanted.

TypeGSignalSU16.skp (1.7 MB)

That makes sense. I am not very experienced in dynamic components, so expect every DC I make to be completely faulty. Thank you for the help. I really appreciate it.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.