Author Topic: Flip Dimension Text  (Read 1287 times)

bdeck

  • Hero Member
  • *****
  • Posts: 780
Flip Dimension Text
« on: June 07, 2015, 03:54:24 PM »
Does what its says.

I'll probably assign mine to a hotkey, but for now I've renamed it FF.d3m, and operate it from the command line.

Thanks DT for reposting the flip parameter.

bd

See reply #8 for a modified version that recognizes progressive dims.

Code: [Select]
' flip.d3m     BDeck   6/7/2015 v0
'
' flip text in all dimensions of current selection set
' If no selection, flip text in last entity drawn, if it is a dimension
'
verno = left$(sys$(105),4)
if verno < 18 then gosub bail

Alias D_SETTEXTFLIPPED &H0A19 

sys(470)=1  ' prevent other commands

ne=sys(9)
ns=sys(80)   
if ns >0 then gosub fliplist
if ns <1 then gosub fliplast          ' if none selected get last entity drawn 
regen
end

fliplist:
'for i=1 to ne   ' this loop deleted in favor of faster getselect loop below.
  '       entno=ne-i+1
'GETATTR entno,type,selected
'if selected MOD 2 =1  then gosub dimtest
'next i

        for i=1 to ns
Getselect i, entno
GETATTR entno,type
                gosub dimtest
next i

return

fliplast:               'Optional routine to flip text of last element drawn, if it is a dimension
if ne <1 then end
entno=ne
GETATTR entno,type
gosub dimtest
return

dimtest: ' is it a dimension with text that can be flipped?
if (type >73) and (type<82) then gosub flipit
return

flipit:
entity entno
query D_SETTEXTFLIPPED, qf
cf=1-qf
change D_SETTEXTFLIPPED, cf
update
return

bail:
message "Flip macro requires DC Version 18.0 or higher"
end
return
« Last Edit: June 24, 2015, 04:11:26 PM by bdeck »

samdavo

  • Hero Member
  • *****
  • Posts: 2587
  • the trick is knowin...^ > v < - which way's up?
Re: Flip Dimension Text
« Reply #1 on: June 07, 2015, 09:37:52 PM »
Thanks bd,
It came in really handy for doing the following 8 sets of dimensions (all options both clockwise and anticlockwise around a shape, numbers read from bottom of page or right hand side).
Mind you, I also had to change one (i.e. a prototype) to eg "above" instead of "below" (or vice versa), and then use "same as" to make the rest the same as the prototype.    I enclose the dcd in case anyone wishes to use "Same as" (or to interrogate them - eg as per the attached jpeg of Infobox).
cheers 
« Last Edit: June 07, 2015, 10:14:38 PM by samdavo »

bdeck

  • Hero Member
  • *****
  • Posts: 780
Re: Flip Dimension Text
« Reply #2 on: June 08, 2015, 04:24:10 AM »
Sam,
Your sample dimension file, for use as a "sameas" reference is a great idea.

As an alternative, once one has successfully drawn a progressive dimension, one should immediately record a macro drawing a progressive dimension with the same settings. The macro can later be used to restore those same settings, or it can be inserted into dss08.d3m.

Though it took some effort to come up with working parameters in v24. The new  " <DimHorizontalTextPos 4" seems to allow closer dimension spacing in later versions than in prior versions. Not sure what "<Location 32" does.

Thanks,

BD

Here's an example of a recorded macro to set parameters for drawing progressive dims. (I added the Null parameter at the end, to prevent it from actually drawing the dimension.)

Code: [Select]
>DimProgress
{
  <Color 0,0,0
  <Layer 1
  '<PointXYZ -5.465053400027049e-001,-1.001926456671624e+001,0.000000000000000e+000
  '<PointXYZ -3.122887657158309e-001,-8.197580100040554e+000,0.000000000000000e+000
  '<PointXYZ 2.055901040962553e+000,-8.718061376233607e+000,0.000000000000000e+000
  '<PointXYZ -5.465053400027049e-001,-5.933486548600783e+000,0.000000000000000e+000
  '<PointXYZ -5.985534676220095e-001,-4.762403677166418e+000,0.000000000000000e+000
  <Axis 2
  <Orientation 0
  <Precision 6
  <Format 0
  <Location 32
  <ToleranceType 0
  <ToleranceSize 5.000000000000000e-001
  <ToleranceLow -0.01
  <ToleranceHigh +0.01
  <Tolerance 0.01
  <Suffix "0"
  <Prefix "0"
  <Font "Arial"
  <VectorFont "Simplex_Win"
  <FontType 0
  <Size 5.000000000000000e-001
  <Style 0
  <Type 0
  <Fix 0
  <Gap 2.500000000000000e-001
  <Length 1.200000000000000e-004
  <OverShoot 1.500000000000000e-001
  <Arrowhead 7
  <Arrowhead2 4
  <EnableSecondArrow 1
  <DimUnits 0
  <DimEnableTextInsidePos 1
  <ArrowSize 2.000000000000000e-001
  <OptDimTextOffset 1.250000000000000e-001
  <DimHorizontalTextPos 4
  <DimMovement 0
  <LinePosition 0
  <Multiplier 1.000000
  <Associated 0
  <ForceTextHorizontallyOutside 1
  <TextMovement 0
  <Null
  }

« Last Edit: June 08, 2015, 08:52:28 AM by bdeck »

bdeck

  • Hero Member
  • *****
  • Posts: 780
Re: Flip Dimension Text
« Reply #3 on: June 09, 2015, 08:25:19 PM »
Sam,

At first glance, the format of my progressive dimensions (text over the end of 2nd extension line) would appear to be more compact than yours (text adjacent second xline). But in fact, your layout (or one of them) allows more densely packed data points because it works better with the following macro, which changes the overshoot of any selected extension line by a user-selected multiple of text height, (or the default). By increasing the overshoot of selected extension lines, the macro allows dimensioning of more data points in a smaller area without the need to reduce text size.

Of course, this could be done in the infobox.  But that's just not my style.

Cheers,
bd

Code: [Select]
See revised code below in reply 6
« Last Edit: June 09, 2015, 10:25:11 PM by bdeck »

samdavo

  • Hero Member
  • *****
  • Posts: 2587
  • the trick is knowin...^ > v < - which way's up?
Re: Flip Dimension Text
« Reply #4 on: June 09, 2015, 09:29:38 PM »
bd
Thanks for pointing out / reminding me of the ease of Recording a Macro, lol,  and getting and recording the relevant parameters (with the option of subsequent  manipulation).   Not sure why you add the "Null" instruction, but no biggie.
.............
I enclose an example (red) with dimensions with text size 15, which would arguably be clearer if some were stretched a bit.
..............
As for macro xx.d3m, yep that works well also (gold example) - also I note if you have say 4 of the dimensions selected, you have to input the overshoot 4 times.   And it's not crystal clear that you should use a multiple of text size when you change from the default of 75.  i.e. if your text size is 15, then you either accept 75, or get the same result if you override it with factor 5 (where 5 x 15 = 75). But these are seriously minor OFI's (opportunities for improvement).

i.e. The gold dimensions were achieved with your macro xx.d3m, with an overshoot factor of 3 ( and 3 x 15 - 45);   which changes the gap from 5 to 5+45 = 50.   (See the cyan dimensions which measure text and gaps after dimensions are exploded).
..............
Btw, I add another way to get something similar, (green example), where you simply stretch alternate dimensions to the right using "point-select" mode.  (2 cents)   cheers.  PS But you have to be pretty careful which point you select to stretch it,

PS Back to xx.d3m for a minute,  could it be that you have to turn on sys(470) again? , i.e you have a line ...
sys(470)=1  ' prevent other commands
Unlikely that's the reason I guess - Probably a red herring, but for some reason, the xx macro doesn't want to play again after a run where I chose the default of 75 (??)   i.e. I was trying to prove that a default of 75 was the same as 5 (x text size of 15), but the second time (5)  refused to "fire up".  Cheers
« Last Edit: June 09, 2015, 09:55:09 PM by samdavo »

samdavo

  • Hero Member
  • *****
  • Posts: 2587
  • the trick is knowin...^ > v < - which way's up?
Re: Flip Dimension Text
« Reply #5 on: June 09, 2015, 10:01:34 PM »
Just a trivial tip, but if you are having trouble selecting the dimension you want to stretch, then don't forget that you can select one down near the "start", and then hitting "Enter" will cycle through them (in the sequence that they were added)

bdeck

  • Hero Member
  • *****
  • Posts: 780
Re: Flip Dimension Text
« Reply #6 on: June 09, 2015, 10:15:26 PM »
Oops,

Code fixed so it asks only once. Thanks for the heads-up.

The <null parameter added to the end of the recorded macro prevents the function from actually drawing a dimension. If you want to draw the dimension, rather than just set the parameters for one, comment out the <null parameter, as the <point parameters are commented out. Seems to run ok that way even without the <incomplete parameter.

Quote
Btw, I add another way to get something similar, (green example), where you simply stretch alternate dimensions to the right using "point-select" mode.  (2 cents)   cheers.  PS But you have to be pretty careful which point you select to stretch it,

Yes I noticed some vestigial points that require immediate resort to Cntrl Z. The baseline point (that was there through version 17.2) is no longer available, so when I tried that, I had to adjust each dim line independently. From your last post, it appears you had the same experience?

Regards,
bd

Code: [Select]
' xx.d3m   Extend Extension line    Bdeck  6/9/2015
' Macro to change the overshoot of an extension line, especially in a Progressive Dimension.
' Select an extension line, Run Macro
'     Leave entry blank to add default increment to overshoot
'     Enter any pos or negative number for change in lenght.

verno = left$(sys$(105),4)

if verno < 22.1 then gosub bail

Alias D_EXTENSIONOVERSHOOT  &H0A24
Alias D_TEXTSIZE   &H0A04

sys(470)=1  ' prevent other commands

xflag=0
ne=sys(9)
ns=sys(80)   

if ns <1 then end 
if ns >0 then gosub xlist       
if xflag>0 then regen        ' have any dims been modified?
end

xlist:
for i=1 to ns
Getselect i, entno
GETATTR entno,type,selected
if selected MOD 2 =1  then gosub dimtest
next i
return

dimtest: ' is it a a progressive dimension?
if (type =79) then gosub extendit
return

extendit:
entity entno
query D_EXTENSIONOVERSHOOT, x0
query D_TEXTSIZE, CurrentTextSize

xxd=5    ' DEFAULT CHANGE


if xflag=0 then
xxdp$=xxd
prompt$="Input change to overshoot distance. Default = "+ xxdp$
INPUT [prompt$], xin$
dx=val(xin$)*CurrentTextSize
endif

if Xin$="" then dx=xxd *CurrentTextSize
'   if Xin$="0" then dx=-x0                        'optional alternative to eliminate overshoot

x1=x0+dx
if x1<0 then x1=0

change D_EXTENSIONOVERSHOOT, x1
update
if x0<>x1 then xflag=1
return

bail:
message "macro requires DC Version 22.1 or higher"
end
return
« Last Edit: June 10, 2015, 08:04:55 AM by bdeck »

bdeck

  • Hero Member
  • *****
  • Posts: 780
Re: Flip Dimension Text
« Reply #7 on: June 09, 2015, 10:46:07 PM »
Heres an example of how xx.d3m  works better with one layout than the other.


bdeck

  • Hero Member
  • *****
  • Posts: 780
Re: Flip Dimension Text
« Reply #8 on: June 14, 2015, 09:30:32 AM »
Heres a minor revision to the flip macro. If a single selected entity is part of a progressive dimension, the macro will offer to flip the entire progressive chain, rather than just a single dimension.

bd


Code: [Select]
' ff.d3m     BDeck   6/14/2015 v02
'
'
' flip text in all dimensions of current selection set
' If no selection, flip text in last entity drawn, if it is a dimension
'
' If dimension being flipped is a progressive dimension,
' flip all prog dims having same baseline. (offer opt out)
'
verno = left$(sys$(105),4)

if verno < 18 then gosub bail

Alias D_SETTEXTFLIPPED &H0A19 
Alias ENT_POINT  &H010E 

sys(470)=1  ' prevent other commands

ne=sys(9)
ns=sys(80)   
if ns >0 then gosub fliplist
if ns <1 then gosub fliplast 
        ' if none selected get last entity drawn 
regen
end


fliplist:
for i=1 to ns
Getselect i, entno
GETATTR entno,type
gosub dimtest
next i
if ns=1 then
if type = 79 then
input "flip entire progressive dimension?    0 = No     Default = Yes ", response$
if response$ <> "0" then gosub flipstack
endif
endif
return

fliplast:               'Optional routine to flip text of last element

drawn, if it is a dimension
if ne <1 then end
entno=ne
GETATTR entno,type
gosub dimtest
if type = 79 then gosub flipstack
return


flipstack:               'if last entiity is part of a stack of progressive dims, then flip them all
ent0=entno
entity entno
Query Ent_Point, 1, ptX0, ptY0, ptZ0
diff=0
do while diff=0
entno=entno-1
entity entno
Query Ent_Point, 1, ptX, ptY, ptZ
diff=(ptX0-ptX)^2+(ptY0-ptY)^2+(ptZ0-ptZ)^2
if diff=0 then
GETATTR entno,type
if type=79 then
gosub flipit
else
diff=1
endif
endif
loop

if ns=1 then
    entno=ent0
    diff=0
      do while (diff=0) and (entno<ne)
entno=entno+1
entity entno
Query Ent_Point, 1, ptX, ptY, ptZ
diff=(ptX0-ptX)^2+(ptY0-ptY)^2+(ptZ0-ptZ)^2
if diff=0 then
GETATTR entno,type
if type=79 then
gosub flipit
else
diff=1
endif
endif
    loop
endif
return



dimtest: ' is it a dimension that can be flipped?
if (type >73) and (type<82) then gosub flipit
return

flipit:
entity entno
query D_SETTEXTFLIPPED, qf
cf=1-qf
change D_SETTEXTFLIPPED, cf
update
return

bail:
message "Flip macro requires DC Version 18.0 or higher"
end
return
« Last Edit: August 01, 2015, 07:23:26 AM by bdeck »