When using the operation Extrude
, you must first create the
geometry to which the extrusion is to be applied. You can create any of the sheet
primitive shapes listed in Creating Primitives. Once
the geometry is created, you can define and apply the operation
Extrude
to it.
In the following example, the function ongenerate()
is used
to create a polygon sheet body and perform the operation
Extrude
.
def Ongenerate(feature,function): length = 0.3 bodies = [] builder = ExtAPI.DataModel.GeometryBuilder polygon=builder.Primitives.Sheet.CreatePolygon([0.,0.,3*length,0.,0.,2.*length,length,0.,2.*length]) polygon_generated = polygon.Generate() extrude = builder.Operations.CreateExtrudeOperation([0.,1.,0.],length/2.) bodies.Add(extrude.ApplyTo(polygon_generated)[0]) feature.Bodies = bodies feature.MaterialType = MaterialTypeEnum.Add return True
In this example:
The first part of the function creates a polygon sheet body using a process similar to the one used to create a cylinder in Creating a Sheet Body.
With the operation
Extrude
, you use the operations generatorbuilder.Operations.CreateExtrudeOperation
. The methodCreateExtrudeOperation
specifies that the operation is defined by the following arguments:Vector coordinates, which defines the direction of the extrusion
Length of the extrusion
Note: While the variable
Length
is used for both the sheet body and the extrusion definition in this example, you could have used a different variable for each.
The method
ApplyTo
specifies the geometry to which to apply the operationExtrude
. The methodApplyTo()
returns a list of bodies to which to apply the operation.With the lines
bodies.Add(extrude.ApplyTo(polygon_generated)[0])
andfeature.Bodies = bodies
, you add the extruded sheet body polygon to the listfeature.bodies
so that it is added to DesignModeler after generation. Bodies not added to this list are not retained.