Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Parametric parts (PPM) are defined using a text description (script). The script defines the structure, editable properties, and output that result in a parametrically editable part.
The script must be saved with a *.PPM extension. The name of the file determines the name of the part.

Examining a Script

A simple example of a parametric part is a rectangle where the width, height and rotation angle are defined though parameters. The script of such part might look as follows:

...

The last line specifies that the output of the script will be the rotated rectangle called 'Rect'. This is what the be drawn as the part.

Script syntax

The description of a parametric part consists of the entire contents of a text file, except comments, tabs, and other control characters, which are ignored.
Comments are specified either using "//" characters that mean that all subsequent characters up to the end of the line are comments, or using the pair "/" and "/" that denote beginning and end of thecomment, respectively.

...

<Identifier>

and

<Expression>;

Identifiers

The <Identifier> defines the symbolic name of an object. It is a set of Roman letters and Arabic numerals, which must start with a letter.

...

Object identifiers may not be the same as names of functions or such names as PI, or LINEAR. These are reserved words that are used to designate the constants of the scripting language. The list of all reserved names is provided in the reserved word list which appears at the end of this chapter.

Expressions

Expressions define the associated identifier. Expression syntax matches the expression syntax in the majority of programming languages. They may define numeric value, arithmetic operations, the dependence of the defined object on other objects and function calls.
The structure of a function call is:

...

Code Block
(D \--1/4) * k;
Polyline(Point(0, 0.25 - 1/8), Point(0, D), Arc1(L-C, - m, m), Point(0,0));
A = B + 0.5;
B = 7;

Arithmetic Operations

Arithmetic operations may use the standard arithmetical operators '+' (addition), '--'(subtraction), '*' (multiplication), '/' (Division) and parenthesis '('and ')', to determine the sequence of performing arithmetic operations. Object identifiers and numbers serve as operands.

Script Semantics

A script contains full description of a parametric part. The collection of script operators determines which actions need to be performed to create the resultant object(s). Correct understanding of a script, requires having a clear understanding of how its operators are interpreted.
Identifiers that are used in a <Expression> must be defined. In other words it must have been used as:

...

Panel

NOTE: The sequence of script operators is not important (except certain special cases that will be described later); because operators are sorted before the script is run.

 

Basic Functions

Probably the most significant advantage of this method of creating parametric parts is the compact size and clarity of the text description of parametric parts in script form. The set of basic functions used in such a description, determines the level of clarity and simplicity of scripts for a particular class of parametric parts.
Note: It is intended that the set of basic functions will expand from version to version.

Description of Parameters

It is important to understand the structure used to within a Parameter function.

...

Alpha = Parameter("Rotation Angle", 45, ANGULAR, Interval(-90, 90)); // This creates a parameter used to define a rotation angle. The name is 'Rotation Angle', the default is 45, the value type is ANGULAR, and the Interval is from '-90' to '90'

Functions for Creating 2D Entities

The following functions are used to create 2D graphic entities

Circle

The Circle function is used to create circles

...

//circle.ppm – two circles
r1 = Parameter("Radius1", 2.5, LINEAR, Interval(0.0, 10.0));
r2 = Parameter("Radius2", 1.25, LINEAR, Interval(0.0, 10.0));
xc = Parameter("CenterX", 3, LINEAR, Interval(-100, 100));
yc = Parameter("CenterY", 3, LINEAR, Interval(-100, 100));
c1 = Circle(r1); // circle centered on the origin
c2 = Circle(r2, xc, yc); // circle offset from the origin
Output(c1, c2);

Rectangle

The Rectangle function is used to create rectangles.

...

rect = Rectangle(W, H, W/2. H/2); // Left bottom corner is in (0,0) point

Polyline

The Polyline function is used to create polylines consisting of straight line segments and arc segments.

...

Poly1 = Polyline( // Rectangle with rounded corners
Point(0,0),
Point(W - r, 0), Arc1(W - r, r), Point(W, r),
Point(W, H - r), Arc1(W - r, H - r), Point(W – r ,H),
Point(0, H), Fillet(r),
Point(0,0), Fillet(r) );

Functions for Creating 3D Entities from 2D Entities

You can use 2D entities as the basis for creating 3D objects.

Thickness

The Thickness function creates a 3D entity based on the 2D entity by adding thickness. It also allows you to change the thickness property of the 3D object.

...

// thickcircle2.ppm – draws a cylinder and changes thickness
Cylind=Thickness(Circle(1,2,2),2);
Cyl2 = Thickness(Cylind, 4); // changes the thickness of the first cylinder
Output(Cyl2);

Sweep

The Sweep function creates a 3D object by extruding a specified profile along a path, defined by a 2D polyline or circle. The profile is defined by a closed 2D polyline or circle.

...

//sweep2.ppm – another sweep example
L = Parameter("Length", 5, LINEAR, Interval(0.005, 1000));
W = Parameter("Width", 3, LINEAR, Interval(0.005, 1000));
H = Parameter("Height", 1, LINEAR, Interval(0.1, 3));
FR = Parameter("Fillet Radius", 0.3, LINEAR, Interval(0.001,100));
p = Polyline(Point(0,0), Point(0,H), Point(-FR,H), Point(-FR,0), Point(0,0));
p1a = RotateX(p,90,0,0);
p1 = Move(p1a, 0, W/2, 0);
p2 = Polyline( Point(0,0), Point(0,W), Fillet(FR), Point(L,W), Fillet(FR), Point(L,0), Fillet(FR), Point(0,0), Fillet(FR));
s = Sweep(p1, p2); Output(s);

Functions for Creating 3D Entities Directly

3D object may also be created directly without reference to a 2D entity.

Sphere

The Sphere function is used to create a 3D sphere.

...

//sphere.ppm – simple sphere example
R = Parameter("Radius", 2.5, LINEAR, Interval(0.01, 20));
cx = Parameter("CenterX", 0, LINEAR, Interval(-100, 100));
cy = Parameter("CenterY", 0, LINEAR, Interval(-100, 100));
cz = Parameter("CenterZ", 0, LINEAR, Interval(-100, 100));
S = Sphere(R, cx, cy, cz);
Output(S);

Cone

The Cone function is used to create a 3D cone.

...

//cone2.ppm – a truncated cone
R1 = Parameter("BaseRadius", 0.5, LINEAR, Interval(0.01, 10));
R2 = Parameter("TopRadius", 0.1, LINEAR, Interval(0, 10));
H = Parameter("Height", 3, LINEAR, Interval(0.05, 20));
Cone2 = Cone(H, R1, R2);
Output(Cone2);

Functions for Transforming Geometric Objects

This class of functions is used for moving, and rotating geometric objects. These transformations are related to the transformation of the coordinate system. As always functions create transformed objects, while original objects do not change.

Move

The Move function is used to move (shift) graphic objects.

...

//move.ppm – illustrates the Move function
RB = Parameter("BaseRadius", 2, LINEAR, Interval(0.1, 10));
RT = Parameter("TopRadius", 0.5, LINEAR, Interval(0, 10));
H = Parameter("Height", 4, LINEAR, Interval(0.1, 20));
con1 = Cone(H, RB, RT);
cx = Parameter("CenterX", 5, LINEAR, Interval(-10, 10));
cy = Parameter("CenterY", 0, LINEAR, Interval(-10, 10));
cz = Parameter("CenterZ", 0, LINEAR, Interval(-10, 10));
count = Parameter("Copies", 2, LINEAR, Interval(1, 10));
con2 = Move(con1, cx, cy, cz, count);// create count copies, offsetting each by cx, cy, cz
Output(con1, con2);

Rotate

The RotateX, RotateY. RotateZ functions are used to rotate graphic objects around the X, Y and Z axes, respectively.

...

//rotate.ppm – demonstrates the rotate functions
c1 = Circle(2, 10, 0); // create a circle
c2 = RotateX(c1, -90, 0, 0); // rotate the circle to lie in the XZ plane
c3 = Move(c2, 0, -0.05, 0); // move it back half the thickness
c4 = Thickness(c3, 0.1);
c5 = RotateZ(c4, 30, 0, 0, 11); //duplicate the circle by rotating about the Z axis
c6 = Circle(2, 0, 10);
c7 = Move(c6, 0, 0, -0.05);
c8 = Thickness(c7, 0.1);
c9 = RotateX(c8, -30, 0, 0, 11);
c10 = Circle(2, 0, 0);
c11 = RotateZ(c10, -90, 0, 0);
c12 = Move(c11, 10, 0, -0.05);
c13 = Thickness(c12, 0.1);
c14 = RotateY(c13, 30, 0, 0, 11);
Output(c4, c5, c8, c9, c13, c14);

Functions for Loading External Symbols as Elements

You can load non-parametric external symbols from external files to be a part of a parametric part. The files must be importable (supported) by the CAD system, such as *.TCW, *.DWG, *.SKP

StaticSymbol

The StaticSymbol function loads non-parametric symbols from external files. When the external symbol's filename is specified with no path information, the symbol is automatically assumed to reside in a sub-folder named Macro that is located in the ppm file's home folder.

...

//staticsym1.ppm – loads an external file from the Macro sub-folder
S = StaticSymbol("ExternalSymbol.tcw");
Output(S); //static symbol from ExternalSymbol.tcw file is inserted on the drawing

Set(FolderList(...))

To create a list of files in a folder, Set(FolderList(...)) is typically used as the Parameter restriction.

...

A parametric part (a file with a *.ppm extension) can loaded by calling the name of the parametric file as if it were a function, whose arguments are the parameters of the part to be loaded, in the order in which they are described in the file. Refer to "Creating Custom Functions" below for more details on this process.

Functions for 3D Boolean Operations

Functions of this class are used to perform Boolean operations on 3D geometric objects.

BooleanUnion

The BooleanUnion function creates an object by adding the specified objects together.

...

R = Parameter("Radius", 8, LINEAR, Interval(0.001, 1000));
s = Sphere(R);
c = Circle(R/3);
c1 = Thickness(c, R*2);
c2 = Move(c1, 0, 0, R); //Cylinder
s1 = BooleanUnion(s, c2); //Sphere with cylinder
Output(s1);

BooleanSubtraction

The BooleanSubtract function creates an object by subtracting the secondary objects from the primary object.

...

R = Parameter("Radius", 8, LINEAR, Interval(0.001, 1000));
s = Sphere(R);
c = Circle(R/3);
c1 = Thickness(c, R*2);
c2 = Move(c1, 0, 0, -R); //Cylinder
s1 = BooleanSubtract(s, c2); //Sphere with hole
Output(s1);

BooleanIntersect

The BooleanIntersect function creates an object derived from the intersection of the primary and secondary objects.

...

S1 = Sphere(5);
S2 = Sphere(5,5,5);
S3 = Sphere(5,5,-5);
S4 = Sphere(5,-5,5);
S5 = Sphere(5,-5,-5);
S6 = BooleanIntersect(S1,S2);
Output(S6);

Functions for Modifying 3D Objects

Several functions are available to modify the geometry of 3D objects.

Fillet Edges

The Fillet Edges function allows rounding one or multiple edges of 3D object.

...

L = Parameter("Length", 5, LINEAR);
W = Parameter("Width", 3, LINEAR);
H = Parameter("Height", 1, LINEAR);
R = Parameter("Radius",0.5);
g0 = Box(0,0,0,L,W,H);
g1 = G3Fillet(g0, Array(Point(L/2, 0, 0), Point(0, W/2, 0),
Point(L/2, W, 0), Point(L, W/2, 0)),
Array(R, R, R, R, R, R, R, R));
Output(g1);

Chamfer Edges

The Chamfer Edges function allows chamfering any edge or multiple edges of 3D object.

...

x = Parameter("size", 5, LINEAR, GreaterThan(0));
r1 = Parameter("r1", 1, LINEAR, GreaterThan(0));
b0 = Box(0, 0, 0, x, x, x);
b2 = G3Chamfer(b0, Point(x/2, x, x), Array(r1, r1+r1));
Output(b2);

G3Offset

The G3Offset function extends a solid face inward or outward.

...

x = Parameter("size", 5, LINEAR, GreaterThan(0));
r1 = Parameter("r1", 1, LINEAR, GreaterThan(0));
b0 = Box(0, 0, 0, x, x, x);
b3 = G3Offset(b0, Point(x,x/2,x/2), r1/2);
Output(b3);

G3Shell

The G3Shell function allows shelling the shape of solid object, leaving the selected face open. It creates a shell of a specified thickness from a single solid object. The new faces are created by offsetting existing faces inside or outside.

...

L = Parameter("Length", 5, LINEAR);
W = Parameter("Width", 3, LINEAR);
H = Parameter("Height", 1, LINEAR);
T = Parameter("Thickness", 0.2, LINEAR);
g0 = Box(0,0,0,L,W,H);
g1 = G3Shell(g0, Point(L/2, W/2, H), T);
Output(g1);
//After inserting a shelled object in the drawing, shell thickness can be edited in the Selection Info palette (as well as Length, Width and Height parameters)

G3Bend

The G3Bend function is used for bending 3D objects.

...

P1=Thickness(Rectangle(10,20),3);
B0 = G3Bend(P1, Point(3, 3, 0),
Point(3,8,0), 90, 2, 0);
Output(B0);

Setting and Changing Object Properties

The SetProperties function is used to set the properties of objects.

...

In the Parametric Part manager there is a special tool to choose the required value for such properties as Material, Pen Color and Brush Style. To activate it, right-click on the property name. This will open the Local Menu either for Material table or PenColor table or BrushStyle table. The appropriate table will appear where the desired value can be chosen.

Nesting Functions

Functions can be nested within a single expression to optimize scripting efficiency.

...

B1 = Box(0,0,0,10,10,10);
BF = BooleanSubtract(B1,Move(RotateZ(RotateY(Box(-5,-5,-5,5,5,5),45),45),-1,-1,-1));
Output(BF);

Functions for Creating Text

Text

The Text function defines the text string itself and its characteristics, including fonts, style, effects, etc. Acceptable font values are dependent upon those installed on your machine.

...

bsb = Text("BS(b)", Tfont, Tstyle);

TextFont

The TextFont function sets the text font, size, and the angle of text line location.

...

Where:
0 — means that text is Standard
2 — text height
45 — text line is located at 45 degrees
Arial — font

TextStyle

The TextStyle function sets the text style including justification, text effects and styles.

...

//Standard text of Times New Roman font with 5in of font size,
//with Left,Top justification, with TextBox effect, Bold, Italic, at 45 degrees of Angle
ht=5;
font_name = "Times New Roman";
Tfont = TextFont(0, ht, 45, font_name);
Tstyle = TextStyle(LEFT, TOP, BOX,BOLD, ITALIC);
bsb = Text("BS(b)", Tfont, Tstyle);
Output(bsb);

Auxiliary Functions

Extents

The ExtentsX1, ExtentsX2, ExtentsY1, ExtentsY2, ExtentsZ1 and ExtentsZ2 functions are used to calculate the extents of graphic objects.
Format:

...

A0=Thickness(Rectangle(H-3/4,D), 3/4);
A1=RotateY(A0,90);
xmin = ExtentsX1(A1);
xmax = ExtentsX2(A1);
ymin = ExtentsY1(A1);
ymax = ExtentsY2(A1);
zmin = ExtentsZ1(A1);
zmax = ExtentsZ2(A1);
P1 = Box(xmin, ymin, zmin, xmax, ymin+3, zmin+4);

ParameterPoint

The ParameterPoint function defines a parametric point with number and coordinates.

...

P0 = ParameterPoint(0, l, -l, 0);
P1 = ParameterPoint(1, 0, 0, 0);

PointX, PointY, PointZ functions

The PointX, PointY, PointZ are used to calculate the coordinates of parametrical point. The PointX function calculates X-coordinate of parametrical point. The PointY function calculates Y-coordinate of parametrical point. The PointZ function calculates Z-coordinate of parametrical point.

...

x0 = PointX(P0); // x0=1 for P0 = ParameterPoint(0, l, -l, 0);
y1 = PointY(P1); //y1=0 for P1 = ParameterPoint(1, 0, 0, 0);
z1 = PointZ(P1); //z1=0 for P1 = ParameterPoint(1, 0, 0);

Anchor
RTF5f5265663231313134373438
RTF5f5265663231313134373438

Anchor
RTF5f546f633231313137333832
RTF5f546f633231313137333832
Anchor
RTF5f546f633231313836363530
RTF5f546f633231313836363530
Special functions and operators

IF

The IF function allows various actions to be performed depending upon whether the specified condition is fulfilled or not fulfilled. It plays the role of a conditional operator, and can be used to create branches in the logic of building a parametric part.

...

Tstyle = IF(dir > 0, TextStyle(MIDDLE, RIGHT), TextStyle(MIDDLE, LEFT));
//Regardless of the specified size of dir, Text Style will be specified with Right or Left justification.

UNITS

The UNITS function defines the units that will be used in the script. It defines the System, Space Units and Scale of dimensions used while creating objects. This function allows loading parts correctly in drawings with different specified units.

...

Units(2[in]);//created object is scaled up 2 times compared with the case of Units(1[in]);
_Units(0.5[in]);// created object is scaled ½ as large as compared with the case of Units(1[in]);_

RefPoint

The RefPoint function sets the location of the Reference Point for the parametric part. When the Reference Point is one of the output values of a script, it is inserted in the drawing along with the part. This enables precise insertion of the parametric object into the drawing.

...

xArrow = PointX(P0);
yArrow = PointY(P0);
rf = RefPoint(xArrow, yArrow, 0); //-> RefPoint is placed on the point (xArrow,yArrow, 0)
Output(rf);

Input and Output

The Input and Output functions are used for inputting initial values or objects into the script and outputting result objects from the script.

...

Sw = Parameter("Switch", 1, CHECKBOX);
P1 = Thickness(Rectangle(5,5), 3);
S1= Thickness(Circle(2.5),4);
Output(IF(Sw,P1,S1));
//Here is either cylinder or box inserted on the drawing
//depending on checkbox Sw value

min and max

The min and max functions are used for choosing the minimum or maximum values within a set of values.

...

Note: A Group of objects cannot be used as argument of these functions, because a Group is a collection of graphic objects, rather than a collection of numbers.

...

Mod

The Mod function is used for finding the remainder of the integer division. For example, Mod(5,4) is 1, because 5/4 = 1, with a remainder of 1. Mod(7,4) is 3, because 7/4 = 1, with a remainder of 3. Mod(7,3) = 1, because 7/3 = 2, remainder 1.
Note: The Mod function is often used to determine if a number is odd or even, because Mod(AnyOddNumber, 2) = 1, while Mod(AnyEvenNumber, 2) = 0.

...

A = 7;
B = 4;
C = Rectangle(A, Mod(A,B));
Output(C);

Div

The Div function is used to perform division.

...

A=7;
B=3;
result1 = A/B;
result2 = Div(A, B);
rect = Rectangle(result1, result2)
Output(rect);

Additional Math Functions

sqrt

Calculates the square root of a specified number
P = sqrt(b);

asin

Calculates the arcsine. Returns the angle in radians
P = asin(0.5);

acos

Calculates the arcsine. Returns the angle in radians
P = acos(0.5);

Array

The Array function defines an array of values, or an array of Points, by directly listing the elements of the array. In other words the Array function collects geometric objects or values into an Array object.

...

txt = Parameter("text", "Simple text example", TEXT);
a = Array(TextFont(0,10,"Arial"), TextStyle(CENTER, MIDDLE, ITALIC));
//Array of 2 items: TextFont and TextStyle)
s0 = Text(txt, a);
Output(s0);

Group

The Group function collects multiple graphic objects into a group and assigns an identifier name to the result. It allows the script to work with multiple objects as if they were a single object. Also a Group can be the output value of a script. Groups of objects can take part in different operations: Move, Rotate, etc.

...

Bx = Group(Move(BxL, -Dis*1.5), Move(BxR, Dis*1.5));
ShelfFBx = BooleanSubtract(ShelfF, Bx);
Output(ShelfFBx, Bx);

Special Functions without Parameters

PI

The PI function calculates the value of Pi = 3.14159...

#$AUX@_Contour

Defines a clipping contour for the resulting object. This is used to clip (remove) sections of walls when the object in inserted into a wall. It uses a referenced contour that is defined elsewhere in the script. The referenced contour must be closed.

...

Output(ClipContour, TS); 

Creating custom functions

When scripts of the same type are created, which describe a particular class of parametric parts, it can be convenient to have the sequence of repeated actions as a separate specialized function. To achieve this, the repeated actions can be put into a separate <name>.ppm file.
In this case, all input variables should be listed in the Input operator:

...

File location is crucial when using parametric scripts as custom functions. In the example above, if blend_box.ppm lies in the folder D:/Symbols, then it can only find the box.ppm script if box.ppm is located in the folder D:/Symbols/Macro.

Parametric Parts Reserved Word List

PI

LINEAR

TEXT

ANGULAR

MATERIAL

FONT

COLOR

CHECKBOX

ITALIC

BOLD

UNDERLINE

BOX

ALLCAPS

STRICKETHROUGH

TOP

MIDDLE

BOTTOM

BASELINE

LEFT

CENTER

RIGHT

Call

Array

+

-

*

Div

Mod

/

-

sin

cos

tan

atan

min

max

**

=

==

!=

<

>

<=

>=

&

Solid

Extrude

UNIQUE

GraphicId

VertexId

 

Vertex

Face

Edge

Source

Bound

Intersect

OperationList

BlendArg

BlendParam

BlendType

BlendRadiusMode

BlendSetback

BlendRadiusBlendSmooth

BlendRadiusParam

BlendOffsetParam

BlendFaceEntity

BlendFaceEdge

BlendFaceVertex

BlendEdgeEdge

BlendEdgeVertex

BlendEdgeVertexMain

BlendEdgeVertexAux

ShellArg

ShellThickness

ShellFace

ShellEdge

FaceEditArg

Transform

ScaleX

ScaleY

ScaleZ

ShearXY

ShearXZ

ShearYZ

RotateX

RotateY

RotateZ

TranslateX

TranslateY

TranslateZ

Path

Profile

LateralFace

LateralEdge

CapFace

CapEdge

JointEdge

Profiles

HighLight

FaceMaterialArg

FaceMaterial

FaceOffsetArg

FaceHoleArg

FaceHole

BendId

BendRadius

BendAngle

BendNeutral

BendFlag

BendPosition

BendFlangeHeight

BendAxialDistance

BendAzimuthAngle

BendEdgeStartPosition

BendEdgeEndPosition

Face2FaceLoftArg

Face2FaceLoft

 

AssemblyAxis

Input

Output

Include

Units

StaticSymbol

FolderList

Macro

Parameters

Parameter

ParameterPoint

PointX

PointY

PointZ

Set

Interval

LessThan

GreaterThan

LessOrEquail

GreaterOrEqual

Circle

Rectangle

Polyline

Point

Arc0

Arc1

Fillet

IF

Move

Thickness

Sweep

Cone

BooleanUnion

BooleanSubtract

BooleanIntersect

G3Fillet

G3Chamfer

G3Shell

G3Offset

G3Slice

G3Bend

ExtentsX1

ExtentsX2

ExtentsY1

ExtentsY2

ExtentsZ1

ExtentsZ2

Text

TextFont

TextStyle

Group

SetProperties

PatternCopy