A relation computes values. A relation can belong to one of the following types:
- Formula
- It combines parameters to compute the value of one output parameter
only. For example, the mass of a cuboid can be the output parameter
of a formula, while the value is computed using the following parameters:
FormulaBody = (height*width*depth)*density
- Program
- It combines conditions and actions on parameters to compute one or
several output parameter values. For example, the following is a program:
ProgramBody = if (mass>2kg) { depth=2mm length=10mm } else { depth=1mm length=5mm } - Check
- It only contains conditions on parameter values.
For example, the following is a check:
CheckBody = mass<10kg
The parameters should be defined previously.
The following example shows how to retrieve the collection of relations from a newly created part document:
Dim CATDocs As Documents
Set CATDocs = CATIA.Documents
Dim part As Document
Set part = CATDocs.Add("CATPart")
Dim relations As Relations
Set relations = part.Relations
- See also:
- , , ,
Properties
- Property Optimizations() As (Read Only)
-
Returns the optimization collection.
It can be empty if no optimization is defined in the document.
This property is available only when the Product Engineering Optimizer license is available.
Methods
- Func CreateCheck( iName, iComment, iCheckBody) As
-
Creates a check relation and adds it to the part's
collection of relations.
- Parameters:
-
- iName
- The check name dd>
- iComment
- A description of the check dd>
- iCheckBody
- The check definition dd>
- Returns:
- The created check
- Example:
-
This example creates the maximummass check relation
and adds it to the newly created part:
Dim CATDocs As Documents Set CATDocs = CATIA.Documents Dim partdoc As Document Set partdoc = CATDocs.Add("CATPart") Dim part As Part Set part = partdoc.Part Dim massCheck As Check Set massCheck = part.Relations.CreateCheck ("maximummass", "Ensures that the mass is less than 10 kg", "mass<10kg")
- Parameters:
-
- iName
- The design table name dd>
- iComment
- A description of the design table dd>
- iCopyMode
- dd>
- Returns:
- The created design table
- Example:
-
This example creates the dt design table
and adds it to the newly created part:
Dim CATDocs As Documents Set CATDocs = CATIA.Documents Dim partdoc As Document Set partdoc = CATDocs.Add("CATPart") Dim part As Part Set part = partdoc.Part Dim designtable As DesignTable Set designtable = part.Relations.CreateDesignTable ("dt", "Ensures that the mass is less than 10 kg", TRUE, "/u/users/client/data/sheet.txt")
- Parameters:
-
- iName
- The formula name dd>
- iComment
- A description of the formula dd>
- iOutputParameter
- The parameter which stores the result of the formula dd>
- iFormulaBody
- The formula definition dd>
- Returns:
- The created formula
- Example:
-
This example creates the computemass formula relation
and adds it to the newly created part:
Dim CATDocs As Documents Set CATDocs = CATIA.Documents Dim partdoc As Document Set partdoc = CATDocs.Add("CATPart") Dim part As Part Set part = partdoc.Part Dim massFormula As Formula Set massFormula = part.Relations.CreateFormula ("computemass", "Computes the cuboid mass", mass, "(height*width*depth)*density")
- Parameters:
-
- iName
- The design table name dd>
- iComment
- A description of the design table dd>
- iCopyMode
- dd>
- Returns:
- The created design table
- Example:
-
This example creates the dt design table
and adds it to the newly created part:
Dim CATDocs As Documents Set CATDocs = CATIA.Documents Dim partdoc As Document Set partdoc = CATDocs.Add("CATPart") Dim part As Part Set part = partdoc.Part Dim designtable As DesignTable Set designtable = part.Relations.CreateHorizontalDesignTable ("dt", "Ensures that the mass is less than 10 kg", TRUE, "/u/users/client/data/horizontalsheet.txt")
- Parameters:
-
- iName
- The law name dd>
- iComment
- A description of the law dd>
- iLawBody
- The law definition dd>
- Returns:
- The created law dd>
- Parameters:
-
- iName
- The program name dd>
- iComment
- A description of the program dd>
- iProgramBody
- The program definition dd>
- Returns:
- The created program
- Example:
-
This example creates the selectdepth program relation
and adds it to the newly created part:
Dim CATDocs As Documents Set CATDocs = CATIA.Documents Dim partdoc As Document Set partdoc = CATDocs.Add("CATPart") Dim part As Part Set part = partdoc.Part Dim depthProgram As Program Set depthProgram = part.Relations.CreateProgram ("selectdepth", "Select depth with respect to mass", "if (mass>2kg) { depth=2mm } else { depth=1 mm }")
- Parameters:
-
- iName
- The name of the rulebase. dd>
- Returns:
- The created rulebase. dd>
- See also:
- Parameters:
-
- iName
- The name of the set of equation. dd>
- iComment
- The comment of the set of equation. dd>
- iFormulaBody
- The body of the set of equation " a==b+4; c ≤ 90". dd>
- Returns:
- The created set of equations dd>
- Parameters:
-
- iParent
- The object to which the set is appended dd>
- Parameters:
-
- iName
- The name of the XML file dd>
- Parameters:
-
- iIndex
- The index or the name of the relation to retrieve from the collection of relations. As a numerics, this index is the rank of the relation in the collection. The index of the first relation in the collection is 1, and the index of the last relation is Count. As a string, it is the name you assigned to the relation using the property or when creating the relation. dd>
- Returns:
- The retrieved relation
- Example:
-
This example retrieves the last relation in the relations
collection.
Dim lastRelation As Relation Set lastRelation = relations.Item(relations.Count)
- Parameters:
-
- iIndex
- The index or the name of the relation to remove from the collection of relations. As a numerics, this index is the rank of the relation in the collection. The index of the first relation in the collection is 1, and the index of the last relation is Count. As a string, it is the name you assigned to the relation using the property or when creating the relation.
- Example:
-
This example removes the relation named density from
the relations collection.
relations.Remove("density")
- Parameters:
-
- iFeature
- The object used to filter the the whole relation collection to get the resulting sub-collection. dd>
- iRecursively
- A flag to specify if children parameters are to be searched for in the returned collection dd>
- Returns:
- The resulting sub-collection
- Example:
-
This example shows how to get a collection of relations that are under a Pad
Dim Relations1 As Relations Set Relations1 = CATIA.ActiveDocument.Part.Relations' gets the collection of relations in the part Dim Body0 As AnyObject Set Body0 = CATIA.ActiveDocument.Part.Bodies.Item ( "MechanicalTool.1" ) Dim Pad1 As AnyObject Set Pad1 = Body0.Shapes.Item ( "Pad.1" ) ' gets the pad Pad.1 Dim Relations2 As Relations Set Relations2 = Relations1.SubList(Pad1, TRUE) ' gets the collection of relations that are under the pad Pad.1