Author Topic: Scaling (?) problem  (Read 822 times)

Gymbo

  • Jr. Member
  • **
  • Posts: 77
Scaling (?) problem
« on: April 18, 2018, 04:09:06 PM »
Hi,

This is a macro to change the demension text size base on the drawing size. I tested it on one of my old drawings and it worked well until I scaled the drawing up by a factor of 10. The original size of the text (after running the macro) is 0.342" after scaling the drawing up it's 33.8"! I've attached screen shots of the "Window" with the variables, the missing variable 'y' is not used anymore as well as 'x3'. I've also attached the drawing.


Code: [Select]
'change dimension text size based on drawing size
INCLUDE "dcadalias.d3i"

x = sys(120) 'min x value
x1 = sys(122) 'max x value
y2 = sys(123) 'max y
y1 = sys(121) 'min y

x2 = x1 - x 'total length of drawing
y3 = y2 - y1 'total ht of dwg
if x2 >= y3 then
vs = x2
else
vs = y2 / 3
endif

ts = vs * 0.015 'new text size

en = sys(9)
for i = 1 to en
entity i
Query Ent_type, type
if type >73 and type < 82 then
change D_TEXTSIZE, ts
change D_ARROWSIZE, ts * 0.8
end if
next
update
regen
end

So what am I missing?
Regards,

Jim

Dr PR

  • Hero Member
  • *****
  • Posts: 5614
Re: Scaling (?) problem
« Reply #1 on: April 18, 2018, 08:35:58 PM »
Does either or both of the drawings have an assigned drawing unit, or is either or both unitless?

Phil
DesignCAD user since 1987

Lar

  • Hero Member
  • *****
  • Posts: 2818
Re: Scaling (?) problem
« Reply #2 on: April 19, 2018, 12:11:14 AM »


I don't know what effect this would have on the text size but the "update" should be before the "end if", otherwise you are only updating the very last entity, and if that is not a dimension then I don't know what will happen.


...BUT, if the macro worked at all (ie, before the scaling) then it sounds like "update" is not really necessary!!


Lar
« Last Edit: April 19, 2018, 12:15:26 AM by Lar »

Lar

  • Hero Member
  • *****
  • Posts: 2818
Re: Scaling (?) problem
« Reply #3 on: April 19, 2018, 07:30:06 AM »



Well Gymbo, it seems you have uncovered one of dcad's dark secrets.


It looks like when a dimension is scaled it remembers the scale factor and if you use the change command to edit the dimension's text size it then applies the scale factor to whatever number the change command stipulated. <<fyi, blocks and symbols also remember their scale factor>> ,<<Text entities don't appear to do this>>

You can test this by making 2 duplicates of you drawing and scale one of them 2x and the other 1/2x, then run your macro. The text sizes in the scaled duplicates will reflect how they were scaled. It also seems a scaled dimension will always carry the scale factor with it, even when you edit the text size directly using the info box. The only way to get rid of the scale factor, far as I can tell, is to select it then use the SameAs finger (from the info box) and click on another unscaled dimension. Using the SameAs finger on another scaled dimension will acquire that dimension's scale factor. Another weirdcool thing is if you select more than one scaled dimension, even with different visual scales but with the same base scale, and then check their text sizes using the *edit multiple dimensions* button in the info box, the reported text size will be the base size, not the scaled size (remember, this would normally be blank for different values).


The good thing is you don't really have to run the macro if you scale the drawing, because the dimensions' text sizes (and all their other parameters) will be scaled to the relative size. Just run the macro when you're finished with the drawing to get the size the macro dictates. If after doing this you discover that some of the dimensions have scale factors (because their text sizes would be different) then just use the Selection Filter to select all the dimensions and use the SameAs finger to click on one of the proper dimensions. This will correct all the dimensions in one step. If all the dimensions are scaled then draw a new random dimension and run the macro, then select all the dimensions and use the SameAs finger to click on the new dimension (which would have the size the macro stipulates).

Lar
« Last Edit: April 19, 2018, 07:55:17 AM by Lar »

Gymbo

  • Jr. Member
  • **
  • Posts: 77
Re: Scaling (?) problem
« Reply #4 on: April 19, 2018, 07:37:53 AM »
Does either or both of the drawings have an assigned drawing unit, or is either or both unitless?

Phil

In Options-Dimensions Units is set to Default, looking at the Info Box-Units/Tolerance 3 of the dimensions show as Unitless, all others show as Inches before and after scaling.
Regards,

Jim

Gymbo

  • Jr. Member
  • **
  • Posts: 77
Re: Scaling (?) problem
« Reply #5 on: April 19, 2018, 07:45:25 AM »

Well Gymbo, it seems you have uncovered one of dcad's dark secrets.

It looks like when a dimension is scaled it remembers the scale factor and if you use the change command to edit the dimension's text size it then applies the scale factor to whatever number the change command stipulated.

Lar, that's good to know, the only reason I scaled the drawing at all was to test the macro for different sized drawings, so I'm guessing the macro works fine, and if I need to scale a drawing run the macro first. :)

Will test the 'update' issue later today.
Regards,

Jim

Lar

  • Hero Member
  • *****
  • Posts: 2818
Re: Scaling (?) problem
« Reply #6 on: April 19, 2018, 08:04:26 AM »

... and if I need to scale a drawing run the macro first. :)
If you need to scale a drawing then a] if the drawing already has dimensions just scale everything and don't run the macro at all; b] if no dimensions, scale then draw in fresh dimensions then run the macro.


As for "update" it seems once at least one is in there somewhere after the last change command then all is good... but still test to see what results you get.


Lar

Gymbo

  • Jr. Member
  • **
  • Posts: 77
Re: Scaling (?) problem
« Reply #7 on: April 19, 2018, 08:35:00 AM »

As for "update" it seems once at least one is in there somewhere after the last change command then all is good... but still test to see what results you get.

Lar

In this macro, tested on several drawings, 'update' made no difference where it was or if it was there at all! I've had macros the crashed DesignCAD if 'update' was left off after a 'change'.
Regards,

Jim

bdeck

  • Hero Member
  • *****
  • Posts: 896
Re: Scaling (?) problem
« Reply #8 on: April 19, 2018, 08:46:36 AM »
gymbo
Is it possible that in your drawing y2 is negative?  oops.  not if your printouts are correct I guess.

saw this line     "vs = y2 / 3"          and  thought it might be a typo.
« Last Edit: April 19, 2018, 09:00:29 AM by bdeck »

Gymbo

  • Jr. Member
  • **
  • Posts: 77
Re: Scaling (?) problem
« Reply #9 on: April 19, 2018, 08:58:56 AM »
gymbo
Is it possible that in your drawing y2 is negative?
I just double checked, and 'x' and 'y1' are the only negitives after scaling, none before.
Regards,

Jim

bdeck

  • Hero Member
  • *****
  • Posts: 896
Re: Scaling (?) problem
« Reply #10 on: April 19, 2018, 10:21:57 PM »
Well Gymbo, it seems you have uncovered one of dcad's dark secrets.

Lar,

Thanks for the heads up.

Even if there is a good reason for such a factor, it would be helpful if it were documented somewhere, so one could  compensate for it in a case like this.

The only way I know to compensate for it is to change a dimension text size to a fixed value S, then query the resulting text size U. The secret scale factor is the ratio of the two values U/S.   

Regards
bd

Code: [Select]
' ds.d3m 
' Macro demonstrating how to change dimension text and arrow size when some dimensions have been scaled previously.
' Works  on all dimensions, regardless of scaling / no scaling. (does not do dimensions in blocks/symbols)
' Thanks to Lar and Gymbo for bringing the wierdness of "secret scale factors" to our attention. BD

INCLUDE "dcadalias.d3i"

input "text size  ", ts

asc0=.8          ' desired arrow scale
asz0=ts* asc0    ' desired arrow size
ofs0=ts*.5 ' desired text offset

en = sys(9)
for i = 1 to en
entity i
Query Ent_type, type
if type >73 and type < 82 then
entity i

query D_TEXTSIZE, ts1 'diagnostic only
query D_ARROWSCALE,  asc1 'diagnostic only
query D_ARROWSIZE, asz1 'diagnostic only

change D_TEXTSIZE, ts
update
query D_TEXTSIZE, u
SF = u / ts ' compute secret scale factor
change D_TEXTSIZE, ts/SF
'change D_ARROWSIZE, asz0/SF 'use this line or the next, not both
change D_ARROWSCALE, asc0      'if used, must be used after each text size change to change arrow size
change D_TEXTOFFSET ofs0/SF 'optional
update

query D_TEXTSIZE, ts2 'diagnostic only
query D_ARROWSCALE, asc2 'diagnostic only
query D_ARROWSIZE, asz2 'diagnostic only

regen
print "i, ts, asc0, asz0  = ", i, ts, asc0,asz0,"    ts1,  ts2  = ",ts1, ts2,"    asc1, asc2  =  ",asc1,  asc2,"    asz1, asz2  = ",asz1,asz2,"       Hit any key "
anykey k
if k=27 then end      'escape key
end if
next
« Last Edit: April 20, 2018, 12:14:38 PM by bdeck »

Lar

  • Hero Member
  • *****
  • Posts: 2818
Re: Scaling (?) problem
« Reply #11 on: April 20, 2018, 11:12:57 AM »

Well Gymbo, it seems you have uncovered one of dcad's dark secrets.
Y'know, looking back at that statement it looks like I was always aware of this secret and now I'm admitting to it, but I want y'all to know this was news to me too!!


The only way I know to compensate for it is to change a dimension text size to a fixed value S, then query the resulting text size U. The secret scale factor is the ratio of the two values U/S.   
Slick thinking BD. That code could be like a contingency when running dimension macros.


IMO, most-if-not-all of the dc18-&-beyond dimension parameters are to cater to exporting to autocad so I guess this is just another side effect to that reality. <<I can't complain because my whole reason for joining the dcad forum back around 1998 (or 9) was to lobby for that ability. I'll admit I didn't do much more lobbying though. Dealing with dcad's many quirks back then kept all of us busy. Besides, soon after that I wrote a dcad macro that
wrote a lsp macro to re-create dimensions in an acad drawing.>>



Lar 

Gymbo

  • Jr. Member
  • **
  • Posts: 77
Re: Scaling (?) problem
« Reply #12 on: April 20, 2018, 03:06:09 PM »

Well Gymbo, it seems you have uncovered one of dcad's dark secrets.

Anyone have a list of these 'dark secrets'?
Regards,

Jim

Dr PR

  • Hero Member
  • *****
  • Posts: 5614
Re: Scaling (?) problem
« Reply #13 on: April 20, 2018, 09:30:47 PM »
It's called the "User Forum" and it appears to me that the list is endless.

Phil
DesignCAD user since 1987

Lar

  • Hero Member
  • *****
  • Posts: 2818
Re: Scaling (?) problem
« Reply #14 on: April 21, 2018, 12:35:27 PM »

Paper Space once had loads of dark secrets but they were eventually done away with.


The only other d-secrete I can think of right now lies within the Front Camera Cutting Plane. The intent of this cutting plane is to allow us to see the inside of a model and not just its exterior. The side effect is it causes parts of the model to be undesirably invisible in close perspective views and far isometric views.


The secrete here is that the front cutting plane is always midway between the viewer location and the focal point. It is normally a pain but can be beneficial in that you can place the cutting plane so that you get a non-destructive slice wherever you want it. This view can even be printed. It is always perpendicular to the camera, though, so anything other than level or plumb viewing angles can look pretty disgusting.


In my opinion, the front cutting plane should be at or slightly behind the camera, the rear cutting plane should be optional or done away with, and we should have free front cutting planes that can be anywhere and at any angle.


Lar