• Login
sketchucation logo sketchucation
  • Login
ℹ️ GoFundMe | Our friend Gus Robatto needs some help in a challenging time Learn More

I don't understand dynamic component scaling

Scheduled Pinned Locked Moved Dynamic Components
sketchup
15 Posts 6 Posters 4.0k Views
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.
  • M Offline
    Msketcher
    last edited by 23 Oct 2014, 15:49

    I'm trying to create a dynamic component that displays the length and width in the summary attribute of the component options window. I'm talking really simple here, like a rectangle.

    I've added the size attributes to the component, untouched, so they read the current size of the component. Then, in the summary attribute, I have the following formula:

    http://content.screencast.com/users/SpiderT3/folders/Snagit/media/b279afd2-d750-4758-b08b-87bf85fcd08a/10.23.2014-11.22.png

    So, I would think that the Summary attribute would read as follows: 60x40

    But, instead it looks like this:

    http://content.screencast.com/users/SpiderT3/folders/Snagit/media/c8bedab9-d458-487c-91b0-4e1a719243fa/10.23.2014-11.25.png

    I don't get why or where the ...00036 is coming from, as the rectangle is exactly 40". If I continue to scale the rectangle, additional decimal places appear, and they won't go away. Even if I scale to an exact whole number dimension by referencing other points or guides in my model, there are always additional random numbers, indicating that I'm not exactly on a whole number dimension.

    http://content.screencast.com/users/SpiderT3/folders/Snagit/media/97dea851-9d98-4e44-9f03-9c2ded5489a7/10.23.2014-11.39.png

    I know I can use the ROUND() function to make it look nicer, but that's not the problem. The dimension is wrong. If I snap to 40", the dimension should read 40.000000000000", not 40.000000000036", or whatever.

    Scaling to precise dimensions

    The other thing that completely baffles me is why dynamic components don't redraw automatically when scaling to an exact dimension using the VCB. Isn't that the whole purpose of dynamic components? You create restraints within the component so the end user can scale it to whatever they want and the dynamic component will redraw according to the constraints defined by the author?

    In what situation would you not want a dynamic component to redraw? And why DOES it redraw when scaling arbitrarily when using the handles, but it DOESN'T redraw when typing in a precise factor or dimension in the VCB?

    The other thing I don't get, is let's say I scale my component from 3' to 2' using the VCB. I use the scale tool to start, then type in 24" ENTER. If I look at the Component Attributes right after doing this, LenX shows 24", But my Summary formula still shows the old dimension of ~36", even though the formula is referencing LenX!!

    http://content.screencast.com/users/SpiderT3/folders/Snagit/media/f7a07efc-a5b0-4124-a421-13ce20b56e5f/10.23.2014-11.49.png

    I have to right click on the component, go to dynamic component -> Redraw, before the Summary formula reads "correctly". That's in quotes because it still displays an incorrect dimension as 24.000000000000000004 instead of 24.0

    http://content.screencast.com/users/SpiderT3/folders/Snagit/media/54d009bd-0fe0-4e77-bfd1-1bb39054b1f8/10.23.2014-11.53.png

    Any insight on what's going on here, and if it's something I'm doing wrong?

    1 Reply Last reply Reply Quote 0
    • K Offline
      Krisidious
      last edited by 23 Oct 2014, 16:57

      Join the club...

      By: Kristoff Rand
      Home DesignerUnique House Plans

      1 Reply Last reply Reply Quote 0
      • Q Offline
        quantj
        last edited by 23 Oct 2014, 19:34

        I couldn't get the "x" in, so I made mine refer to another value which I then put in x. I also used INT to force round the numbers. If want fractions, maybe there's another formula for that...


        Scale-test.skp


        Screenshot 2014-10-23 15.39.37.jpg

        1 Reply Last reply Reply Quote 0
        • Q Offline
          quantj
          last edited by 23 Oct 2014, 19:35

          I have noticed sometimes sketchup adds the 0.000000000random little number, and yea, never figured it out

          1 Reply Last reply Reply Quote 0
          • M Offline
            Msketcher
            last edited by 23 Oct 2014, 19:57

            @quantj said:

            I couldn't get the "x" in, so I made mine refer to another value which I then put in x. I also used INT to force round the numbers. If want fractions, maybe there's another formula for that...

            I think you just need to put quotes around the x when using Concatenate so it treats it as a string. Yeah, I could use INT to clean it up too. The whole redraw thing is what I find really frustrating. Why doesn't it read the LenX property when typing in an absolute value? Why do you have to redraw?

            I mean, it seems like this was done on purpose *(why else would there be an option in the context menu to redraw?)*but I don't understand WHY?? When would you ever NOT want a dynamic component to redraw? Shouldn't it do it automatically every time?

            1 Reply Last reply Reply Quote 0
            • Q Offline
              quantj
              last edited by 23 Oct 2014, 20:49

              Yea I tried adding quotes and it just didn't work.
              I don't why it won't redraw automatically. I have same problem with my models.

              I have a dynamic table with option for amount of chairs to appear (Copy function), however if I scaled/change the the table height, the main chair height will scaled proportionally, but all the copy chairs won't. Very frustrating, my only way is to choose table height first before choosing chairs amount.

              1 Reply Last reply Reply Quote 0
              • P Offline
                pcmoor
                last edited by 23 Oct 2014, 20:50

                use two variables

                length =current("LenY")
                wide =current("LenX")

                Summary =length & " x " & wide

                this should force the redraw

                1 Reply Last reply Reply Quote 0
                • M Offline
                  Msketcher
                  last edited by 30 Oct 2014, 13:46

                  @pcmoor said:

                  use two variables

                  length =current("LenY")
                  wide =current("LenX")

                  Summary =length & " x " & wide

                  this should force the redraw

                  So you're saying that by referencing the LenX and LenY values indirectly using custom variables, it forces a redraw? I'll have to try that. I noticed that's what the SketchUp team did in their dynamic windows, but I just assumed it was overly organized or something.

                  1 Reply Last reply Reply Quote 0
                  • T Offline
                    Trogluddite
                    last edited by 30 Oct 2014, 16:30

                    IIRC, it's not so much using a proxy variable that makes it work - it's the use of the 'current()' function.

                    As an example, consider you made a DC where the equations only allowed a component to be an exact number of feet long - very common for models of kitchen units, building supplies etc. When you resize it, things happen something like this...

                    • You resize your component by whatever method - which changes, say, LenX. We didn't bother snapping to anything because we know the component only allows valid sizes.
                    • The calculations are done by sub-components inside the DC to calculate their sizes - this causes a new value of LenX to be calculated, conforming to the 'whole units' constraint.
                    • But if LenX just got calculated to a new value, different than the one supplied by the scale tool, that means that the DC just got resized again.
                    • If SU were allowed to see that change as another re-scaling, it could set all the calculations running again - and with a very complex DC, this might just go on and on forever, with every calculation triggering yet another re-scale.

                    The 'current()' function is used to resolve this problem - it's guaranteed to read the value either before the calculations start, or after they have all finished (which one, or both, I can't quite remember). It ensures that you receive a nice stable value, and that the maths has a proper beginning, middle and end, with each resize only calculated once.

                    PS) Technically, that's probably nothing like what really happens! But I found that keeping that idea in my mind really helped me get my first few DCs working.

                    1 Reply Last reply Reply Quote 0
                    • M Offline
                      Msketcher
                      last edited by 13 Nov 2014, 13:13

                      I just tried using the =current() function, and it still doesn't redraw when I use the Scale tool then type in a precise measurement.

                      • Scale the component an arbitrary distance = shows correct size after scaling

                      -Scale the component an arbitrary distance, then type in a precise distance/ENTER = size shows the original dimensions, not the new dimensions.

                      1 Reply Last reply Reply Quote 0
                      • P Offline
                        pcmoor
                        last edited by 13 Nov 2014, 22:01

                        try this,

                        note in metric 2.54 is required for conversion when using "current"


                        scale update.skp

                        1 Reply Last reply Reply Quote 0
                        • M Offline
                          Msketcher
                          last edited by 14 Nov 2014, 00:23

                          I downloaded your file. Same problem. If I scale the rectangle, then immediately type 200cm ENTER, the summary display is wrong. I just don't understand why it would behave this way.

                          1 Reply Last reply Reply Quote 0
                          • P Offline
                            pcmoor
                            last edited by 14 Nov 2014, 07:37

                            You have a misunderstanding of the scale tool, the scale is changed by the factor you enter, if you move with scale tool then enter 2, the result would be 2 times the previous size, or 0.5 would be half.

                            if you made a unit size, say 1 inch, then entering 25.75 then it would be 25.75 inches,

                            or say 1000mm then entering 3.45 makes the side 3450mm

                            1 Reply Last reply Reply Quote 0
                            • J Offline
                              Jim
                              last edited by 14 Nov 2014, 08:08

                              @pcmoor said:

                              You have a misunderstanding of the scale tool, the scale is changed by the factor you enter, if you move with scale tool then enter 2, the result would be 2 times the previous size, or 0.5 would be half.

                              if you made a unit size, say 1 inch, then entering 25.75 then it would be 25.75 inches,

                              or say 1000mm then entering 3.45 makes the side 3450mm

                              The Scale tool has always allowed scaling to dimensional values in the Measurements box. In your example, you could also enter 2" which would result in the object being "scaled" to exactly 2"

                              It's a bug in DC's that they are not redrawn when using the Measurements box.

                              Attention Required! | Cloudflare

                              favicon

                              (help.sketchup.com)

                              Hi

                              1 Reply Last reply Reply Quote 0
                              • P Offline
                                pcmoor
                                last edited by 14 Nov 2014, 08:32

                                thanks Jim, I learnt another thing about this amazing program, hopefully 2015-16 will bring about a revamp of DCs

                                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