I don't understand dynamic component scaling
-
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:
So, I would think that the Summary attribute would read as follows: 60x40
But, instead it looks like this:
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.
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!!
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
Any insight on what's going on here, and if it's something I'm doing wrong?
-
Join the club...
-
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 have noticed sometimes sketchup adds the 0.000000000random little number, and yea, never figured it out
-
@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?
-
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.
-
use two variables
length =current("LenY")
wide =current("LenX")Summary =length & " x " & wide
this should force the redraw
-
@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.
-
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.
-
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.
-
-
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.
-
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
-
@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.
-
thanks Jim, I learnt another thing about this amazing program, hopefully 2015-16 will bring about a revamp of DCs
Advertisement