Mechanical Design |
Assembly Design |
Fix Constraint in Part DesignSet a fix constraint to the Part |
Use Case |
AbstractThis article discusses the CAAAuiCreateFixConstraintInPart use case. This use case explains how to create, list and remove a fix constraint in a Part document. |
This use case is intended to help you make your first steps in programming with CATIA Part Design. Its main intent is to fix an element in Part design document. More specifically, you will learn how to:
[Top]
CAAAuiCreateFixConstraintInPart is a use case of the CAAAssemblyUI.edu framework that illustrates the ConstraintModeler framework capabilities.
Before discussing the use case, some main concepts, about the fix constraint, have to be introduced:
A fix constraint is a geometrical relation created on a feature or a body, with respect to the 3D space
The object then cannot be moved in 3D space, though its defining parameters can be modified
The fix constraint appears in the specification tree at the same level as the element to be constrained and they are displayed under PartBody or GeometricalSet, which owns the element.
[Top]
CAAAuiCreateFixConstraintInPart:
[Top]
To launch CAAAuiCreateFixConstraintInPart, you will need to set up the build time environment, then compile CAAAuiCreateFixConstraintInPart along with its prerequisites, set up the run time environment, and then execute the use case [1].
Launch the use case as follows:
e:>CAAAuiCreateFixConstraintInPart InputDirectory OutputDirectory |
$ CAAAuiCreateFixConstraintInPart InputDirectory OutputDirectory |
where:
InputDirectory |
The directory into which Line_FixCst.CATPart is stored, usually in the resources directory of your RuntimeView |
OutputDirectory | The directory into which output part "Line_FixCst_output.CATPart" is stored |
[Top]
The CAAAuiCreateFixConstraintInPart use case is located in the CAAAuiCreateFixConstraintInPart.m module of the CAAAssemblyUI.edu framework:
Windows | InstallRootDirectory\CAAAssemblyUI.edu\CAAAuiCreateFixConstraintInPart.m\ |
Unix | InstallRootDirectory/CAAAssemblyUI.edu/CAAAuiCreateFixConstraintInPart.m/ |
where InstallRootDirectory
is the directory where the CAA CD-ROM
is installed.
[Top]
The required data for CAAAuiCreateFixConstraintInPart ODT is located in the CAAAssemblyUI.tst framework:
Shell script | InstallRootDirectory/ CAAAssemblyUI.tst/FunctionTests/TestCases/CAAAuiCreateFixConstraintInPart.sh |
InputData | InstallRootDirectory/ CAAAssemblyUI.tst/FunctionTests/TestCases/InputData/Line_FixCst.CATPart |
Output | InstallRootDirectory/ CAAAssemblyUI.tst/FunctionTests/TestCases/Output/intel_a/Line_FixCst_output.CATPart |
where InstallRootDirectory
is the directory where the CAA CD-ROM
is installed.
[Top]
There are five main steps in CAAAuiCreateFixConstraintInPart:
We will now comment each of those sections by looking the code.
[Top]
CAAAuiCreateFixConstraintInPart begins by checking that the command lines contains one argument (file path of CATPart document). It then creates a session, and opens a CATPart document with the help static method OpenDocument of class CATProductDocument. It then retrieves the document's root(specification) container handle of type CATIPrtContainer, and then retrieves mechanical part feature handle (of type CATIPrtPart). It searches part's descendants (CATIDescendants) of type "non-ordered geometrical set". Under geometrical set, it searches for the 3rd child that is line and retrieves line's handle ( of type CATISpecObject) as
spSpecLine |
A pointer to CATISpecObject onto the line. |
[Top]
... CATICst_var spCst = NULL_var; CATLISTV(CATBaseUnknown_var) ElemList; ElemList.Append(spSpecLine); // Create a constraint : Type - Fix constraint, Element to be constrained - Line, rc = CATConstraintServices::CreateConstraintIn( spPart, CstType_Reference, ElemList, 0.0, CATCstVal_Mode_Constrained, spCst); // Process errors ... |
The constraint is created using the static method CreateConstraintIn of the class CATConstraintServices. The only out argument to this method is the handle of the created constraint. CreateConstraintIn has the following arguments...
spPart | The owner of the created constraint, can be a Part or a Sketch. |
CstType_Reference | The constraint's type: a fix constraint. |
ElemList | The list of geometry involved in the constraint, can contain from 1 to 3 elements. |
0.0 | The constraint's value. For angle or offset constraints only. |
CATCstVal_Mode_Constrained | The creation mode. |
spCst | The created constraint. |
... // Get the list of constraints under a given Part CATLISTV(CATICst_var) CstList; rc=CATConstraintServices::ListConstraints(spPart, CstList); if(SUCCEEDED(rc)) { cout << "***** Listing constraints *****" << endl; cout << "*** Total constraints = " << CstList.Size() << endl; } else { // Process errors } ... |
The constraints are listed using the static method ListConstraints of the class CATConstraintServices. If no constraints are found, the call to method will fail. ListConstraints has the following arguments...
spPart | The Part or Sketch where the constraints are created. |
CstList | The resulting constraints list. |
[Top]
... // Remove constraints rc = CATConstraintServices::RemoveConstraint(spCst); if ( SUCCEEDED(rc) ) cout << "***** Removing constraint ***** " << endl; else { // Process errors } ... |
The constraint is removed using the static method RemoveConstraint of the class CATConstraintServices. RemoveConstraint has the following arguments...
spCst | The constraint to remove. The constraint has to be defined in a Part or a Sketch. |
[Top]
Close the document an then session is closed, as usual.
[Top]
This use case has demonstrated the way to create, list and remove the fix constraint on the (non-order geometrical set) element of a part design document.
[Top]
[1] | Building and Launching a CAA V5 Use Case |
[Top] |
Version: 1 [Mar 2005] | Document created |
[Top] |
Copyright © 2005, Dassault Systèmes. All rights reserved.