Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

control of arrangements

Status
Not open for further replies.

multicaduser

Industrial
Jan 29, 2013
261
0
16
US
I'm pretty comfortable with arrangements in assemblies and sub-assemblies, all done by manually choosing the active arrangement. Searches haven't come up with anything so I'm asking if anyone knows if it is possible to choose the active arrangement with a part attribute or expression. Thanks in advance for any feedback.

NX 1899 Windows 10
 
Replies continue below

Recommended for you

Hi jerry1423, thanks for the link. However, the position in arrangements is easy, choosing an arrangement is with a journal, expression or part attribute is what I'm after. There are several examples of reporting arrangements available, etc., not quite what I'm looking for.

NX 1899 Windows 10
 
Controlling the current arrangement with an expression is not possible (at least up through NX 12). I'm pretty sure that such functionality has been requested. It might be in a newer version; if not, you can contact GTAC and open an enhancement request (or add your vote to an existing one).

Changing the arrangement with a journal is certainly possible, though.

www.nxjournaling.com
 
Ok, there are several visual basic programs out there that will read the current arrangement and that helps because it shows the command for reading, but how do you set an arrangement active. I apologize because I have no access to programming tools and don't really know where to find commands except existing programs.

NX 1899 Windows 10
 
I had some time today to create an example. The code below will report the current arrangement of the current work part then it will report the available arrangements and change the arrangement to the first one found that isn't the current one.

Code:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Assemblies

Module Module2

    Sub Main()

        Dim theSession As Session = Session.GetSession()
        If IsNothing(theSession.Parts.Work) Then
            'active part required
            Return
        End If

        Dim lw As ListingWindow = theSession.ListingWindow
        lw.Open()

        Const undoMarkName As String = "NXJ journal"
        Dim markId1 As Session.UndoMarkId
        markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)

        lw.WriteLine("current arrangement: " & theSession.Parts.Work.ComponentAssembly.ActiveArrangement.Name)
        lw.WriteLine("")

        lw.WriteLine("available arrangements")

        Dim changed As Boolean = False
        For Each tempArr As Arrangement In theSession.Parts.Work.ComponentAssembly.Arrangements
            lw.WriteLine("  " & tempArr.Name)
            If Not changed Then
                If Not tempArr.Equals(theSession.Parts.Work.ComponentAssembly.ActiveArrangement) Then
                    theSession.Parts.Work.ComponentAssembly.ActiveArrangement = tempArr
                    changed = True
                End If
            End If
        Next

        lw.WriteLine("")
        lw.WriteLine("arrangement changed to: " & theSession.Parts.Work.ComponentAssembly.ActiveArrangement.Name)

        lw.Close()

    End Sub


    Public Function GetUnloadOption(ByVal dummy As String) As Integer

        'Unloads the image when the NX session terminates
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

    End Function

End Module

www.nxjournaling.com
 
Status
Not open for further replies.
Back
Top