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

  •  The code places an XYZ reference symbol in your drawing. The user can add as many as they want where they want. Keep them or delete them as you draft. They are grouped and placed on layer 999 for easy click/ deletion or layer deletion say via macro or layer dialog.

     written by prl
'Program: xyzHere.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 xyz symbol 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

sp1 = sys(9)+1
>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"
}

for j = sp1 to sys(9)
getattr j, type, select
putattr j, type, 1
next j
>groupdefine
{
}

gosub restore



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:

xyzhere.zip