Automating Tasks

ainfo.gif (980 bytes) If you perform a task repeatedly, you can take advantage of a macro to automate it. A macro is a series of functions, written in a scripting language, that you group in a single command to perform the requested task automatically.
This task will show you how to edit a macro created in the DMU Optimizer workbench.
aprereq.gif (1223 bytes) Open the ThicknessMacro.CATScript  from the sample folder with a Text editor

You stored your recorded  macros in a text format file. For more details about recording, running macros refer to the DMU Navigator Infrastructure User's Guide.

ascenari.gif (1364 bytes)  You can easily modify the macro instructions specific to DMU Optimizer (strings of characters put in bold).
Here is an example:
  • Thickness Macro

THICKNESS MACRO

EXPLANATIONS

Language="VBSCRIPT"

Sub CATMain()

Dim productDocument1 As Document
Set productDocument1 = CATIA.ActiveDocument

Dim dMOThicknesses1 As DMOThicknesses
Set dMOThicknesses1 = optimizerWorkBench1.Thicknesses

Dim product1 As Product
Set product1 = productDocument1.Product

Dim groups1 As AnyObject
Set groups1 = product1.GetTechnologicalObject("Groups")

 

Dim group1 As Group
Set group1 = groups1.Add()

group1.AddExplicit product1

Dim dMOThicknesses1 As AnyObject
Set dMOThicknesses1 = product1.GetTechnologicalObject("Thicknesses")
 

Name of the product selected for the thickness.

Enter a meaningful name if you wish to edit the name.
macro01NLS.gif (1034 bytes)
Dim arrayOfVariantOfDouble1(5)
arrayOfVariantOfDouble1(0) = 1665.173462
arrayOfVariantOfDouble1(1) = -682.007568
arrayOfVariantOfDouble1(2) = -29.914585
arrayOfVariantOfDouble1(3) = -0.006795
arrayOfVariantOfDouble1(4) = -0.173679
arrayOfVariantOfDouble1(5) = 0.984779
Dim document1 As Document
Set document1 = dMOThicknesses1.ComputeAThickness(group1, 2.000000, -2.000000, 0, arrayOfVariantOfDouble1)

Dim optimizerWorkBench1 As Workbench
Set optimizerWorkBench1 = productDocument1.GetWorkbench("OptimizerWorkBench")


groups1.Remove group1

document1.Activate

 
2.000000, -2.000000, Gives the values of the offset 1 and offset 2, you defined.
macro02NLS.gif (1963 bytes)
 

1 corresponds to the number orientation constraints.

arrayOfVariantOfDouble1:  defines the constraint coordinates:

  • Constraint location point

arrayOfVariantOfDouble1(0) = 1665.173462
arrayOfVariantOfDouble1(1) = -682.007568
arrayOfVariantOfDouble1(2) = -29.914585

  • Corresponding normal vector

arrayOfVariantOfDouble1(3) = -0.006795
arrayOfVariantOfDouble1(4) = -0.173679
arrayOfVariantOfDouble1(5) = 0.984779

document1.SaveAs "./Product1_THICKNESS.cgr"

productDocument1.Activate

productDocument1.Activate

End Sub
Gives the location of the cgr file you saved.
ainfo.gif (980 bytes) Note: From V5R11,  the calculation changes: offset1 and offset2 values make the selected surface move to two opposite directions (i.e. two positive values equal to 2mn will result in a thickness of 4mm).
Open the ThickR11.CATScript  document to access a V5R11 thickness macro (taking in account this behavioral change)
Open the SilhouetteMacro.CATScript document from the samples folder
ainfo.gif (980 bytes) Silhouette macro example :

Dim arrayOfVariantOfDouble1(17)
arrayOfVariantOfDouble1(0) = 1.000000
arrayOfVariantOfDouble1(1) = 0.000000
arrayOfVariantOfDouble1(2) = 0.000000
arrayOfVariantOfDouble1(3) = -1.000000
arrayOfVariantOfDouble1(4) = 0.000000
arrayOfVariantOfDouble1(5) = 0.000000
arrayOfVariantOfDouble1(6) = 0.000000
arrayOfVariantOfDouble1(7) = 1.000000
arrayOfVariantOfDouble1(8) = 0.000000
arrayOfVariantOfDouble1(9) = 0.000000
arrayOfVariantOfDouble1(10) = -1.000000
arrayOfVariantOfDouble1(11) = 0.000000
arrayOfVariantOfDouble1(12) = 0.000000
arrayOfVariantOfDouble1(13) = 0.000000
arrayOfVariantOfDouble1(14) = 1.000000
arrayOfVariantOfDouble1(15) = 0.000000
arrayOfVariantOfDouble1(16) = 0.000000
arrayOfVariantOfDouble1(17) = -1.000000
Dim document1 As Document
Set document1 = silhouettes1.ComputeASilhouette(group1, arrayOfVariantOfDouble1, 20.000000, 0.000000)
 

Coordinates of the  first viewpoint vector :

arrayOfVariantOfDouble1(0) = 1.000000
arrayOfVariantOfDouble1(1) = 0.000000
arrayOfVariantOfDouble1(2) = 0.000000

and so on...

aendtask.gif (1477 bytes)