DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

Adjust extension line gaps independently

Started by bdeck, October 27, 2007, 06:23:01 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

bdeck

'Gapset.d3m       bdeck  10/27/07
'
' Macro to adjust extension line gaps independently
'
' Select any @ style dimension (entity 75)
' Use cursor keys to set 2 extension line gaps independently
'     Use right/left cursor keys to select first or second extension line
'     Use up/down cursor keys to adjust gap
' Works in versions 14 - 17.2
'
' The regen at end of loop is optional
'
sys(470)=1  ' stop other commands
Dim xd(20),yd(20),zd(20)       'dim pts array

' *********************************** set constants ********'

Alias ENT_POINT               &H010E  'R/W - i,f,f,f

rt1=1   ' Root points
rt2=2
xL1a=3  'ExtLines
xL2a=5

k_spc=32
k_esc=27
k_cr=13
k_up=38
k_dn=40
k_rt=39
k_lft=37

' *********************************** initialize vars ********'
gonow=0
' **********************************************************'

ne=sys(80)                          ' look for selected entities
if ne <1 then end
if ne >1 then gosub toomany         ' if too many end 

getselect 1,entno
gosub dmsel




sys(1)=0    ' unset any points

rt=rt1     'root
xLa=xL1a   'ExtLine


Do While NOT gonow
     
    print "Use cursor keys to adjust extension line gaps."
   
    Anykey keycode 'check for the ESC key
     If keycode = k_cr Then gonow = 1
     If keycode = k_esc Then gonow = 1
        If keycode = 1 Then gonow = 1
        
   
     if keycode=k_lft then
        rt=rt1
        xLa=xL1a   'ExtLine
       
    endif
   
    if keycode=k_rt  then
        rt=rt2
        xLa=xL2a   'ExtLine
       
    endif
   
    if keycode=k_up or keycode=k_dn then gosub gapadjust
   

Loop

regen       'optional

end

gapadjust:                          '**************** adjust ext line gap

      gf=2^(1/3)
      if keycode= k_dn then gf=1/gf   
     
      i=rt
      gosub quent
     
      i=xLa
      gosub quent
     
      xd(xLa)=xd(rt)+gf*(xd(xLa)-xd(rt))     
      yd(xLa)=yd(rt)+gf*(yd(xLa)-yd(rt))         
      zd(xLa)=zd(rt)+gf*(zd(xLa)-zd(rt))
          
      i=xLa
      gosub chent
     
       sys(36)=1
 
      >Move
      {
           <Type 0
           <Reference 1
           <Pointxyz 0, 0, 0
           <Pointxyz 0, 0, 0
      }
         sys(36)=0     
      entity entno
      update
       
return

quent:
    entity entno
    query ENT_POINT,i,xd(i),yd(i),zd(i)
return

chent:
    entity entno
    change ENT_POINT,i,xd(i),yd(i),zd(i)
return

toomany:
      print "Select one dimension, or default to last drawn entity"
      message "Too Many Selected"
      end
return

dmsel:     
      GETATTR entno, type ,select, laynum, group, red, green, blue, solid
      if type <> 75 then ' if not a 75 dimension then end       
            Message "Selected Entity Not a Qualified Dimension"
            end
      end if     
   
return