|
-
Open the
KwrEvent_BeforeUpdate.CATPart file: It contains 3 points and a spline
(called cable in this scenario).
-
From the Start > Knowledgeware menu, access
the Product Engineering Optimizer workbench and click the
Optimize icon ().
The Optimization window opens.
-
Enter the following data in the Optimization window:
Problem tab |
|
|
Optimization type |
Minimization |
Optimized parameter |
distance |
Free parameters |
Geometrical Set.1\Point.3\Z |
Algorithm |
Simulated Annealing Algorithm |
Termination criteria |
Maximum number of updates: 100
Consecutive updates without improvements: 20
Maximum time (minutes): 5 |
Constraints tab |
|
|
New constraint |
Geometrical Set.1\Point.3\Z`
- max (Geometrical Set.1\Point.2\Z)
,Geometrical Set.1\Point.1\Z)
<= 0mm |
-
Click OK in the opening dialog box, click
Run optimization.
-
Select an output file and click Save.
-
Click OK when the optimization process
is over.
-
From the Start > Knowledgeware menu, access
the Knowledge Advisor workbench and click the Macros with argument icon ().
The Script Editor opens. Enter the following data in the editor and click
OK:
Argument |
optim |
Script body |
optim.Run false |
-
Click the Reaction icon ().
The Reaction dialog box opens.
|
|
In the Source type field, select
Owner. |
|
|
From the Available events list,
select BeforeUpdate. |
|
|
In the Action field, select
Knowledgeware action. |
|
-
Click Edit action..., paste the following
script in the editor, and click OK twice:
if (CableLength <= distance (Geometrical
Set.1\Point.1
,Geometrical Set.1\Point.2
))
Message ("Incompatible inputs: cable length is less than distance
between points!")
else
{
`VB Script.1` .Run(Relations\Optimizations.1\Optimization.1
)
} |
-
Double-click the root of the specification tree and
select Insert > UserFeature > UserFeature Creation.... The
User Feature Definition window opens.
-
In the Name field, enter the name of the UDF:
Cable1 in this scenario.
-
Select the Spline, Point3, Reaction.1, VB Script.1,
Optimization.1, the 4 formulas, and the parameters: they are displayed in
the User Feature definition window.
|
Note that the UDF becomes the owner of the
reaction. This reaction will be fired before the update of the UDF
instance. |
-
Click the Parameters tab, select CableLength,
click the Published name check box and click OK.
-
Save the file and close it.
-
Create a .CATPart file, access the Generative Shape
Design workbench, and create 3 points.
-
Select Insert > Instantiate From Document....
The File Selection window opens. Select the KwrEvent_BeforeUpdate.CATPart
file you saved and click Open.
-
The Insert object dialog box opens. Select Point.1 and
Point.2 in the geometry or in the specification tree and click OK.
The cable (UDF) is instantiated and the optimization is launched before
the update.
-
Repeat steps 14 and 15: select Point.2 and Point.3 when
instantiating the UDF: the cable lengths are optimized.
-
Double-click the CableLength=400mm parameter
and change its value to 200mm. This cable length is optimized once again
before the update.
|