The DesignModeler API Primitives provides you with the
ability to create different types of primitive bodies: sheet bodies, wire bodies,
and solid bodies. For each primitive body type, multiple shape options are
available.
The primitives variable
ExtAPI.DataModel.GeometryBuilder.Primitives is the
gateway for designing a new geometric body. The code must be integrated into the
callback <ongenerate>.
The script function ongenerate() can be used to create a
primitive body. The API provides a variety of queries that allow you to specify
properties such as body type, dimensions, shape, point coordinates, and material.
When creating a sheet body, you have the option of defining it in the shape of
a cone, cylinder, polygon, or sphere. An example follows of using the function
ongenerate() to define a sheet body cylinder.
def Ongenerate(feature,function):
width = 0.015
height = 0.3
sheetBodies = []
primitive = ExtAPI.DataModel.GeometryBuilder.Primitives
cylinder = primitive.Sheet.CreateCylinder([0.,0.,0.],[0.,0.,height],width)
cylinder_generated = cylinder.Generate()
sheetBodies.Add(cylinder_generated)
feature.Bodies = sheetBodies
feature.MaterialType = MaterialTypeEnum.Freeze
return TrueIn this example:
The variables width and
height are used to define the width and the
height of the cylinder.
The variable sheetBodies specifies the type of
primitive to be created.
The primitive variable uses the global variable
ExtAPI to access the data model and define
the geometry builder, which serves as entry point for ACT into
DesignModeler.
The method CreateCylinder () is used to
generate the new body, specifying that it is defined by the following arguments:
Coordinates of the center point of the cylinder’s base
Coordinates of the center point of the upper face (which defines the direction of the cylinder)
Value of the radius
(This is a float. The integer value << 3 >>, for instance, is refused, while a value of << 3. >> is accepted.)
With the object cylinder_generated, you use the
method Generate () to generate the
cylinder.
With the lines
sheetBodies.Add(cylinder_generated) and
feature.Bodies = sheetBodies, you add the
sheet body cylinder to the list feature.bodies so
that it is added to DesignModeler after generation. Bodies not added to
this list are not retained.
With the line MaterialType, you specify a
material property of Freeze.
When creating a wire body, you have the option of defining it in the shape of
an arc, curve, ellipse, or polyline. An example follows of using the function
ongenerate() to define a wire body polyline.
def Ongenerate(feature,function):
points_list = [0.,0.,0., 1.,0.,0., 1.,1.,0., 1.,1.,1.]
wireBodies = []
primitive = ExtAPI.DataModel.GeometryBuilder.Primitives
polyline = primitive.Wire.CreatePolyline(points_list)
polyline_generated = polyline.Generate()
wireBodies.Add(polyline_generated)
feature.Bodies = wireBodies
feature.MaterialType = MaterialTypeEnum.Add
return TrueIn this example:
The method points_list () is defined for later
use in the creation of the polyline body. For arguments, it expects as a
list of coordinate points (defined by three float values per
point).
The primitive variable uses the global variable
ExtAPI to access the data model and define
the geometry builder, which serves as entry point for ACT into
DesignModeler.
The method CreatePolyline () is applied to the
object Wire to generate the new body. As
arguments, this method is expecting the coordinate points defined by the
method points_list.
With the object polyline_generated, you use the
method Generate () to generate the
polyline.
The new body is added to the list
feature.bodies as described in Creating a Sheet Body.
With the line MaterialType, you specify a
material property of Add.
When creating a solid body, you have the option of defining it in the shape of
a box, cone, cylinder, or sphere. The following example uses the function
ongenerate() to define a solid body box.
def Ongenerate(feature,function):
point1 = [0.,0.,0.]
point2 = [1.,2.,2.]
solidBodies = []
primitive = ExtAPI.DataModel.GeometryBuilder.Primitives
box1 = primitive.Solid.CreateBox(point1, point2)
box1_generated = box1.Generate()
solidBodies.Add(box1_generated)
feature.Bodies = solidBodies
feature.MaterialType = MaterialTypeEnum.Freeze
return TrueIn this example:
The methods point1 () and point2
() are defined for later use in the creation of the
solid body. For arguments, they each expect as a list of coordinate
points (defined by three float values per point).
The primitive variable uses the global variable
ExtAPI to access the data model and define
the geometry builder, which serves as entry point for ACT into
DesignModeler.
The method CreateBox () is applied to the
object Solid to generate the new body. For
arguments, this method is expecting the coordinate points defined by the
methods point1 and point2.
With the object box1_generated, you use the
method Generate () to generate the box.
The new body is added to the list
feature.bodies lias described in Creating a Sheet Body.
With the line MaterialType, you specify a
material property of Freeze.