• Login
sketchucation logo sketchucation
  • Login
πŸ”Œ Quick Selection | Try Didier Bur's reworked classic extension that supercharges selections in SketchUp Download

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.
  • C Offline
    Chris Fullmer
    last edited by 15 Dec 2009, 06:46

    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
    • P Offline
      plot-paris
      last edited by 15 Dec 2009, 09:35

      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 15 Dec 2009, 15:12

        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 15 Dec 2009, 15:27

          And here's your modified model.


          sliding_door[jf].skp

          Hi

          1 Reply Last reply Reply Quote 0
          • P Offline
            plot-paris
            last edited by 15 Dec 2009, 15:40

            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 15 Dec 2009, 17:32

              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
              • C Offline
                Chris Fullmer
                last edited by 15 Dec 2009, 17:42

                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
                • P Offline
                  plot-paris
                  last edited by 15 Dec 2009, 17:57

                  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
                  • C Offline
                    Chris Fullmer
                    last edited by 15 Dec 2009, 18:18

                    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
                    • P Offline
                      plot-paris
                      last edited by 15 Dec 2009, 23:11

                      @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
                      • T Offline
                        thomthom
                        last edited by 15 Dec 2009, 23:22

                        @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
                        • P Offline
                          plot-paris
                          last edited by 21 Dec 2009, 10:25

                          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
                          • C Offline
                            Chris Fullmer
                            last edited by 21 Dec 2009, 17:22

                            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
                            • P Offline
                              plot-paris
                              last edited by 21 Dec 2009, 17:43

                              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
                              1 / 1
                              • First post
                                12/16
                                Last post
                              Buy SketchPlus
                              Buy SUbD
                              Buy WrapR
                              Buy eBook
                              Buy Modelur
                              Buy Vertex Tools
                              Buy SketchCuisine
                              Buy FormFonts

                              Advertisement