Constraint Class¶
-
class
NXOpen.Positioning.Constraint¶ Bases:
NXOpen.NXObjectConstraints for use in positioning objects in NX.
For constraints between components, the subclass
NXOpen.Positioning.ComponentConstraintshould be used by preference.Some constraint types have an
NXOpen.Expressionassociated with them, which the user can change to determine the value of that constraint. This expression applies to distance and angle constraints. The user can choose for this expression value to be driven by the system, so it will not have a fixed value set by the user.The constraint types with values can be given limits. If the constraint is driven, the solver will always try to solve it to remain within those limits, and the constraint will fail if this is not possible. If the constraint is driving, it will have a failure status if its value is set to violate those limits (though it will still solve the model).
To create a new instance of this class, use
NXOpen.Positioning.Positioner.CreateConstraint()New in version NX4.0.0.
Properties¶
| Property | Description |
|---|---|
| Automatic | Returns or sets the flag marking the constraint as an automatic constraint. |
| ConstraintAlignment | Returns or sets the alignment behavior for the constraint. |
| ConstraintType | Returns or sets the constraint type. |
| Expression | Returns the NXOpen.Expression of a constraint. |
| ExpressionDriven | Returns or sets the driven state of the expression of a constraint. |
| IsOccurrence | Returns whether this object is an occurrence or not. |
| JournalIdentifier | Returns the identifier that would be recorded in a journal for this object. |
| LowerLimitEnabled | Returns or sets the lower limit of the expression of a constraint. |
| LowerLimitExpression | Returns the lower limit of the expression of a constraint. |
| LowerLimitRightHandSide | Returns or sets the lower limit of the expression right hand side of a constraint. |
| Name | Returns the custom name of the object. |
| OwningComponent | Returns the owning component, if this object is an occurrence. |
| OwningPart | Returns the owning part of this object |
| Persistent | Returns or sets the persistent state of the constraint. |
| Prototype | Returns the prototype of this object if it is an occurrence. |
| SplinePointsType | Returns or sets the type of the spline. |
| Suppressed | Returns or sets the suppression state for the constraint. |
| Tag | Returns the Tag for this object. |
| UpperLimitEnabled | Returns or sets the upper limit of the expression of a constraint. |
| UpperLimitExpression | Returns the upper limit of the expression of a constraint. |
| UpperLimitRightHandSide | Returns or sets the upper limit of the expression right hand side of a constraint. |
Methods¶
| Method | Description |
|---|---|
| CreateAttributeIterator | Create an attribute iterator |
| CreateConstraintReference | Adds geometry to a constraint and sets the movable object to be constrained. |
| DeleteAllAttributesByType | Deletes all attributes of a specific type. |
| DeleteAttributeByTypeAndTitle | Deletes an attribute by type and title. |
| DeleteConstraintReference | Removes a NXOpen.Positioning.ConstraintReference from the constraint. |
| DeleteUserAttribute | Deletes the first attribute encountered with the given Type, Title. |
| DeleteUserAttributes | Deletes the attributes on the object, if any, that satisfy the given iterator |
| EditConstraintReference | Adds geometry to a constraint and sets the movable object to be constrained, replacing the properties of an existing reference of the constraint. |
| FindObject | Finds the NXOpen.NXObject with the given identifier as recorded in a journal. |
| FlipAlignment | Reverses the constraint alignment if this is possible. |
| GenerateConversionReport | Returns a textual conversion report this constraint from when it was converted from a Mating Constraint to an Assembly Constraint. |
| GetAttributeTitlesByType | Gets all the attribute titles of a specific type. |
| GetBooleanUserAttribute | Gets a boolean attribute by Title and array Index. |
| GetComputationalTimeUserAttribute | Gets a time attribute by Title and array Index. |
| GetConstraintStatus | Returns the solver status of a constraint. |
| GetDisplayedConstraint | Gets the NXOpen.Positioning.DisplayedConstraint that is in the same part as that of the constraint. |
| GetIntegerAttribute | Gets an integer attribute by title. |
| GetIntegerUserAttribute | Gets an integer attribute by Title and array Index. |
| GetNextUserAttribute | Gets the next attribute encountered on the object, if any, that satisfies the given iterator. |
| GetPdmReferenceAttributeValue | Gets the value of PDM Reference attribute for given object. |
| GetRealAttribute | Gets a real attribute by title. |
| GetRealUserAttribute | Gets a real attribute by Title and array Index. |
| GetReferenceAttribute | Gets the reference string (not the calculated value) of a string attribute that uses a reference string. |
| GetReferences | Gets all the :py:class:`NXOpen.Positioning.ConstraintReference`s for the constraint. |
| GetStringAttribute | Gets a string attribute value by title. |
| GetStringUserAttribute | Gets a string attribute by Title and array Index. |
| GetTimeAttribute | Gets a time attribute by title. |
| GetTimeUserAttribute | Gets a time attribute by Title and array Index. |
| GetUserAttribute | Gets the first attribute encountered on the object, if any, with a given Title, Type and array Index. |
| GetUserAttributeAsString | Gets the first attribute encountered on the object, if any, with a given title, type and array index. |
| GetUserAttributeCount | Gets the count of set attributes on the object, if any, that satisfy the given iterator. |
| GetUserAttributeLock | Determine the lock of the given attribute. |
| GetUserAttributeSize | Gets the size of the first attribute encountered on the object, if any, with a given Title and Type. |
| GetUserAttributeSourceObjects | Returns an array of objects from which this object presents attributes. |
| GetUserAttributes | Gets all the attributes that have been set on the given object, if any, that satisfy the given iterator. |
| GetUserAttributesAsStrings | Gets all the attributes that have been set on the given object. |
| HasUserAttribute | Determines if an attribute exists on the object, that satisfies the given iterator |
| Prints a representation of this object to the system log file. | |
| Renew | Changes the constraint to solve with the latest version of the constraint code. |
| ReverseDirection | Reverses the constraint direction. |
| SetAlignmentHint | Set a hint as to which alignment should be used by the solver for this constraint. |
| SetAttribute | Creates or modifies an integer attribute. |
| SetBooleanUserAttribute | Creates or modifies a boolean attribute with the option to update or not. |
| SetExpression | The NXOpen.Expression of a constraint - only for distance or angle constraints. |
| SetName | Sets the custom name of the object. |
| SetPdmReferenceAttribute | Sets the value of PDM Reference attribute on the object. |
| SetReferenceAttribute | Creates or modifies a string attribute which uses a reference string. |
| SetTimeAttribute | Creates or modifies a time attribute. |
| SetTimeUserAttribute | Creates or modifies a time attribute with the option to update or not. |
| SetUserAttribute | Creates or modifies an attribute with the option to update or not. |
| SetUserAttributeLock | Lock or unlock the given attribute. |
Enumerations¶
| ConstraintAlignment Enumeration | Specifies alignment of directed geometries used in a constraint. |
| ConstraintSolverStatus Enumeration | Specifies the status of a constraint. |
| ConstraintSplineType Enumeration | Specifies how the spline points define the shape of the spline. |
| ConstraintType Enumeration | Specifies the type of a constraint. |
Property Detail¶
Automatic¶
-
Constraint.Automatic¶ Returns or sets the flag marking the constraint as an “automatic” constraint.
Automatic constraints are constraints created by the system, but are visible and editable by the user. Automatic constraints are automatically deleted when one of the referenced objects are deleted by update.
-------------------------------------Getter Method
Signature
AutomaticReturns: The automatic state Return type: bool New in version NX5.0.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
-------------------------------------Setter Method
Signature
AutomaticParameters: isauto (bool) – The automatic state New in version NX5.0.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
ConstraintAlignment¶
-
Constraint.ConstraintAlignment¶ Returns or sets the alignment behavior for the constraint.
-------------------------------------Getter Method
Signature
ConstraintAlignmentReturns: Alignment behavior for constraint Return type: NXOpen.Positioning.ConstraintAlignmentNew in version NX4.0.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
-------------------------------------Setter Method
Signature
ConstraintAlignmentParameters: alignment ( NXOpen.Positioning.ConstraintAlignment) – Alignment behavior for constraintNew in version NX4.0.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
ConstraintType¶
-
Constraint.ConstraintType¶ Returns or sets the constraint type.
-------------------------------------Getter Method
Signature
ConstraintTypeReturns: Return type: NXOpen.Positioning.ConstraintTypeNew in version NX4.0.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
-------------------------------------Setter Method
Signature
ConstraintTypeParameters: constraintType ( NXOpen.Positioning.ConstraintType) –New in version NX4.0.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
Expression¶
-
Constraint.Expression¶ Returns the
NXOpen.Expressionof a constraint.The expression will be unused unless this constraint type supports an expression, such as a distance or angle constraint.
-------------------------------------Getter Method
Signature
ExpressionReturns: Expression used in the constraint Return type: NXOpen.ExpressionNew in version NX4.0.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
ExpressionDriven¶
-
Constraint.ExpressionDriven¶ Returns or sets the driven state of the expression of a constraint.
The value of a driven expression can change. Driven expression values are controlled by the solver and cannot be edited by the user. Only distance and angle constraints can have their expression made driven.
-------------------------------------Getter Method
Signature
ExpressionDrivenReturns: Whether or not the expression is driven. Return type: bool New in version NX11.0.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
-------------------------------------Setter Method
Signature
ExpressionDrivenParameters: expressionDriven (bool) – Whether or not the expression is driven. New in version NX11.0.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
IsOccurrence¶
-
Constraint.IsOccurrence¶ Returns whether this object is an occurrence or not.
-------------------------------------Getter Method
Signature
IsOccurrenceReturns: This object is an occurrence Return type: bool New in version NX3.0.0.
License requirements: None.
JournalIdentifier¶
-
Constraint.JournalIdentifier¶ Returns the identifier that would be recorded in a journal for this object.
This may not be the same across different releases of the software.
-------------------------------------Getter Method
Signature
JournalIdentifierReturns: Return type: str New in version NX3.0.0.
License requirements: None.
LowerLimitEnabled¶
-
Constraint.LowerLimitEnabled¶ Returns or sets the lower limit of the expression of a constraint.
The limit expression will only be used for constraint types that can have their expression made driven.
-------------------------------------Getter Method
Signature
LowerLimitEnabledReturns: Return if the constraint has a lower limit of the expression enabled Return type: bool New in version NX11.0.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
-------------------------------------Setter Method
Signature
LowerLimitEnabledParameters: hasLimit (bool) – Whether or not the lower limit of the expression is enabled. New in version NX11.0.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
LowerLimitExpression¶
-
Constraint.LowerLimitExpression¶ Returns the lower limit of the expression of a constraint.
The limit expression will only be used for certain constraint types, and they must have an expression.
-------------------------------------Getter Method
Signature
LowerLimitExpressionReturns: Return the lower limit of the expression. Return type: NXOpen.ExpressionNew in version NX11.0.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
LowerLimitRightHandSide¶
-
Constraint.LowerLimitRightHandSide¶ Returns or sets the lower limit of the expression right hand side of a constraint.
The limit expression will only be used for certain constraint types, and they must have an expression.
-------------------------------------Getter Method
Signature
LowerLimitRightHandSideReturns: Return the lower limit right hand side of the expression. Return type: str New in version NX11.0.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
-------------------------------------Setter Method
Signature
LowerLimitRightHandSideParameters: limitRightHandSide (str) – The expression to be applied to the lower limit of the expression. New in version NX11.0.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
Name¶
-
Constraint.Name¶ Returns the custom name of the object.
-------------------------------------Getter Method
Signature
NameReturns: Return type: str New in version NX3.0.0.
License requirements: None.
OwningComponent¶
-
Constraint.OwningComponent¶ Returns the owning component, if this object is an occurrence.
-------------------------------------Getter Method
Signature
OwningComponentReturns: Return type: NXOpen.Assemblies.ComponentNew in version NX3.0.0.
License requirements: None.
OwningPart¶
-
Constraint.OwningPart¶ Returns the owning part of this object
-------------------------------------Getter Method
Signature
OwningPartReturns: The owning part of this object or null if it does not have an owner Return type: NXOpen.BasePartNew in version NX3.0.0.
License requirements: None.
Persistent¶
-
Constraint.Persistent¶ Returns or sets the persistent state of the constraint.
-------------------------------------Getter Method
Signature
PersistentReturns: The persistent state Return type: bool New in version NX4.0.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
-------------------------------------Setter Method
Signature
PersistentParameters: persistent (bool) – The persistent state New in version NX4.0.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
Prototype¶
-
Constraint.Prototype¶ Returns the prototype of this object if it is an occurrence.
-------------------------------------Getter Method
Signature
PrototypeReturns: The prototype of this object or null if this object is not an occurrence Return type: NXOpen.INXObjectNew in version NX3.0.0.
License requirements: None.
SplinePointsType¶
-
Constraint.SplinePointsType¶ Returns or sets the type of the spline.
Only valid if the type of the constraint is set to
NXOpen.Positioning.ConstraintType.SplineData.-------------------------------------Getter Method
Signature
SplinePointsTypeReturns: Return type: NXOpen.Positioning.ConstraintSplineTypeNew in version NX6.0.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
-------------------------------------Setter Method
Signature
SplinePointsTypeParameters: splineType ( NXOpen.Positioning.ConstraintSplineType) –New in version NX6.0.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
Suppressed¶
-
Constraint.Suppressed¶ Returns or sets the suppression state for the constraint.
In a
NXOpen.Positioning.ComponentConstraintthis is the state in theNXOpen.Positioning.ComponentPositioner.PrimaryArrangement`().”-------------------------------------Getter Method
Signature
SuppressedReturns: The suppression state Return type: bool New in version NX4.0.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
-------------------------------------Setter Method
Signature
SuppressedParameters: suppressed (bool) – The suppression state New in version NX4.0.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
UpperLimitEnabled¶
-
Constraint.UpperLimitEnabled¶ Returns or sets the upper limit of the expression of a constraint.
The limit expression will only be used for constraint types that can have their expression made driven.
-------------------------------------Getter Method
Signature
UpperLimitEnabledReturns: Return if the constraint has an upper limit of the expression enabled Return type: bool New in version NX11.0.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
-------------------------------------Setter Method
Signature
UpperLimitEnabledParameters: hasLimit (bool) – Whether or not the upper limit of the expression is enabled. New in version NX11.0.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
UpperLimitExpression¶
-
Constraint.UpperLimitExpression¶ Returns the upper limit of the expression of a constraint.
The limit expression will only be used for certain constraint types, and they must have an expression.
-------------------------------------Getter Method
Signature
UpperLimitExpressionReturns: Return the upper limit of the expression. Return type: NXOpen.ExpressionNew in version NX11.0.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
UpperLimitRightHandSide¶
-
Constraint.UpperLimitRightHandSide¶ Returns or sets the upper limit of the expression right hand side of a constraint.
The limit expression will only be used for certain constraint types, and they must have an expression.
-------------------------------------Getter Method
Signature
UpperLimitRightHandSideReturns: Return the upper limit right hand side of the expression. Return type: str New in version NX11.0.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
-------------------------------------Setter Method
Signature
UpperLimitRightHandSideParameters: limitRightHandSide (str) – The expression to be applied to the upper limit of the expression. New in version NX11.0.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
Method Detail¶
CreateConstraintReference¶
-
Constraint.CreateConstraintReference¶ Overloaded method CreateConstraintReference
CreateConstraintReference(movableObject, geometry, usesAxis, isIndirect)CreateConstraintReference(movableObject, geometry, usesAxis, isIndirect, usePortRotate)
-------------------------------------Adds geometry to a constraint and sets the movable object to be constrained.
Signature
CreateConstraintReference(movableObject, geometry, usesAxis, isIndirect)Parameters: - movableObject (
NXOpen.NXObject) – Object to be positioned by constraint - geometry (
NXOpen.NXObject) – Geometry used to define constraint - usesAxis (bool) – Use axis of geometry
- isIndirect (bool) – Geometry is to be used indirectly to identify geometry in another part
Returns: Return type: New in version NX4.0.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
-------------------------------------Adds geometry to a constraint and sets the movable object to be constrained.
Signature
CreateConstraintReference(movableObject, geometry, usesAxis, isIndirect, usePortRotate)Parameters: - movableObject (
NXOpen.NXObject) – Object to be positioned by constraint - geometry (
NXOpen.NXObject) – Geometry used to define constraint - usesAxis (bool) – Use axis of geometry
- isIndirect (bool) – Geometry is to be used indirectly to identify geometry in another part
- usePortRotate (bool) – Use rotate vector of
NXOpen.Routing.Port.
Returns: Return type: New in version NX4.0.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
-------------------------------------
DeleteConstraintReference¶
-
Constraint.DeleteConstraintReference¶ Removes a
NXOpen.Positioning.ConstraintReferencefrom the constraint.Signature
DeleteConstraintReference(constraintReference)Parameters: constraintReference ( NXOpen.Positioning.ConstraintReference) – The constraint reference to remove. A list of references can be obtained viaNXOpen.Positioning.Constraint.GetReferences().New in version NX4.0.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
EditConstraintReference¶
-
Constraint.EditConstraintReference¶ Adds geometry to a constraint and sets the movable object to be constrained, replacing the properties of an existing reference of the constraint.
Signature
EditConstraintReference(constraintReference, movableObject, geometry, usesAxis, isIndirect, usePortRotate)Parameters: - constraintReference (
NXOpen.Positioning.ConstraintReference) – TheNXOpen.Positioning.ConstraintReferencewhose properties are to be changed - movableObject (
NXOpen.NXObject) – Object to be positioned by constraint - geometry (
NXOpen.NXObject) – Geometry used to define constraint - usesAxis (bool) – Use axis of geometry
- isIndirect (bool) – Geometry is to be used indirectly to identify geometry in another part
- usePortRotate (bool) – Use rotate vector of
NXOpen.Routing.Port.
New in version NX5.0.1.
License requirements: assemblies (“ASSEMBLIES MODULE”)
- constraintReference (
FindObject¶
-
Constraint.FindObject¶ Finds the
NXOpen.NXObjectwith the given identifier as recorded in a journal.An object may not return the same value as its JournalIdentifier in different versions of the software. However newer versions of the software should find the same object when FindObject is passed older versions of its journal identifier. In general, this method should not be used in handwritten code and exists to support record and playback of journals.
An exception will be thrown if no object can be found with the given journal identifier.
Signature
FindObject(journalIdentifier)Parameters: journalIdentifier (str) – Journal identifier of the object Returns: Return type: NXOpen.INXObjectNew in version NX3.0.0.
License requirements: None.
FlipAlignment¶
-
Constraint.FlipAlignment¶ Reverses the constraint alignment if this is possible.
Signature
FlipAlignment()New in version NX4.0.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
GenerateConversionReport¶
-
Constraint.GenerateConversionReport¶ Returns a textual conversion report this constraint from when it was converted from a Mating Constraint to an Assembly Constraint.
If this isn’t a converted constraint or there were no problems converting this constraint, then an empty string is returned.
Signature
GenerateConversionReport()Returns: The text lines of the conversion report Return type: list of str New in version NX5.0.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
GetConstraintStatus¶
-
Constraint.GetConstraintStatus¶ Returns the solver status of a constraint.
Signature
GetConstraintStatus()Returns: The solver status of the constraint Return type: NXOpen.Positioning.ConstraintSolverStatusNew in version NX4.0.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
GetDisplayedConstraint¶
-
Constraint.GetDisplayedConstraint¶ Gets the
NXOpen.Positioning.DisplayedConstraintthat is in the same part as that of the constraint.Note that this will be None if the part has not been the displayed part since the constraint was created.
Signature
GetDisplayedConstraint()Returns: Return type: NXOpen.Positioning.DisplayedConstraintNew in version NX7.5.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
GetReferences¶
-
Constraint.GetReferences¶ Gets all the :py:class:`NXOpen.Positioning.ConstraintReference`s for the constraint.
Signature
GetReferences()Returns: ConstraintReferences used by this constraint Return type: list of NXOpen.Positioning.ConstraintReferenceNew in version NX4.0.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
Print¶
-
Constraint.Print¶ Prints a representation of this object to the system log file.
Signature
Print()New in version NX3.0.0.
License requirements: None.
Renew¶
-
Constraint.Renew¶ Changes the constraint to solve with the latest version of the constraint code.
Signature
Renew()New in version NX11.0.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
ReverseDirection¶
-
Constraint.ReverseDirection¶ Reverses the constraint direction.
This operation reverses the
NXOpen.Positioning.ConstraintReference.Order()on eachNXOpen.Positioning.ConstraintReference. So “Inside” becomes “Outside”, “Outside” becomes “Inside” and “Unknown” remains as it is.Signature
ReverseDirection()New in version NX5.0.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
SetAlignmentHint¶
-
Constraint.SetAlignmentHint¶ Set a hint as to which alignment should be used by the solver for this constraint.
If the constraint does not solve using this alignment then the hint will be ignored.
The hint can only have an effect when the alignment of [version_created(“4”)] the constraint, as returned by
NXOpen.Positioning.Constraint.ConstraintAlignment(), isNXOpen.Positioning.ConstraintAlignment.InferAlign.The hint can only have an effect when the constraint has been explicitly added to a
NXOpen.Positioning.Network.Passing in
NXOpen.Positioning.ConstraintAlignment.InferAlignas the alignment argument will have no effect.The hint is forgotten after an update.
Signature
SetAlignmentHint(alignment)Parameters: alignment ( NXOpen.Positioning.ConstraintAlignment) – The alignment hintNew in version NX4.0.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
SetExpression¶
-
Constraint.SetExpression¶ The
NXOpen.Expressionof a constraint - only for distance or angle constraints.Signature
SetExpression(expression)Parameters: expression (str) – Name of expression used in the constraint New in version NX4.0.0.
License requirements: assemblies (“ASSEMBLIES MODULE”)
SetName¶
-
Constraint.SetName¶ Sets the custom name of the object.
NOTE: This method should not be used to edit a read-only object such as a Mirrored PMI object. If it is, the changes will be overridden when the part is updated.
Signature
SetName(name)Parameters: name (str) – New in version NX3.0.0.
License requirements: None.