I have two cylinder macros that work similarly, but require a diameter. One also creates a centerline.

PRL: Sorry, I should have given attribution, but I had forgotten where these came from. I had written similar DOS macros myself, many, many years ago.

cyl2.d3m:

`'Creates cylinder along line`

'Program: cyl2.d3m (Cylinder along line)

precision 15

dx1$=sys$(0)

if dx1$ <> "" then goto skip

' Get User Input

dx1$=sys$(0)

if dx1$ = "" then input "Enter cylinder radius: ", dx1$

skip:

dx=val(dx1$)

input "Enter the number of cylinder facets: ", facet$

facet=val(facet$)

if sys(1) <> 2 then

sys(1)=0

setpoint "Point 1 for cylinder origin, point 2 for cylinder length " 2

endif

'sys(36)=1

pointval x1, y1, z1, 1

pointval x2, y2, z2, 2

sys(1)=0

>line

{

<pointxyz [x1, y1, z1]

<pointxyz [x2, y2, z2]

}

w = 2*dx

>PerpendicularPlane

{

<Width [w]

<pointxyz [x1, y1, z1]

<pointxyz [x1, y1, z1]

}

Entity Sys(9) ' Get the points for the square plane just drawn.

' only need the last two points

tp=sys(1)

tpm1=tp-1

Pointval x3, y3, z3, tpm1

Pointval x4, y4, z4, tp

sys(1)=0

'compute radius point location using two edges of plane

xr=(x4-x3)/2.0 + x3

yr=(y4-y3)/2.0 + y3

zr=(z4-z3)/2.0 + z3

>EraseLast 'remove the perpendicular plane

{

}

>Cylinder

{

<Orientation 0

<Nface [facet]

<pointxyz [x1, y1, z1]

<pointxyz [xr, yr, zr]

<pointxyz [x2, y2, z2]

}

End

and cyl3.d3m

`'DesignCad 3D v14 Macro: cyl3.d3m`

'

'This command takes two points specified for the cylinder's endcaps, 'and a specified radius to set 3 points: 1st point is one endcap,

'2nd point is for radius (and plane of endcap and orientation,)

'third specifies far endcap (and length.)

'

'This macro uses some basic linear algebra

PRECISION 8

DIM X(3), Y(3), Z(3)

user:

SetPoint "Set two points: one for each endcap" 2

If Sys(1)<2 then goto user

FOR I = 1 TO 2

PointVal X(I) Y(I) Z(I) I

NEXT I

'Reset points:

SYS(1)=0

INPUT "Now enter the cylinder's desired radius in drawing units: ",R

'First we must find an "R" orthogonal to P1 and P2 by using

'the vector cross product of P1 and P2: P1 x P2

RX = Y(1)*Z(2)-Y(2)*Z(1)

RY = X(2)*Z(1)-X(1)*Z(2)

RZ = X(1)*Z(2)-X(2)*Y(1)

MAGR = SQRT(RX*RX+RY*RY+RZ*RZ) 'Find the magnitude of "R"

'Now go find a unit vector "RHAT"

RHATX = RX/MAGR

RHATY = RY/MAGR

RHATZ = RZ/MAGR

'Now go find the location of third point relative to first point.

'This is found by multiplying the scalar (radius) R with RHAT:

X(3) = X(1) + R*RHATX

Y(3) = Y(1) + R*RHATY

Z(3) = Z(1) + R*RHATZ

'Now clear any set points:

SYS(1)=0

'Now set 1st point 1st for first end, 2nd point for radius,

'then last point for second end and then draw a cylinder

>Cylinder

{

<Pointxyz [X(1),Y(1),Z(1)]

<Pointxyz [X(3),Y(3),Z(3)]

<Pointxyz [X(2),Y(2),Z(2)]

}

END