Animate doesn't return to normal
-
I have a component that has an onclick function that looks like this : "animate(swing_angle,0,-90)"
This changes the custom variable called "swing_angle" which is located right next to the above rule in the same component.
a sub-component has a rule that its RotX is "=Main Component!swing_angle"
Anyhow, if I click on the whole thing, the sub-component swings down like I want. When I click it again, I expect it to go back to where it was (0 degrees). Instead, it doesn't animate back, but makes a new custom variable called "-90" with a value of "0".
Anyone know why a new custom variable is created instead of just changing swing_angle back to 0?
-
Without seeing the file I'd say it sounds like a bug.
Best,
Jason. -
Jason - The file is available in fizgig's 'Anyone know why changing "RotZ" to 45...' thread.
I would agree that this is a Sketchup bug; I was able to duplicate the problem in a new file using new Components. If a negative value is used in the OnClick 'Animate' or 'Set' functions a new Attribute is created when the negative value is reached; the Attribute is given the name of the -value; it can be deleted but not edited.
I'm new to DCs but I checked the advice on usage in the 'Dynamic Components Function Examples' and I don't think there is an problem with fizgig's usage.
Regards, S -
No-one else stepped in so I've done a bit more research and there is a problem with the coding in fizgig's DC. To quote the 'Assembling a Dynamic Component' example from this site; "When you want to reference an attribute value quotation marks are not needed. If you are telling an attribute to do something they are needed". The quotes are noticeably missing around 'swing_angle' in fizgig's component... adding them in fixes the problem of creating a rogue attribute. It doesn't however fix the referencing issues, but these can be corrected by moving the 'onClick ANIMATE' command to the BODY part of the component.
-
@saladyne said:
No-one else stepped in so I've done a bit more research and there is a problem with the coding in fizgig's DC. To quote the 'Assembling a Dynamic Component' example from this site; "When you want to reference an attribute value quotation marks are not needed. If you are telling an attribute to do something they are needed". The quotes are noticeably missing around 'swing_angle' in fizgig's component... adding them in fixes the problem of creating a rogue attribute. It doesn't however fix the referencing issues, but these can be corrected by moving the 'onClick ANIMATE' command to the BODY part of the component.
Sorry Saladyne, I didn't see your post there. Funny enough, I ran into the problem again and knew I had discussed it before. I just came back and searched for my posts and found this thread and your last post about the need for quotes. That did the trick. Thanks so much!
Advertisement