Using Variables of parent DCs
-
Chris, cool trick with just clicking the parent component. that was what I was looking for.
but now I ran into another problem... how can I animate a child component, when a variable in the parent component is changed from lets say 0 to 1?
is there a function like an onVariableChange function, similar to the onClick function?just that you understand what I want to do, I attached the door I want to animate. once clicked, all the door elements should slide to the side...
and Howard: sorry, your problem is far too complicated for me to follow
-
animate some variable from 0 to 100%. This will allow you to synchronize multiple animations.
In the parent:
onClick: animate("actuator", 0, 100) actuator: 0
All child components can use the animated variable:
actuator: =parent!actuator RotZ: =actuator/100 * 90
You don't even need the create another variable in the child:
RotZ: =parent!actuator/100 * 90
-
-
aaaah. I looked at it the wrong way around.
so the way to go is actually animating the variable as opposed to the variable triggering the animation... thank you very much Jim. -
I think it is a good, generalized solution to use in many circumstances.
I'm glad I could help.
-
Watch out Jakob, once you start playing with DC's you quickly see how much more you could want to do with them. And then its a natural step to start Ruby after that.
DC's are what got me to finally try to learn ruby, and I started learning DC's just one year and 2 weeks ago. Its a slippery slope into the world of ruby
Chris
-
are you serious? you started with ruby only a year ago???
and now you are one of the most active writers out there, having produced many invaluable scripts...
wow. either you are smart as hell or ruby is truly easy - or both -
I needed some extra credits to graduate, so I designed an independent study class to learn ruby. So I touched ruby for the first time in January of this year. So its not even been a year yet. I had written shape bender which is my most complex plugin by the beginning of March. While I'd like to think it's my brains, I'd have to give most of the credit to Ruby's easy to learn syntax. This is the only programming language I know at this point, and I only learned it for SketchUp. And I have no real math training. And it really was learning DC's that showed me that I could learn the syntax and that I had a lot of ideas that could not be implemented in DC's, so it pushed me into ruby. So we'll be expecting you to show up in the developer's section soon
Chris
-
@chris fullmer said:
So we'll be expecting you to show up in the developer's section soon Chris
uff, the pressure!
well, who knows, maybe I will find that Ruby actually is what I've been looking for my whole life. always so many ideas in my head and no means to get them out of there... after your pep-talk I actually feel like getting started...
but first things first. DCs still keep a lot of secrets from me that want to be discovered... -
@unknownuser said:
well, who knows, maybe I will find that Ruby actually is what I've been looking for my whole life.
Do it!
-
I've just got another question.
now I know that I can get a parent component's value to a subcomponent by using 'ParentComponent**!**Variable'.
but is there a way to transfer the value of a subcomponent to a different subcomponent? didn't seem to be working for me... -
You can go child to parent, parent to child, and sibling to sibling. But not grandparent to grandchild - that just sounds silly. But you can't skip over any connection. So if you have a variable and want to pass it down from the top groupd, down to a sub sub sub component, you have to pass it through each sub component along the way. It gets messsy unfortunately.
But you should be able to go from one component to another if they are on the level.
Chris
-
unfortunately that doesn't seem to be working for me.
imagine the following situation: you have got a 'onClick' function assigned to a subcomponent. the function animates a Variable. and now I want this variable to multiply the length of another subcomponent (or even the daughter of another subcomponent).
somehow I don't seem to get this to work...[Edit] I just checked again. the value of the subcomponent's variable isn't passed on to the parent component. neither does it reach another subcomponent. to me it seems values can only be passed down the chain, but not up.
unless you have to use a different way of referencing it, than 'subcomponent!variable'...
Advertisement