Author Topic: sm.d3m and scp.d3m (selection move or selection copy by dx, dy, dz offsets)  (Read 561 times)

prl

  • Hero Member
  • *****
  • Posts: 3389
  • A Bézier Extrusion
keywords: prl=KWsm.d3m  =KWoffset

Say you want to move a selection 20 mm to the right, or up, down, in, out etc., how to do it with a fix distance input?


For the posed question, I would select the spring and then type sm 20 on the command line.  Or if you wanted to move it in the z direction, sm 0 0 20.

The routine puts you in a repeated move loop so if you hit the space bar, you will "walk" the selection.  Press enter when you are at your destination.  I use this routine to nudge things left, right, up, down, in, out by fixed distances. 

Code: [Select]
'Program: sm.d3m (selection move by dx dy dz offsets)

if sys(80)=0 then
  Message "Nothing selected to move. . . routine will end"
  END
end if

dx$ = "0"
dy$ = "0"
dz$ = "0"

fmt$ = "%s %s %s"

b$ = sys$(0)
if b$ = "" then
input "Enter dx dy dz offset.    Examples : 0 0 4 or 0 7.25 or 1.25'  (Note trailing zeros can be omitted)", b$
endif

if b$="" then END

Parse b$, fmt$, dx$, dy$, dz$

precision 15
dx = val(dx$)
dy = val(dy$)
dz = val(dz$)

for j = 1 to 200
  sys(36) = 1 'stop annoying flicker
  >Move
  {
  <type 1
  <reference 1
  <Pointxyz 0.0000000000000000,0.0000000000000000,0.0000000000000000
  <Pointrel [dx,dy,dz]
  }
  regen
  sys(36) = 0
  PRINT "Press space bar for additional moves, enter to end"
     anykey A
     if A=13 then
       >Move
       {
       <type 1
       <reference 0
       <null
       }
       sys(80)=0
       end
     endif
next j

End

Edit:  added scp.d3m, a theme variation using the duplicate command rather than move.  Same command line concept.   scp 0 0 30 will copy (duplicate) the selection in the z direction at 30 unit increments until you hit enter.  Good for laying out out things that repeat;  pickets, posts,  joists, rafters, etc.

Code: [Select]
'Program: scp.d3m (selection copy (duplicate) by dx dy dz offsets)

if sys(80)=0 then
  Message "Nothing selected to move. . . routine will end"
  END
end if

dx$ = "0"
dy$ = "0"
dz$ = "0"

fmt$ = "%s %s %s"

b$ = sys$(0)
if b$ = "" then
input "Enter dx dy dz offset.    Examples : 0 0 4 or 0 7.25 or 1.25'  (Note trailing zeros can be omitted)", b$
endif

if b$="" then END

Parse b$, fmt$, dx$, dy$, dz$

precision 15
dx = val(dx$)
dy = val(dy$)
dz = val(dz$)

 >SetHandle
      {
      <Type 0 
      <Pointxyz 0.00000000000000,0.00000000000000,0.00000000000000
      }

for j = 1 to 200
  sys(36) = 1 'stop annoying flicker
  >Duplicate
  {
  <type 1
  <reference 1
  <Pointxyz [j*dx,j*dy,j*dz]
  }
  regen
  sys(36) = 0
  PRINT "Press space bar for additional moves, enter to end"
     anykey A
     if A=13 then
       >Duplicate
       {
       <type 1
       <reference 0
       <null
       }
       sys(80)=0
       end
     endif
next j

End

For hippies and groovy movie people.

A movie - Moving an object (or selection set) using dx, dy, dz offsets using SM.D3M macro

A movie - Copying (duplicate) an object (or selection set) using dx, dy, dz offsets using SCP.D3M macro

(Reminder: In the movies, you can left click in the movie area to start/stop the action.  And the slider to rewind.)
« Last Edit: February 16, 2015, 01:07:57 AM by prl »

samdavo

  • Hero Member
  • *****
  • Posts: 2587
  • the trick is knowin...^ > v < - which way's up?
prl
your scp.d3m reminds me of a two-directional array, where you can decide how many repetitions while you are adding them :)   - top stuff