sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Using Variables of parent DCs

    Scheduled Pinned Locked Moved Dynamic Components
    sketchup
    16 Posts 5 Posters 3.3k Views 5 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • plot-parisP Offline
      plot-paris
      last edited by

      just a quick one. I dimmly remember that there was an option to use Variables of parent components - somehow by adding a $ sign or something - in order to trigger several reactions of nested dynamic components, when onClicking the parent component.

      but I just can't remember, how it is done (haven't done anything with DCs for a loooong time 😳 )

      1 Reply Last reply Reply Quote 0
      • H Offline
        Howard leslie
        last edited by

        Jakob,
        Are you asking a similar question to this one ....???
        http://forums.sketchucation.com/viewtopic.php?f=289&t=23202
        if you are, and find an answer I'd definitely be interested (along with many other people I suspect) !!!
        ...........
        Good luck and please keep us all posted.

        Regards
        Howard L'

        1 Reply Last reply Reply Quote 0
        • Chris FullmerC Offline
          Chris Fullmer
          last edited by

          Jakob, you can put your cursor inside the text field that you want to add the variable, hit the equal sign, then go click on the parent variable and it will add it reference it for you automatically. Its a time saver.

          Chris

          Lately you've been tan, suspicious for the winter.
          All my Plugins I've written

          1 Reply Last reply Reply Quote 0
          • plot-parisP Offline
            plot-paris
            last edited by

            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 😳


            sliding_door.skp

            1 Reply Last reply Reply Quote 0
            • J Offline
              Jim
              last edited by

              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

              Hi

              1 Reply Last reply Reply Quote 0
              • J Offline
                Jim
                last edited by

                And here's your modified model.


                sliding_door[jf].skp

                Hi

                1 Reply Last reply Reply Quote 0
                • plot-parisP Offline
                  plot-paris
                  last edited by

                  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. 😍

                  1 Reply Last reply Reply Quote 0
                  • J Offline
                    Jim
                    last edited by

                    I think it is a good, generalized solution to use in many circumstances.

                    I'm glad I could help. πŸ‘

                    Hi

                    1 Reply Last reply Reply Quote 0
                    • Chris FullmerC Offline
                      Chris Fullmer
                      last edited by

                      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

                      Lately you've been tan, suspicious for the winter.
                      All my Plugins I've written

                      1 Reply Last reply Reply Quote 0
                      • plot-parisP Offline
                        plot-paris
                        last edited by

                        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 πŸ˜„

                        1 Reply Last reply Reply Quote 0
                        • Chris FullmerC Offline
                          Chris Fullmer
                          last edited by

                          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

                          Lately you've been tan, suspicious for the winter.
                          All my Plugins I've written

                          1 Reply Last reply Reply Quote 0
                          • plot-parisP Offline
                            plot-paris
                            last edited by

                            @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...

                            1 Reply Last reply Reply Quote 0
                            • thomthomT Offline
                              thomthom
                              last edited by

                              @unknownuser said:

                              well, who knows, maybe I will find that Ruby actually is what I've been looking for my whole life.

                              Do it! πŸ˜„

                              Thomas Thomassen β€” SketchUp Monkey & Coding addict
                              List of my plugins and link to the CookieWare fund

                              1 Reply Last reply Reply Quote 0
                              • plot-parisP Offline
                                plot-paris
                                last edited by

                                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...

                                1 Reply Last reply Reply Quote 0
                                • Chris FullmerC Offline
                                  Chris Fullmer
                                  last edited by

                                  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

                                  Lately you've been tan, suspicious for the winter.
                                  All my Plugins I've written

                                  1 Reply Last reply Reply Quote 0
                                  • plot-parisP Offline
                                    plot-paris
                                    last edited by

                                    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'...

                                    1 Reply Last reply Reply Quote 0
                                    • 1 / 1
                                    • First post
                                      Last post
                                    Buy SketchPlus
                                    Buy SUbD
                                    Buy WrapR
                                    Buy eBook
                                    Buy Modelur
                                    Buy Vertex Tools
                                    Buy SketchCuisine
                                    Buy FormFonts

                                    Advertisement