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

    Dynamic component problem(s)

    Scheduled Pinned Locked Moved Dynamic Components
    sketchup
    10 Posts 3 Posters 2.1k Views 3 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.
    • N Offline
      NN24
      last edited by

      Hi guys, I stumbled upon some problems today. I'd appreciate if you have any suggestions about what can i try:

      1. a simple dynamic component - i'd like to contstrain the length to be between eg. 10 and 20 units. I tried using some logic functions (like IF etc.) but ended up with circular reference errors.

      2. global variable - i'd like to add to a global variable a certain value on each creation of a dynamic component, substract when the component is deleted, and modify the global variable if some attributes of the component are changed. I'd like the user to be able to easily monitor the current value of the variable, by showing it in a corner of the model view (or somewhere else). I looked for "oncreate" event or similiar, but components attribute window shows only "onClick".

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

        #2 there is no way to do that built into DC's. You could possible write a ruby script that could do it for you by adding some functionality to the DC's. But anyone that wanted to yuse your DC's would have to install your script also.

        #1 is do-able though. There are some example DC's available to look at. I don't recall which one would be the best one to check out though. But it is possible,

        Chris

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

        1 Reply Last reply Reply Quote 0
        • N Offline
          NN24
          last edited by

          Hi πŸ˜„

          For #1 i tried LenZ=LARGEST(SMALLEST(CURRENT("LenZ"),20),10) ...it works...kind of...it limits the size, but it mess up with the position and all sizes in between the limits. Any idea why?

          #2 - I see πŸ˜‰

          1 Reply Last reply Reply Quote 0
          • N Offline
            NN24
            last edited by

            I attached the file, just try to scale it using scale tool and you'll see.
            The other problem is that typing any value in the Length field erases the component attributes LenZ formula completely πŸ˜„


            custobj.skp

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

              You should be able to accomplish this using a couple IF expressions. I used a cz variable to simplify the IF expression:

              cz: =current("LenZ")

              Then used this to set the Z length:

              LenZ: =if(cz > 300, 300, if(cz < 160, 160, cz))

              The gotcha is that you may need to make sure all the units of the formulas and variables are the same.

              Hi

              1 Reply Last reply Reply Quote 0
              • N Offline
                NN24
                last edited by

                @jim said:

                You should be able to accomplish this using a couple IF expressions. I used a cz variable to simplify the IF expression:

                cz: =current("LenZ")

                How do you put the variable assignment into the component attribute formula ?
                Don't you need a script for that ?

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

                  Well, you click "Add Attribute" and type in the variable name:

                  116.jpg

                  Here's what I ended up with after making some refinement:

                  119.jpg

                  Hi

                  1 Reply Last reply Reply Quote 0
                  • N Offline
                    NN24
                    last edited by

                    Thanks for the tip. However, i discovered that the problem is (i suppose) not due to the formula, but because of the units returned by current("LenZ") which are inches, as opposed to what i use in the formula and all other variables - centimeteres. Model default units are decimal too.

                    After i "adjusted" cz with simple "*2.54" (is there any function i can use to make SU convert units "internally") it started to work and continued to do so for the next minute. Then it got messy again. Why - i don't know.

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

                      There does appear to be something wrong - the value returned by CURRENT("LenZ") is in inches although the .

                      Multiplying by 2.54 should work, so I am not sure why it got messy for you - it is working well for me.


                      120.jpg

                      Hi

                      1 Reply Last reply Reply Quote 0
                      • N Offline
                        NN24
                        last edited by

                        Hi,

                        I typed what i showed exactly and it works now. I think the reason was either the formula that used largest/smallest or using constants istead of variables, though what's the difference - i dunno.

                        Thanks for the tip.

                        Last one thing that seems unsolved is how can i make the length parameter editable for the user (eg. if he/she wanted to type in the value) without erasing the formula ?

                        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