Constraint Class

class NXOpen.Positioning.Constraint

Bases: NXOpen.NXObject

Constraint for use in positioning objects in NX.

For constraints between components, the subclass NXOpen.Positioning.ComponentConstraint should be used by preference.

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 expression used for 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.
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.

Methods

Method Description
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 encountered with the given Type with option to update or not.
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.
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, of the given type.
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.
GetUserAttributesAsStrings Gets all the attributes that have been set on the given object.
HasUserAttribute Determines if an attribute with the given Title, Type and array Index is present on the object Unset attributes will not be detected by this function, as its purpose is to test for the actual presence of the attribute on the object.
Print Prints a representation of this object to the system log file.
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 expression used for constraint - only for distance or angle
SetName Sets the custom name of 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 Automatic()

Returns:The automatic state
Return type:bool

New in version NX5.0.0.

License requirements: assemblies (“ASSEMBLIES MODULE”)

-------------------------------------

Setter Method

Signature Automatic(isauto)

Parameters: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 ConstraintAlignment()

Returns:Alignment behavior for constraint
Return type:NXOpen.Positioning.ConstraintAlignment

New in version NX4.0.0.

License requirements: assemblies (“ASSEMBLIES MODULE”)

-------------------------------------

Setter Method

Signature ConstraintAlignment(alignment)

Parameters:alignment (NXOpen.Positioning.ConstraintAlignment) – Alignment behavior for constraint

New in version NX4.0.0.

License requirements: assemblies (“ASSEMBLIES MODULE”)

ConstraintType

Constraint.ConstraintType

Returns or sets the constraint type.

-------------------------------------

Getter Method

Signature ConstraintType()

Returns:
Return type:NXOpen.Positioning.ConstraintType

New in version NX4.0.0.

License requirements: assemblies (“ASSEMBLIES MODULE”)

-------------------------------------

Setter Method

Signature ConstraintType(constraintType)

Parameters:constraintType (NXOpen.Positioning.ConstraintType) –

New in version NX4.0.0.

License requirements: assemblies (“ASSEMBLIES MODULE”)

Expression

Constraint.Expression

Returns the expression used for constraint.

The expression will be unused unless this constraint has type distance or angle.

-------------------------------------

Getter Method

Signature Expression()

Returns:Expression used in distance or angle constraint
Return type:NXOpen.Expression

New in version NX4.0.0.

License requirements: assemblies (“ASSEMBLIES MODULE”)

IsOccurrence

Constraint.IsOccurrence

Returns whether this object is an occurrence or not.

-------------------------------------

Getter Method

Signature IsOccurrence()

Returns: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 JournalIdentifier()

Returns:
Return type:str

New in version NX3.0.0.

License requirements: None.

Name

Constraint.Name

Returns the custom name of the object.

-------------------------------------

Getter Method

Signature Name()

Returns:
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 OwningComponent()

Returns:
Return type:NXOpen.Assemblies.Component

New in version NX3.0.0.

License requirements: None.

OwningPart

Constraint.OwningPart

Returns the owning part of this object

-------------------------------------

Getter Method

Signature OwningPart()

Returns:The owning part of this object or null if it does not have an owner
Return type:NXOpen.BasePart

New in version NX3.0.0.

License requirements: None.

Persistent

Constraint.Persistent

Returns or sets the persistent state of the constraint.

-------------------------------------

Getter Method

Signature Persistent()

Returns:The persistent state
Return type:bool

New in version NX4.0.0.

License requirements: assemblies (“ASSEMBLIES MODULE”)

-------------------------------------

Setter Method

Signature Persistent(persistent)

Parameters: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 Prototype()

Returns:The prototype of this object or null if this object is not an occurrence
Return type:NXOpen.INXObject

New 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 SplinePointsType()

Returns:
Return type:NXOpen.Positioning.ConstraintSplineType

New in version NX6.0.0.

License requirements: assemblies (“ASSEMBLIES MODULE”)

-------------------------------------

Setter Method

Signature SplinePointsType(splineType)

Parameters: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.ComponentConstraint this is the state in the NXOpen.Positioning.ComponentPositioner.PrimaryArrangement`.”

-------------------------------------

Getter Method

Signature Suppressed()

Returns:The suppression state
Return type:bool

New in version NX4.0.0.

License requirements: assemblies (“ASSEMBLIES MODULE”)

-------------------------------------

Setter Method

Signature Suppressed(suppressed)

Parameters:suppressed (bool) – The suppression state

New in version NX4.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:

The new NXOpen.Positioning.ConstraintReference

Return type:

NXOpen.Positioning.ConstraintReference

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:

The new NXOpen.Positioning.ConstraintReference

Return type:

NXOpen.Positioning.ConstraintReference

New in version NX4.0.0.

License requirements: assemblies (“ASSEMBLIES MODULE”)

-------------------------------------

DeleteConstraintReference

Constraint.DeleteConstraintReference

Removes a NXOpen.Positioning.ConstraintReference from the constraint.

Signature DeleteConstraintReference(constraintReference)

Parameters:constraintReference (NXOpen.Positioning.ConstraintReference) – The constraint reference to remove. A list of references can be obtained via NXOpen.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:

New in version NX5.0.1.

License requirements: assemblies (“ASSEMBLIES MODULE”)

FindObject

Constraint.FindObject

Finds the NXOpen.NXObject with 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.INXObject

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

New in version NX4.0.0.

License requirements: assemblies (“ASSEMBLIES MODULE”)

GetDisplayedConstraint

Constraint.GetDisplayedConstraint

Gets the NXOpen.Positioning.DisplayedConstraint that 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.DisplayedConstraint

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

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

ReverseDirection

Constraint.ReverseDirection

Reverses the constraint direction.

This operation reverses the NXOpen.Positioning.ConstraintReference.Order on each NXOpen.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, is NXOpen.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.InferAlign as the alignment argument will have no effect.

The hint is forgotten after an update.

Signature SetAlignmentHint(alignment)

Parameters:alignment (NXOpen.Positioning.ConstraintAlignment) – The alignment hint

New in version NX4.0.0.

License requirements: assemblies (“ASSEMBLIES MODULE”)

SetExpression

Constraint.SetExpression

The expression used for constraint - only for distance or angle

Signature SetExpression(expression)

Parameters:expression (str) – Name of expression used in distance or angle constraint NOTE: The full Unicode character set is not supported for this parameter.

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.