News:

Please note new Forum URL: forum.designcad.com

Main Menu

Dimension Replacement

Started by bdeck, October 24, 2015, 03:37:21 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

bdeck

Note: Please Find a Much Improved version in third post in this thread, includes point4 bug fix.

Design Cad's dimension format was changed drastically in version 18.

With that change DC added some dramatic improvements to the dimension drawing process, with the downside that dimensioning in DC now sometimes requires a bit of extra attention from the user. 

For example, the behavior of DC when drawing an "@" style dimension differs markedly from its behavior when editing the same dimension. This has to do with the odd implementation of the "movement" parameter of the Dimension command.

Here are two macros that work around that behavior to simplify the drawing and editing process.

dd.d3m (Draw Dimension) is a complete replacement for the "@" dimension command.  I assign mine to the alpha "2" key (unshifted "@").

dink.d3m simply toggles the selected dimension(s) between "Movement: no leader" and "Movement: Dim line with text"

Run the dd.d3m macro and set 3 points. Then set a 4th point for the text position, or hit the return key or click the gravity button (RMB) to lock the text position to the location of the 3rd point.

Next time you want to use the mouse to alter the text location of that same dimension, the text and dimension line will move together correctly, just as when the dimension was originally drawn.

Occasionally, if  a dimension is drawn with arrows and text outside the extension lines, DC will put an unwanted line through the text. To eliminate the line, run dink.d3m once. (This will eliminate the stray line, but make the dimension more difficult to edit later. To make the dimension more easily editable again, run the dink.d3m macro again. Dink is a simple toggle, and can be run as many times as desired)

' DD.d3m  Draw Dimension dimension so that text position and dimension line move together
' during both the initial drawing and subsequent editing

Alias D_ENABLEFIXEDTEXTPOS &H0A18

ne0=sys(9)  ' archive number of entities

>Dimension

{
<TextMovement 2
<incomplete 
}

ne=sys(9)

if ne>ne0 then   ' is there a new entity?
getattr ne,type
if type=75 then gosub fixit  ' is the entity a simple @ style dimension?
endif

end

fixit:
entity ne
change D_ENABLEFIXEDTEXTPOS,1
update
regen
return



' Dink.d3m  Dimension Increment  Bdeck  10/ 2015
' Toggles selected dimension(s) between "Movement: no leader" and "Movement: Dim line with text"
' Necessary to remove stray dimension line extensions in DC versions 18-25
' If no dimension is selected, acts on last drawn entity, if it is a dimension.


Alias D_ENABLEFIXEDTEXTPOS &H0A18
Alias ENT_SELECTED  &H010C

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

if ns=0 then           'toggle last entity drawn
entno=sys(9)
gosub checkit
regen         'optional
end
endif

for entno=1 to ne
entity entno
query ENT_SELECTED, isselected
if isselected = 1 then gosub checkit
next entno
regen           'optional
end

checkit:
getattr entno,type
if type=75 then gosub fixit
return

fixit:
entity entno
query D_ENABLEFIXEDTEXTPOS,isfixed
refixed=1-isfixed
change D_ENABLEFIXEDTEXTPOS,refixed
update

return

 


bdeck

#1
NOTE: See third post of this thread for an update of this macro to fix Dcad's asymmetry bug.

This is an update of  the macro presented in the Original Post of this thread.

The prior version required 4 points to be set ( or preferably 3 points and a keypress ). This version needs just 3 points to be set, and is a bit simpler. It automatically makes all the corrections necessary to draw a linear dimension using "Dim Line With Text" movement, which would be unduly difficult without a macro. I have configured my alpha 2 key ( unshifted @ ) to point to this macro as a replacement for the DIMENSION command.

The macro can be configured to run in any of 3 modes documented in the macro text. Choose the mode by setting the value of "auto" to 0, 1, or 2.  Mode 0 is only for those who do not want to implement  Point Select mode unnecessarily.

It works on the principle that DC can edit an existing dimension using "Dim Line With Text" movement, but, in many cases, DC cannot correctly draw the same dimension from scratch.

The macro first draws the dimension using "Dim Line With Text" movement, but with vertical and horizontal text position fixed. It then automatically unlocks the fixed text position on the new dimension, so that user can edit text position easily while still using "Dim Line With Text" movement, and without having to change settings in the info box.


"'' DD2.d3m 
' This is an improvement over previous version.
'
'       It draws a dimension so that text and dimension line are linked
' during both the initial drawing and subsequent editing.
'
' MODES:
' Auto 0: Text Centered, "Dim Line With Text" set for editing
' The macro first draws the dimension with text centered on the dimension line.
' It then changes movement to "Dim Line With Text" for later repositioning.
'
' Auto 1: Text Centered, "Dim Line With Text" set for editing, Selected
' Same as Auto 0, but text is selected, and cursor is positioned over
' the text in Point Select mode, so that a simple mouse click
' will grab the text for repositioning.
'
' Auto 2: Text Moved to Cursor Position , "Dim Line With Text" set for editing, Selected
' Same as auto 1, but positions the text at the cursor position
' before ending with out regard to the extension lines and arrows.
' Again, text is moved from dim-line center to under the cursor,  ready to reposition in Point Select mode.
'
' This macro overcomes the nastiest of the bugs which occur when
' trying to draw dimensions using "dim line with text" movement.
'       In particular, it avoids the "Leader" caused by DC's failed implementation of
' AC leaders with "Dim Line With Text" movement.
'
' It does not fix the "Point 4" bug, which is handled in other macros.
' Directions:
' Run the macro to start the dimension command.
' Set 2 points to be dimensioned.
' Set a third point for dimension line position.
' Afterward, if text needs to be repositioned,
' click while cursor is still over text.
'
' Esc or Click in open area to deselect.
'
''***************  User Parameter(s) ************************
auto=2  ' 0 = end with cented text, deselected
      ' 1 = end with cursor over centered text position.
      ' 2 = end with text under useer cursor position, .

Alias D_ENABLEFIXEDTEXTPOS &H0A18
Alias ENT_POINT  &H010E
Alias ENT_SELECTED  &H010C 
Alias D_TEXTMOVEMENT &H0A21

ne0=sys(9)  ' archive number of entities

>Dimension
{
<DimVerticalTextPos 0        'Draw with centered vert text position
<DimHorizontalTextPos 0 'Draw with centered Horz text position
<TextMovement 0    'Draw with "dim line with text" movement
<incomplete 
}

Getxy x1, y1, z1 ' get cursor position

ne=sys(9)   ' get number of entities

if ne>ne0 then   ' is there a new entity?
getattr ne,type
if type=75 then
entity ne
change D_ENABLEFIXEDTEXTPOS,0 'unlock fixed text position
update
if auto>0 then
change ENT_SELECTED, 1
update     
endif
if auto=1 then gosub redim 
if auto=2 then gosub automove
    if auto>0 then     'suggest making unconditional
          >PointSelectMode 
      {
      }
          if NOT sys(345) then
      >PointSelectMode   'run twice to assure redraw
      {
      }
      endif
    endif
                change D_TEXTMOVEMENT, 0   'Change to "dim line with text" movement
update
endif
 
endif

end
'''' ---------------------------------------------------------------
redim:
entity ne
      query ENT_POINT, 5, TxtX, TxtY, TxtZ  'get text position
update
>MoveCursor   ' move cursor to text position
{
<Pointxyz [TxtX, TxtY, TxtZ]
}

return

automove: 'automatically move text to last cursor position
entity ne
      change ENT_POINT, 5, x1, y1, z1   'move text to cursor position
update
return