Macro to Orbit a Drawing around a Set Point with a visible XYZ Triad

  •  This routine is meant to augment or substitute for the "Y" dynamic rotation key. The first point will locate the view center (orbit center), the second point will draw a rubberband box which will size the xyz symbol, it then puts you in the rotation mode. The xyz symbol should go away when the routine is finished but if not, delete the items on 999.
  •  Note: Renamed to Orbit_with_triad.d3m for clarity  /Steve

     written by prl
'Program: Orbit_with_triad.d3m

sf = .25 'scale factor for arrow and text size. Fiddle with this to your liking

'save various settings
cl = sys(3) 'current layer
cred = sys(300) 'current red value
cgrn = sys(301) 'current green value
cbl = sys(302) 'current blue
cctf = sys(254) 'current color text flag
ccfl = sys(255) 'current color layer flag
pspm = sys(1116) 'preset point mode'

sys(1116)=0 'preset point mode off for sphere rubberband
sys(41) = 18 'sphere rubberband
sys(36)=0

SetPoint "Set 1st point for view center, 2nd point for xyz symbol size", 2
pointval x,y,z, 1 'store first point only

sys(36)=1 'hide the dialogs
>sphere
{
<Latitude 5
<Longitude 5
<Orientation 0
<UsePresetPoints
}

entity sys(9) 'get coordinates of sphere just drawn
pointval cx,cy,cz, 1
pointval ex2,ey2,ez2, 3
sys(1)=0

dx = ex2 - cx
dy = ey2 - cy
dz = ez2 - cz
d = dx * dx + dy * dy + dz * dz

if d = 0 then goto restore
d = sqrt(d)
sys(12) = sf*d

>eraselast
{
}

sys(3)=999 'switch to empty/junk layer, say 999'
sys(254) = 1 'turn on
sys(255) = 1 'turn on

>arrow
{
<Color [sys(334), sys(335), sys(336)]
<Type 4
<Size [1]
<pointxyz [x,y,z]
<pointxyz [x+d,y,z]
<Doublesided 0
}

>Text2d
{
<Color [sys(334), sys(335), sys(336)]
<pointxyz [x+d,y,z]
<Style 0
<Justification 0
<Angle 0
<Text "x"
}

>arrow
{
<Color [sys(337), sys(338), sys(339)]
<Type 4
<Size [1]
<pointxyz [x,y,z]
<pointxyz [x,y+d,z]
<Doublesided 0
}

>Text2d
{
<Color [sys(337), sys(338), sys(339)]
<pointxyz [x,y+d,z]
<Style 0
<Justification 0
<Angle 0
<Text "y"
}

>arrow
{
<Color [sys(340), sys(341), sys(342)]
<Type 4
<Size [1]
<pointxyz [x,y,z]
<pointxyz [x,y,z+d]
<Doublesided 0
}

>Text2d
{
<Color [sys(340), sys(341), sys(342)]
<pointxyz [x,y,z+d]
<Style 0
<Justification 0
<Angle 0
<Text "z"
}

gosub restore

>SetViewerPoints
{
<pointxyz [x,y,z]
}

>setview
{
}

for i = 1 to 6
>eraselast
{
}
next i

regen
end

'subroutines follow

restore: 'restore settings
sys(36)=0
sys(80) = 0
sys(3)= cl
sys(1116)=pspm
sys(300)=cred
sys(301)=cgrn
sys(302)=cbl
sys(254)=cctf
sys(255)=cclf
return
 

File to Download:

orbit_with_triad.zip