Macro to Draw a Slot with Round Ends

  •  The code draws a slot with round ends.

     written by Impulse
'SLOT.D3M
'prompts for a width which is the "diameter" of the end semicircs
'then prompts for a length
'after drawing, macro waits for a kepress to continue...
'if user presses "S" key then the slot will be
'grouped and a a handle set in the center

onepnt:
Input "Enter slot width (diameter)" , dia
if dia = 0 then goto onepnt
Lenin:
Input "Enter Length", Lgth
If Lgth = 0 then goto lenin
if Lgth < DIA then goto lenin

segment = Lgth - dia 'get length of line attaching semis
rad = dia/2

setpoint "Set a point representing the center " 1
pointval CX, CY ,CZ,1
sys(1) = 0


>line
{
<PointXYZ [cx+rad,cy+segment/2 ,CZ]
<PointXYZ [cx+rad,cy-segment/2 ,CZ]
}
>line
{
<PointXYZ [cx-rad,cy-segment/2 ,CZ]
<PointXYZ [cx-rad,cy+segment/2 ,CZ]
}

>semicircle
{
<Type 0
<PointXYZ [cx-rad,cy-segment/2 ,CZ]
<PointXYZ [cx+rad,cy-segment/2 ,CZ]

}
>semicircle
{
<Type 0
<PointXYZ [cx+rad,cy+segment/2 ,CZ]
<PointXYZ [cx-rad,cy+segment/2 ,CZ]
}
print "Hit 'S' to Select the slot"
Anykey kyht$
if Kyht$ = "S" or Kyht$ = "s" then goto groupit
end

groupit:
sys(34) = 0
cnt = sys(9)
strt = cnt - 3 'use "5" to select last 4 entities

for j = strt to cnt
getattr j, a,b
putattr j, a,1
next

>sethandle
{
<PointXYZ [cx,cy,CZ]
<PointXYZ [cx,cy-segment/2,CZ]
}
 

File to Download:

slot.zip