 |
Create the Parameters Driving the
Pattern: NbPoints, YFactor, XFactor, ZFactor, PointsHidden, GenerateLines
-
Click the Formula icon ( ).
The Formula editor opens.
-
In the New parameter of type combo box, select
Integer and click New parameter of type.
-
In the Edit name or value of the current parameter
field, double-click Integer.1 and enter NbPoints. Click OK.
The NbPoints parameter is created.
-
In the New parameter of type combo box, select
Integer and click New parameter of type.
-
In the Edit name or value of the current parameter
field, double-click Integer.1 and enter YFactor. Click OK. The
YFactor parameter is created.
-
In the New parameter of type combo box, select
Integer and click New parameter of type.
-
In the Edit name or value of the current parameter
field, double-click Integer.1 and enter XFactor. Click OK. The
XFactor parameter is created.
-
In the New parameter of type combo box, select
Integer and click New parameter of type.
-
In the Edit name or value of the current parameter
field, double-click Integer.1 and enter ZFactor. Click OK. The
ZFactor parameter is created.
-
In the New parameter of type combo box, select
Boolean, and in the Edit name or value of the current
parameter field, enter PointsHidden. Click New parameter of
type.
-
In the New parameter of type combo box, select
Boolean. In the Edit name or value of the current
parameter field, enter GenerateLines. Click New parameter of
type. Click OK to validate.
Create the Knowledge Pattern
-
From the Start > Knowledgeware menu, select
the Product Knowledge Template workbench.
-
Click the Create a Knowledge Pattern icon ( ).
The Knowledge Pattern Editor opens.
-
Enter the following code in the editor or copy/paste the
code contained in this file:
let i (integer) (1)
let p (Point)
let p2 (Point)
let l( line)
let R (integer)
let G (integer)
let B (integer)
i = 1
For i while i <= NbPoints
{
set p = CreateOrModifyDatum("Point", `Geometrical Set.1` ,Points, i)
(2)
p = point(PartBody\Point.2\X + cos(i*XFactor) * 10mm, PartBody\Point.2\Y
+ cos(i*YFactor) * 10mm,
PartBody\Point.2\Z + cos(i*ZFactor) * 10mm) (3)
p.Name = "Point." + ToString(i)
if PointsHidden == True (4)
p.Show = False
else
{
p.Show = True
R = mod(i , 255)
G = mod(i * 2, 255)
B = 255 - mod(i, 255)
p.Color = ToString(R) + "," + ToString(G) + "," + ToString(B)
}
i = i +1
}
if
GenerateLines == True
{
i = 1
For i while i <= `Relations\Knowledge Pattern.1\Points` -
1
{
set l = CreateOrModifyDatum("Line", `Geometrical Set.1` , Lines, i) (5)
l.Name = "Line." + ToString(i)
p = Points.GetItem(i)
p2 = Points.GetItem(i + 1)
l = line(p, p2)
R = mod(i , 255)
G = mod(i * 2, 255)
B = 255 - mod(i, 255)
l.Color = ToString(R) + "," + ToString(G) + "," + ToString(B)
(6)
i = i + 1
}
}
|
 |
In the script above, you first
declare the local variables for points and lines then for colors:
R= Red, G=Green, B=Blue (1).
Then, depending on the number of points determined, a loop is run
to generate the desired number of points in the Geometrical Set
using the CreateOrModifyDatum method (2)
and a formula based on a point constructor (3).
Then, the system checks if the points are hidden or not. If not, a
color is applied. (4)
The lines are generated in the Geometrical Set using the
CreateOrModifyDatum method (5)
and a color is applied. (6) |
-
Click Add. List.1 = 0 elements is displayed in
the Knowledge Pattern Lists field.
-
Click it and replace it with Points in the Name
field.
-
Click Add. List.2 = 0 elements is displayed in
the Knowledge Pattern Lists field.
-
Click it and replace it with Lines in the Name
field.
-
In the Mode combo box, select Automatic
execution (before root update). Click OK when done.
-
In the specification tree, double-click the YFactor
parameter and enter 1. Click OK.
-
Double-click the XFactor parameter and enter 2. Click
OK.
-
Double-click the ZFactor parameter and enter 3. Click
OK.
-
Double-click the NbPoints parameter. Use the spin box to
indicate the number of instances you want to instantiate (50 in this
scenario.)
-
Click Execute now. 50 datum features are
created.
-
Double-click twice the parameter in the specification
tree. The Edit parameter dialog box displays.
-
Use the spin box to set the number of instances to 300
and click OK. 300 instances are created.
 Click
here to open
the Part containing the Knowledge Patterns. |
|