I don't understand dynamic component scaling

I don't understand dynamic component scaling

Postby Msketcher » Thu Oct 23, 2014 4:49 pm

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?
1
User avatar
Msketcher 
 

Re: I don't understand dynamic component scaling

Postby Krisidious » Thu Oct 23, 2014 5:57 pm

Join the club...
0
By: Kristoff Rand
Home Designer
Unique House Plans
User avatar
Krisidious 
 

Re: I don't understand dynamic component scaling

Postby quantj » Thu Oct 23, 2014 8:34 pm

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

quantj 
 

Re: I don't understand dynamic component scaling

Postby quantj » Thu Oct 23, 2014 8:35 pm

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

quantj 
 

Re: I don't understand dynamic component scaling

Postby Msketcher » Thu Oct 23, 2014 8:57 pm

quantj wrote: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?
0
User avatar
Msketcher 
 

Re: I don't understand dynamic component scaling

Postby quantj » Thu Oct 23, 2014 9:49 pm

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

quantj 
 

Re: I don't understand dynamic component scaling

Postby pcmoor » Thu Oct 23, 2014 9:50 pm

use two variables

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


Summary =length & " x " & wide

this should force the redraw
0

pcmoor 
 

Re: I don't understand dynamic component scaling

Postby Msketcher » Thu Oct 30, 2014 2:46 pm

pcmoor wrote: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.
0
User avatar
Msketcher 
 

Re: I don't understand dynamic component scaling

Postby Trogluddite » Thu Oct 30, 2014 5:30 pm

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

Trogluddite 
PluginStore Author
PluginStore Author
 

Re: I don't understand dynamic component scaling

Postby Msketcher » Thu Nov 13, 2014 2:13 pm

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
User avatar
Msketcher 
 

Re: I don't understand dynamic component scaling

Postby pcmoor » Thu Nov 13, 2014 11:01 pm

try this,

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

pcmoor 
 

Re: I don't understand dynamic component scaling

Postby Msketcher » Fri Nov 14, 2014 1:23 am

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
User avatar
Msketcher 
 

Re: I don't understand dynamic component scaling

Postby pcmoor » Fri Nov 14, 2014 8:37 am

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
0

pcmoor 
 

Re: I don't understand dynamic component scaling

Postby Jim » Fri Nov 14, 2014 9:08 am

pcmoor wrote: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.

http://help.sketchup.com/en/article/94906
1
Hi

Jim 
Global Moderator
 

Re: I don't understand dynamic component scaling

Postby pcmoor » Fri Nov 14, 2014 9:32 am

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

pcmoor 
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Dynamic Components

Who is online

Users browsing this forum: No registered users and 2 guests

Visit our sponsors: