Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

NXOpen AssemblyConstraint question

Status
Not open for further replies.

MANox

Mechanical
Apr 2, 2007
121
Hello everyone,

I try write journal for flip direction of concentric constraints (many in one operation).
I have problem and I can't find solution.

I can select constraints as "NXOpen.Positioning.DisplayedConstraint".
For flip operation I need type "NXOpen.Positioning.ComponentConstraint"

Maybe somebody have idea for change NXOpen.Positioning.DisplayedConstraint to NXOpen.Positioning.ComponentConstraint.

Operation:
Code:
componentConstraint1 = CType(displayedconst, NXOpen.Positioning.ComponentConstraint)
don't work [dazed]

Best regards

MANok
NX12
TC10
 
Replies continue below

Recommended for you

The .DisplayConstraint is the graphical representation of the constraint; it has a .GetConstraint method that will return the positioning.constraint that can be cast to a component constraint.

www.nxjournaling.com
 
Many thanks cowski, You are Great.

If somebody need journal for Flip Alignment of selected constraints, here it is:

Code:
'Journal create by MANok 03.02.2021
'Journal Flip Alignement of selected constraints

Imports System
Imports NXOpen
Imports NXOpen.UF

Module Reverse_const
    Sub Main(ByVal args() As String)

        Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
        Dim workPart As NXOpen.Part = theSession.Parts.Work
        Dim displayPart As NXOpen.Part = theSession.Parts.Display

        Dim componentConstraint() As NXOpen.Positioning.ComponentConstraint

        If (SelectConstraints(componentConstraint)) = Selection.Response.Cancel Then
            Exit Sub
        ElseIf IsNothing(componentConstraint) Then
            Exit Sub
        End If

        For i As Integer = 0 To componentConstraint.Length - 1
            componentConstraint(i).FlipAlignment()
        Next

    End Sub

    Function SelectConstraints(ByRef componentConstraint1() As NXOpen.Positioning.ComponentConstraint) As Selection.Response

        Dim theUI As UI = UI.GetUI
        Dim title As String = "Select a constraint"
        Dim includeFeatures As Boolean = False
        Dim keepHighlighted As Boolean = False
        Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
        Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart
        Dim selectionMask_array(0) As Selection.MaskTriple
        Dim prompt As String = "Select constraint"
        Dim selObj() As TaggedObject

        With selectionMask_array(0)
            .Type = UFConstants.UF_constraint_type
            .Subtype = UFConstants.UF_constraint_subtype
        End With


        Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObjects(prompt, title, scope, selAction, includeFeatures, keepHighlighted, selectionMask_array, selObj)
        If resp = Selection.Response.ObjectSelected OrElse resp = Selection.Response.ObjectSelectedByName OrElse Selection.Response.Ok Then
            Dim i As Integer = 0
            For Each element As TaggedObject In selObj
                Dim dispconst As NXOpen.Positioning.DisplayedConstraint = Utilities.NXObjectManager.Get(element.Tag)
                ReDim Preserve componentConstraint1(i)
                componentConstraint1(i) = dispconst.GetConstraint
                i = i + 1
            Next
            Return Selection.Response.Ok
        Else
            Return Selection.Response.Cancel
        End If

    End Function

End Module

Best regards

MANok
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor