Truncated Cone Builder

This knowledge base article demonstrates a script that will create a truncated cone subassembly consisting of two end planes and a tapered cylinder.  The cone is specified by the two end surface radii and the axial height of the truncated cone.  In this implementation r1 > r2, where r1 is the base radius and r2 is the top radius.  The script implements the following steps:

  1. User specifies r1, r2 and h
  2. Check that r1 > r2, print message or proceed with construction
  3. Create the subassembly to hold all of the cone geometry
  4. Create the large aperture base surface using an element primitive plane
  5. Create the small aperture top surface using an element primitive plane and move to proper z-position
  6. Create the tapered cylinder wall to close the cone volume
  7. Update the document to reflect the changes

The full script is provided below:

Sub Main

Dim ent As T_ENTITY
Dim op As T_OPERATION
Dim tb As T_TUBE
Dim subNode As Long, ceNode As Long, surfNode As Long
Dim r1 As Double, r2 As Double, h As Double

‘USER SPECIFICATIONS
‘r1 = radius of the large aperture base surface
‘r2 = radius of the small aperture base surface
‘h = height of the cone along the axis
r1 = 4
r2 = 3
h = 11

‘check that r2 < r1
If r2 > r1 Then
Print “Check radii specifications.  R2 should be less than R1.”
GoTo errCatch
End If

‘create subassembly for truncated cone
InitEntity ent
ent.name = “TruncatedCone”
ent.parent = 2
subNode = AddSubassembly( ent )

‘create large aperture base surface
ent.name = “LargeApertureBase”
ent.parent = subNode
surfNode = ElemAddPlane( ent )
ElemSetParmValue surfNode, 0, r1
ElemSetParmValue surfNode, 1, r1
ElemSetParmValue surfNode, 2, 1
ElemSetParmValue surfNode, 3, 0
ElemSetParmValue surfNode, 4, 0

‘create small aperture surface and position along axis
ent.name = “SmallApertureBase”
ent.parent = subNode
surfNode = ElemAddPlane( ent )
ElemSetParmValue surfNode, 0, r2
ElemSetParmValue surfNode, 1, r2
ElemSetParmValue surfNode, 2, 1
ElemSetParmValue surfNode, 3, 0
ElemSetParmValue surfNode, 4, 0
op.parent = subNode
op.Type = “Shiftz”
op.val1 = h
AddOperation surfNode, op

‘create outer wall cylinder surf
ent.name = “OuterCylinderWall”
ent.parent = subNode
ceNode = AddCustomElement( ent )
InitTube tb
tb.x1SemiApe = r1
tb.x2SemiApe = r2
tb.y1SemiApe = r1
tb.y2SemiApe = r2
tb.z1SemiApe = 0
tb.z2SemiApe = h
ent.name = “Surf 1”
ent.parent = ceNode
surfNode = AddTube( ent, tb )
SetTrimVol surfNode, r1+0.01, r1 + 0.01, h/2, 0, 0, h/2, “Cylinder”

‘update the document
Update

‘jump here if r2 > r1 in the user specifications
errCatch:

End Sub

Download the FRED script: createTruncatedCone.frs

Download the FRED file: truncatedConeBuilder.frd