Mechanical Design

Assembly Design

Fix Constraint in Part Design

Set a fix constraint to the Part
Use Case

Abstract

This article discusses the CAAAuiCreateFixConstraintInPart use case. This use case explains how to create, list and remove a fix constraint in a Part document.


What You Will Learn With This Use Case

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]

The CAAAuiCreateFixConstraintInPart Use Case

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:

[Top]

What Does CAAAuiCreateFixConstraintInPart Do

CAAAuiCreateFixConstraintInPart:

[Top]

How to Launch CAAAuiCreateFixConstraintInPart

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:

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]

Where to Find the CAAAuiCreateFixConstraintInPart Code

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]

Replaying CAAAuiCreateFixConstraintInPart ODT

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]

Step-by-Step

There are five main steps in CAAAuiCreateFixConstraintInPart:

  1. Prolog
  2. Creating a fix constraint in part document
  3. Listing the constraint
  4. Removing the Constraint
  5. Epilog

We will now comment each of those sections by looking the code.

[Top]

Prolog

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]

Creating a fix constraint in part document.

  ...
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.

 

Listing the 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]

Removing the Constraint.

  ...
// 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]

Epilog

Close the document an then session is closed, as usual.

[Top]


In Short

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]


References

[1] Building and Launching a CAA V5 Use Case
[Top]

History

Version: 1 [Mar 2005] Document created
[Top]

Copyright © 2005, Dassault Systèmes. All rights reserved.