How to implement SmartPart methods in Allplan Python API

2D Shapes

DRAWING ELEMENTS

LINE2 creates a line between two points.

Syntax

LINE2 x1, y1, x2, y2

NemAll_Python_Geometry.Line2D

Example:

·         GeometryExamples\GeometryElements.py -> create_line2d

RECT2 creates a rectangle based on two nodes located diagonally opposite each other.

Syntax

RECT2 x1, y1, x2, y2, frame_fill

NemAll_Python_Geometry.Polygon2D

Example:

·         GeometryExamples\GeometryElements.py -> create_polygon2d

POLY2 creates an open or closed polygon with n nodes.

Syntax

POLY2 n, frame_fill, x1, y1, ... xn, yn

NemAll_Python_Geometry.Polyline2D

Example:

·         GeometryExamples\GeometryElements.py -> create_polyline2d

ARC2 creates a circular arc based on center point, radius and central angle from alpha to beta.

Syntax

ARC2 x, y, r, alpha, beta

NemAll_Python_Geometry.Arc2D

Example:

·         GeometryExamples\GeometryElements.py -> create_arc2d

(Allplan 2016-1-1)

CIRCLE2 creates a full circle based on its center point and radius.

Syntax

CIRCLE2 x, y, r

Same as ARC2

SPLINE2 creates a spline based on n control points. Angles of tangents in spline control points must be stated.

Syntax

SPLINE2 n, status, x1, y1, angle1, ..., xn, yn, anglen

NemAll_Python_Geometry.Arc2D

Example:

·         GeometryExamples\GeometryElements.py -> create_spline2d

(Allplan 2016-1-1)

CURVE_B2 creates a Bezier curve with n control points in 2D.

Syntax

CURVE_B2 n, status,

x1, y1, t_next_x1, t_next_y1,

...

t_prev_xn, t_prev_yn,

xn, yn, t_next_xn, t_next_yn

Not yet implemented.

 

3D Shapes

BASIC SHAPES

BOX creates a rectangular solid.

Syntax

BOX a, b, c

NemAll_Python_Geometry.Polyhedron3D.CreateCuboid(point1, point2)

Create Polyhedron3D from 2 Point3D as min and max

Example:

·         GeometryExamples\GeometryElements.py -> create_polyhedron3d

CONE creates a cone or a frustum of a cone.

Syntax

CONE h, r1, r2, alpha1, alpha2

NemAll_Python_Geometry.Cone3D

Example:

§  GeometryExamples\GeometryElements.py -> create_cone3d

CYLIND creates a right cylinder centered in Z axis. The center of the circle is in the point of origin.

Syntax

CYLIND h, r

NemAll_Python_Geometry.Cylinder3D

Example:

§  GeometryExamples\GeometryElements.py -> create_cylinder3d

ELLIPS creates a half ellipsoid.

Syntax

ELLIPS h, r

NemAll_Python_Geometry.Ellipsoid3D

Example:

§  GeometryExamples\GeometryElements.py -> create_ellipsoid3d

SPHERE defines a ball.

Syntax

SPHERE r

NemAll_Python_Geometry.Ellipsoid3D

Example:

§  NemAll_Python_Geometry_UnitTests.TestEllipsoid3D.py

ARMC creates a cylinder originating from another cylinder. One end of the new cylinder is straight, the other end is smoothed to the cylinder it originates from.

Syntax

ARMC r1, r2, l, h, d, alpha

Same as CYLIND

Additionally use BoolOp NemAll_Python_Geometry.MakeSubtraction

Example:

§  GeometryExamples\BoolOp.py -> make_subtraction

ARME creates a right cylinder originating from an ellipsoid in the YZ plane. Its upper end is straight and parallel to the XY plane.

Syntax

ARME l, r1, r2, h, d

Same as CYLIND

Additionally use BoolOp NemAll_Python_Geometry.MakeSubtraction

Example:

§  GeometryExamples\BoolOp.py -> make_subtraction

ELBOW creates a segmented, elbow-shaped tube in the XZ plane.

Syntax

ELBOW r1, alpha, r2

Not yet implemented.

BODY_B creates a NURBS cube of Bezier type according to the passed list of control points.

Syntax

BODY_B m, n, subdiv_n, subdiv_m, rise,

x11, y11, ... z11,

x12, y12, ... z12,

...

x1m, y1m, ... z1m,

x21, y21, ... z21,

...

zn1, zn2, ... znm

Not yet implemented.

 

PRISM

PRISM creates a right prism. Its base polygon is in the XY plane.

Syntax
PRISM n, h, x1, y1, ... xn, yn

NemAll_Python_Geometry.CreatePolyhedron(base, refPoint, path)

Create Polyhedron3D from base Polygon2D, ref Point2D and path as Polyline3D

Example:

§  GeometryExamples\CreatePolyhedron1.py -> create_phed_by_pgon2d

PRISM_ creates a right prism. It is similar to PRISM. In addition, you can define holes and create segments and arcs in the polyline.

Syntax

PRISM_ n, h, x1, y1, s1, ... xn, yn, sn

NemAll_Python_Geometry.CreatePolyhedron(solid)

Create Polyhedron3D from ExtrudedAreaSolid3D

Example:

§  GeometryExamples\CreatePolyhedron2.py -> create_phed_from_extruded_area

PRISM_C is similar to PRISM_. In addition, you can define a material for its surfaces.

Syntax

PRISM_C top_material, bottom_material, side_material, n, h, x1, y1, s1, ... xn, yn, sn

Same as PRISM_ additionally with material definition

PRISM_B is similar to PRISM_C and creates a smooth curved prism.

Syntax

PRISM_B top_material, bottom_material, side_material,

n, h, radius, x1, y1, s1, ... xn, yn, sn

Not yet implemented.

PRISM_F is similar to PRISM_. In addition, you can chamfer or round out the upper edges of the prism and define the prism's overall thickness and the material, height and angle for the chamfered rsp. rounded part.

Syntax

PRISM_F top_material, bottom_material, side_material, hill_material,

n, thickness, angle, hill_height,

x1, y1, s1, ... xn, yn, sn

Same as PRISM_ additionally with material definition

Additionally use NemAll_Python_Geometry.ChamferCalculus.ChamferCalculus .Calculate(polyhedron, edges, width)

Example:

§  GeometryExamples\Chamfer.py

PRISM_H is similar to PRISM_F.

Same as PRISM_F

PRISM_S is similar to PRISM_C. In addition, you can define an upper polygon which is not parallel to the XY plane.

Syntax

PRISM_S top_material, bottom_material, side_material,

n,

xb, yb, xe, ye, h, angle,

x1, y1, s1, ..., xn, yn, sn

NemAll_Python_Geometry.CreatePolyhedron(solid)

Create Polyhedron3D from ClippedSweptSolid3D, top and bottom Plane3D

Example:

§  GeometryExamples\CreatePolyhedron2.py -> create_phed_by_swept_solid

PRISM_S2 is an extension of the PRISM_S command, with the possibility of having an upper and lower polygon non-parallel with the x-y plane.

The top and bottom of the prism is defined at the reference line.

Upper and lower polygon intersection is forbidden.

Same as PRISM_S

 

SOLIDS

SOLID_BEAM is similar to SOLID_WALL_X and creates a beam.

Syntax

SOLID_BEAM left_material, right_material, vertical_material, top_material, bottom_material,

height, x1, x2, x3, x4,

y1, y2, y3, y4, t,

mask1, mask2, mask3, mask4

Same as SOLID_WALL_

SOLID_SLAB creates a polygonal prism; it is similar to PRISM. The side faces are perpendicular to XY plane. The bottom and top face can be inclined to XY plane.

Syntax

SOLID_SLAB n, h, x1, y1, z1, ... xn, yn, zn

Same as PRISM

SOLID_WALL_ creates perpendicular walls with materials and openings.

Syntax

SOLID_WALL_ left_material, right_material, side_material,

height, x1, x2, x3, x4, t,

mask1, mask2, mask3, mask4,

n,

x_start1, y_low1, x_end1, y_high1, frame_shown1,

...

x_startn, y_lown, x_endn, y_highn, frame_shownn,

m,

a1, b1, c1, d1,

...

am, bm, cm, dm

NemAll_Python_Geometry.Polyhedron3D additionally with material definition

Example:

§  GeometryExamples\CreatePolyhedron1.py

 

MESH

MESH generates a mesh based on a grid with an equidistant grid-length within a rectangular contour with user defined length of the rectangle sides.

Syntax

MESH a, b, m, n, mask, z11, z12, ... , z1m, z21, z22, ... , z2m, zn1, zn2, ... , znm

Not yet implemented.

MESH_B generates a mesh which approximates the Bezier surface defined by the specified control points. The surface evaluation may happen in two different modes, static mode and adaptive mode. Adaptive mode is being chosen, if subdiv_n or subdiv_m is less than or equal to 2. Otherwise, the static mode will be chosen and parameter value rise will be ignored.

Syntax

MESH_B m, n, subdiv_n, subdiv_m, rise, x11, y11, z11, x12, y12, z12, ... , x1m, y1m, z1m, x21, y21, z21, x22, y22, z22, ... , x2m, y2m, z2m, ... , xn1, yn1, zn1, xn2, yn2, zn2, ... , xnm, ynm, znm

Not yet implemented.

MESH_B_ generates a mesh which approximates the Bezier body defined by the specified control points. The surface evaluation may happen in two different modes, static mode and adaptive mode. Adaptive mode is being chosen, if subdiv_n or subdiv_m is less than or equal to 2. Otherwise, the static mode will be chosen and parameter value rise will be ignored.

Syntax

MESH_B_ m, n, subdiv_n, subdiv_m, mask, x11, y11, z11, x12, y12, z12, ... , x1m, y1m, z1m, x21, y21, z21, x22, y22, z22, ... , x2m, y2m, z2m, ... , xn1, yn1, zn1, xn2, yn2, zn2, ... , xnm, ynm, znm

Not yet implemented.

MESH_C generates a coon's patch defined by four boundary curves forming a chain.

Syntax

MESH_C n, m, x11, y11, z11, ... , x1n, y1n, z1n, x21, y21, z21, ... , x2n, y2n, z2n, x31, y31, z31, ... , x3m, y3m, z3m, x41, y41, z41, ... x4m, y4m, z4m

Not yet implemented.

MESH_P generates a free-form surface based on a coon's patch with a plinth; materials can be defined for the top-, bottom- and side surfaces.

Syntax

MESH_P top_material, bottom_material, side_material, n, m, mask, h, x1, y1, z1, s1, ... , xn, yn, zn, sn, xn+1, yn+1, zn+1, sn+1, ... , xn+m, yn+m, zn+m, sn+m

Not yet implemented.

MESH_P_ generates a free-form surface with a plinth; materials can be defined for the top-, bottom- and side surfaces.

Syntax

MESH_P top_material, bottom_material, side_material, n, m, mask, h, x1, y1, z1, s1, ... , xn, yn, zn, sn, xn+1, yn+1, zn+1, sn+1, ... , xn+m, yn+m, zn+m, sn+m

Not yet implemented.

 

PLANAR SHAPES

LINE generates a line in the three-dimensional space between the two points P1 (x1,y1,z1) and P2 (x2,y2,z2).

Syntax

LINE x1, y1, z1, x2, y2, z2

NemAll_Python_Geometry.Line3D

Example:

·         GeometryExamples\GeometryElements.py -> create_line3d

RECT generates a rectangle in the XY plane with its first edge placed in the origin of the coordinate system.

Syntax

RECT a, b

NemAll_Python_Geometry.Polygon3D

Example:

·         GeometryExamples\GeometryElements.py -> create_polygon3d

POLY generates a polyline in the XY plane.

Syntax

POLY n, x1, y1, ..., xn, yn

NemAll_Python_Geometry.Polyline3D

Example:

·         GeometryExamples\GeometryElements.py -> create_polyline3d

CIRCLE generates a full circle in the XY plane with its center situated in the origin of the coordinate system; it is defined solely by its radius.

Syntax

CIRCLE r

Same as ARC

ARC generates a circular arc in the XY plane with its center situated in the coordinate system's origin; it is defined by its radius and a central angle from alpha to beta.

Syntax

ARC r, alpha, beta

NemAll_Python_Geometry.Arc3D

Example:

·         GeometryExamples\GeometryElements.py -> create_arc3d

(Allplan 2016-1-1)

CURVE_B creates a Bezier curve with n control points in 3D.

Syntax

CURVE_B n, status,

x1, y1, z1, t_next_x1, t_next_y1, t_next_z1,

...

t_prev_xn, t_prev_yn, t_prev_zn,

xn, yn, zn, t_next_xn, t_next_yn, t_next_zn

Not yet implemented.

POLYPLANE generates a polyline within an arbitrary plane.

The polygon must be planar in order to get a correct result, but the interpreter does not check this condition.

Syntax

POLYPLANE n, x1, y1, z1, ... , xn, yn, zn

Same as POLY

Check with NemAll_Python_Geometry.Polyline3D.IsPlanar method

 

SHAPES FROM POLYLINE

EXTRUDE generates a general prism with its base defined by a polyline in the XY plane; the displacement vector between the bases is (dx, dy, dz). This command is a generalization of the commands PRISM and SOLID_SLAB; the base polyline is not necessarily closed, as the lateral edges are not always perpendicular to the XY plane. Arcs and segments can be defined within the polyline by using additional status code values.

Tipp: The base polyline may include holes, just like PRISM_.

Syntax

EXTRUDE n, dx, dy, dz, mask, x1, y1, s1, ... , xn, yn, sn

Same as PRISM

FRAME generates a frame with its outer polygon in the XY plane.

The width is perpendicular to the segments. The height along the Z axis is abs(h); negative h values can also be used.

Syntax

FRAME n, w , h , x1, y1, ... xn, yn

Not directly possible. Use NemAll_Python_Geometry.CreatePolyhedron and NemAll_Python_Geometry. MakeSubtraction

PYRAMID generates a pyramid with its base defined by a polyline in the XY plane; its peak is situated in P (0,0,h). Arcs and segments can be defined within the polyline by using additional status code values.

Syntax

PYRAMID n, h, mask, x1, y1, s1, ..., xn, yn, sn

Not yet implemented. Use NemAll_Python_Geometry.CreatePolyhedron(baseOutline, leftOffset, rightOffset, frontOffset, backOffset, bottomPlane, topPlane) to create a frustum of pyramid.

Or use NemAll_Python_Geometry.CreatePolyhedron.CreateFrustumOfPyramid

Example:

·         GeometryExamples\CreatePolyhedron1.py -> create_phed_by_plane_offset

REVOLVE generates a surface of revolution, which is described by a polyline defined in the XY plane rotating about the X axis. Arcs and segments can be defined within the polyline by using additional status code values.

Syntax

REVOLVE n, alpha, mask, x1, y1, s1, ... , xn, yn, sn

Not yet implemented.

RULED generates a curved surface between a planar and a spatial polyline, both with identical numbers of nodes; the corresponding edges are connected by plane surfaces (each either a planar quadrangle or two triangles). RULED is together with RULED_2 the only SmartPart which allows the overlapping of adjacent nodes.

Syntax

RULED n, mask, u1, v1, s1, ... , un, vn, sn, x1, y1, z1, ... , xn, yn, zn

Not yet implemented.

SWEEP generates a tubular surface by displacement of a polylined contour along a spatial polyline (= path curve); in order to get a twisted tube with a tapering or dilating cross-section, the polylined contour may be scaled and/or rotated during displacement. The plane of the polylined contour follows the spatial polyline determining the path: at node (xi, yi, zi) the corresponding plane is perpendicular to the spatial polyline segment between the nodes (xi-1, yi-1, zi-1) and (xi, yi, zi).

The path determining polyline must have its beginning in the XY plane. If this condition is not fulfilled, the polyline will be moved along the Z axis automatically, until the condition is fulfilled.

Syntax

SWEEP n, m, alpha, scale, mask, u1, v1, s1, ... , un, vn, sn, x1, y1, z1, ... ,xm, ym, zm

Not yet implemented.

TUBE generates a tubular surface by displacement of a closed polylined contour along a spatial polyline (= path curve). In each joint of the path curve the polylined contour is situated in the bisector plane of the joint segments. At the middle of the path segments the polylined contour is always identical with the polylined contour at the beginning of the displacement (the coordinates u1, w1, ... , un, wn remain unchanged). Arcs and segments can be defined within the polyline by using additional status code values. (See Remarks section for details.)

Syntax

TUBE n, m, mask, u1, w1, s1, ... , un, wn, sn, x1, y1, z1, angle1, ... , xm, ym, zm, anglem

NemAll_Python_Geometry.CreatePolyhedron(base, path)

Create Polyhedron3D from base Polygon3D and path as Polyline3D

Example:

·         GeometryExamples\CreatePolyhedron1.py -> create_phed_by_pgon3d

 

Cutting

CUTPLANE

CUTPLANE creates a cutting plane in 3-dimensional space. All 3D elements in its area are cut, the cut parts are removed. A different number of parameters is possible. CUTPLANE must be finished with CUTEND.

Syntax

CUTPLANE [x, y, z [, side]]

[statement1 ... statementn]

CUTEND

or

CUTPLANE angle

[statement1 ... statementn]

CUTEND

Not directly possible.

Use BoolOp NemAll_Python_Geometry.MakeSubtraction

Example:

§  GeometryExamples\BoolOp.py -> make_subtraction

CUTPLANE_2 is similar to CUTPLANE. In addition, you can define a status parameter for the cutting edges and faces, when the angle parameter is used.

Syntax

CUTPLANE_2 angle [, status] [...]

CUTEND

Same as CUTPLANE

CUTPLANE_3 is similar to CUTPLANE and creates a cutting plane in 3-dimensional space. All 3D elements in its area are cut, the cut parts are removed. A different number of parameters is possible. CUTPLANE_3 must be finished with CUTEND.

Syntax

CUTPLANE_3 [x [, y,[ z [, side [, status]]]]]

[statement1 ... statementn]

CUTEND

or

CUTPLANE angle

[statement1 ... statementn]

CUTEND

Same as CUTPLANE

 

CUTPOLY

CUTPOLY is similar to CUTPLANE and defines a cutting polygon. All elements within an infinite "tube" above and under the cutting polygon are cut. The CUTPOLY parameters refer to the current coordinate system.

Syntax

CUTPOLY n,

x1, y1, ... xn, yn [, x, y, z]

CUTEND

Use BoolOp NemAll_Python_Geometry.MakeSubtraction

Example:

§  GeometryExamples\BoolOp.py -> make_subtraction

CUTPOLYA is similar to CUTPOLY and creates a cutting tube, too. The tube needs not to be infinite, it can be closed on one side.

Syntax

CUTPOLYA n, status, d,

x1, y1, mask1, ... xn, yn, maskn

[, x, y, z]

[statement1 statement2 ... statementn]

CUTEND

Same as CUTPOLY

 

OTHER

CUTSHAPE defines a cutting shape and is similar to CUTPLANE.

Syntax

CUTSHAPE d

[statement1 statement2 ... statementn]

CUTEND

Same as CUTPOLY

CUTFORM is similar to CUTPOLYA. In addition, you can define form and extent of the cutting body.

Syntax

CUTFORM n, method, status,

rx, ry, rz, d,

x1, y1, mask1, ... xn, yn, maskn

CUTEND

Same as CUTPOLY

 

Text

2D / 3D

TEXT2 creates text in a defined style at a defined starting point.

Syntax

TEXT2 x, y, expression

Not yet implemented.

TEXT is similar to TEXT2 and creates 3-dimensional texts in the set style. Texts start from the local origin.

Syntax

TEXT d, flag, expression

Not yet implemented.

 

Transformation

TRANS

TRANS2 moves the local coordinate system along the X and Y axis.

Syntax

TRANS2 x, y

NemAll_Python_Geometry.Move

The service moves the geometry elements directly. It is not necessary to define or move a local coordinate system.

Examples:

·         NemAll_Python_Geometry_UnitTests\TestServiceMove.py

TRANS moves the local coordinate system along the X, Y and Z axis.

Syntax

TRANS x, y, z

Same as TRANS2

 

ROT

ROT2 rotates the local coordinate system around the point of origin. Only for 2D script.

Syntax

ROT2 alpha

NemAll_Python_Geometry.Rotate

The service rotates the geometry elements directly. It is not necessary to define or rotate a local coordinate system.

Examples:

·         NemAll_Python_Geometry_UnitTests\TestServiceRotate.py

ROT rotates the local coordinate system around a vector, which is specified as a line from point 0,0,0 to point X,Y,Z.

Syntax

ROT x, y, z, alpha

Same as ROT2

 

SCALE

SCALE2 scales the local coordinate system.

Syntax

SCALE2 x, y

Not directly possible. Use NemAll_Python_Geometry.Transform with Scaling Matrix

NemAll_Python_Geometry.Matrix2D. SetScaling(scaleX, scaleY)

The service scales the geometry elements directly. It is not necessary to define or scale a local coordinate system.

Examples:

·         NemAll_Python_Geometry_UnitTests\TestServiceTransform.py

SCALE scales the local coordinate system.

Syntax

SCALE x, y, z

Same as SCALE2

 

Reinforcement

FORMS

REINF_BAR_*

NemAll_Python_Reinforcement.BarPlacement()

Or use Python module StdReinfShapeBuilder.LinearBarPlacementBuilder

Example:

·         ReinforcementExamples\RebarPlacement.py

REINF_STIRRUP_*

NemAll_Python_Reinforcement.ReinforcementShapeBuilder.CreateStirrup()

Or use Python module StdReinfShapeBuilder.GeneralReinfShapeBuilder

Example:

·         ReinforcementExamples\GeneralShapeCreation.py

 

PLACEMENTS

REINF_PLACE

NemAll_Python_Reinforcement.BarPlacement()

Or use Python modules StdReinfShapeBuilder.LinearBarPlacementBuilder or

Example:

·         ReinforcementExamples\RebarPlacement.py or GeneralShapeCreation.py

 

Handles

2D/3D HANDLE

HANDLE2 creates a 2D handle in the point (X, Y). With handles, you can move or modify an object.

HANDLE2 is similar to HANDLE.

Syntax

HANDLE2 x, y [, unID [, paramReference, flags][, displayParam]]

GeneralScripts.HandleProperties.HandleProperties(handle_id, handle_point, ref_point, ele_prop_list, handle_move_dir, abs_value=True, distance_factor=1.0)

Example:

·         GeometryExamples\Cone.py

HANDLE creates a 3D handle in the point (X, Y, Z). With handles, you can move or modify an object.

HANDLE is similar to HANDLE2.

Syntax

HANDLE x, y, z [, unID [, paramReference, flags][, displayParam]]

Same as HANDLE2

 

Attributes

DIRECTIVES

e.g. PEN / COLOR / STROKE

NemAll_Python_Elements.CommonProperties.GetGlobalProperties or define by e.g.

NemAll_Python_Elements.CommonProperties.Color(color)

Example:

·         PaletteExamples\ExampleControls.py

MATERIAL

NemAll_Python_Elements.ModelElement(commonProp, textureDefinition, geometryObject)

Set the material in ModelElement constructor by textureDefinition parameter as string.

Example:

·         PaletteExamples\MaterialButtons.py

 

Non geometrical commands

PARAMETER COMMANDS

Parameter are defined by the *.pyp file. For deeper introduction have a look at the “How to define the PythonPart pyp file” documentation.

Examples can be found under PaletteExamples.

PALETTE COMMANDS

Palette controls are defined by the *.pyp file. For deeper introduction have a look at the “How to define the PythonPart pyp file” documentation.

Examples can be found under PaletteExamples.