Cancel
Showing results for 
Search instead for 
Did you mean: 

Create a Journal to move Partslist to a specified Point

Builder
Builder

I want to create a journal to move Partslist to a specified point in the sheet and to resize coloumns width. But it seems to be impossible because NXOpen doesn't support these features.

I don't know if there is a way to aoutomate this change in my drawings

Sina shojaee
5 REPLIES

Re: Create a Journal to move Partslist to a specified Point

Honored Contributor
Honored Contributor

What version of NX are you working with?

Re: Create a Journal to move Partslist to a specified Point

Builder
Builder

Excuse me

We are using NX 9

Sina shojaee

Re: Create a Journal to move Partslist to a specified Point

Honored Contributor
Honored Contributor

A parts list is just a special type of tabular note. You can use the tabular note functions to resize the width of the columns. The code below will double the width of the first column in each parts list.

 

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module Module1

    Dim theSession As Session = Session.GetSession()
    Dim theUfSession As UFSession = UFSession.GetUFSession()

    Sub Main()

        If IsNothing(theSession.Parts.BaseWork) Then
            'active part required
            Return
        End If

        Dim workPart As Part = theSession.Parts.Work
        Dim lw As ListingWindow = theSession.ListingWindow
        lw.Open()

        Const undoMarkName As String = "edit parts list column width"
        Dim markId1 As Session.UndoMarkId
        markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)

        Dim partsListTags() As Tag
        Dim numPartsLists As Integer

        theUfSession.Plist.AskTags(partsListTags, numPartsLists)

        If numPartsLists = 0 Then
            lw.WriteLine("No parts lists found in work part, exiting")
            Return
        End If

        'change the width of the first column in each parts list found
        For Each temp As Tag In partsListTags
            Dim columnTag As Tag = Tag.Null
            theUfSession.Tabnot.AskNthColumn(temp, 0, columnTag)

            Dim columnWidth As Double
            theUfSession.Tabnot.AskColumnWidth(columnTag, columnWidth)

            theUfSession.Tabnot.SetColumnWidth(columnTag, columnWidth * 2)
        Next

        lw.Close()

    End Sub


    Public Function GetUnloadOption(ByVal dummy As String) As Integer

        'Unloads the image immediately after execution within NX
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

    End Function

End Module

As for moving the parts list, you should be able to record a journal while using the "move object" command to get a good start on how to move the parts list.

Re: Create a Journal to move Partslist to a specified Point

Builder
Builder

Thankyou Cowski1.

I was making Journal to resize rows and columns and as Journal recorder didn't make anything valuble I thought there is no solution.

 

I changed your code to resize the first row of parts list but when I Run it, NX change the second row. Could you please help me again?

Sina shojaee

Re: Create a Journal to move Partslist to a specified Point

Honored Contributor
Honored Contributor

I assume you want to change the height of the header row. Depending on your table's row "autosize" settings, the following code should do the trick:

 

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module Module2

    Dim theSession As Session = Session.GetSession()
    Dim theUfSession As UFSession = UFSession.GetUFSession()

    Sub Main()

        If IsNothing(theSession.Parts.BaseWork) Then
            'active part required
            Return
        End If

        Dim workPart As Part = theSession.Parts.Work
        Dim lw As ListingWindow = theSession.ListingWindow
        lw.Open()

        Const undoMarkName As String = "edit parts list row height"
        Dim markId1 As Session.UndoMarkId
        markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)

        Dim partsListTags() As Tag
        Dim numPartsLists As Integer

        theUfSession.Plist.AskTags(partsListTags, numPartsLists)

        If numPartsLists = 0 Then
            lw.WriteLine("No parts lists found in work part, exiting")
            Return
        End If

        'change the row height of the header rows
        For Each temp As Tag In partsListTags

            Dim numHeaderRows As Integer
            theUfSession.Tabnot.AskNmHeaderRows(temp, numHeaderRows)

            For i As Integer = 0 To numHeaderRows - 1
                Dim headerRowTag As Tag
                theUfSession.Tabnot.AskNthHeaderRow(temp, i, headerRowTag)

                Dim rowHeight As Double
                theUfSession.Tabnot.AskRowHeight(headerRowTag, rowHeight)

                'double the row height
                theUfSession.Tabnot.SetRowHeight(headerRowTag, rowHeight * 2)

            Next

        Next

        lw.Close()

    End Sub


    Public Function GetUnloadOption(ByVal dummy As String) As Integer

        'Unloads the image immediately after execution within NX
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

    End Function

End Module