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!

next page in drafting

Status
Not open for further replies.

fzvnpg

New member
Aug 6, 2002
70
0
0
US
Create or use grip to automaticly go to next page in drafting without using either pull down or selecting it in part navigator... I have seen one at another location but can not find the way they did it and I am no longer at that location

Cj Silver
Tooling Engineer BAE Systems
Working to remember all I forgotten
 
Replies continue below

Recommended for you

Does it have to be GRIP?
Below is a journal that should switch to the next drawing sheet (by sheet number).

Code:
Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen

Module Module1

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

    Sub Main()

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

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

        Dim currentApplication As Integer
        theUfSession.UF.AskApplicationModule(currentApplication)
        If currentApplication <> UF.UFConstants.UF_APP_DRAFTING Then
            lw.WriteLine("must be in the drafting application")
            Return
        End If

        Const undoMarkName As String = "next drawing page"
        Dim markId1 As Session.UndoMarkId
        markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)

        Dim drawingDic As New Dictionary(Of Integer, Drawings.DrawingSheet)
        For Each dwgSheet As Drawings.DrawingSheet In workPart.DrawingSheets
            drawingDic.Add(SheetNumber(dwgSheet), dwgSheet)
        Next

        Dim totalSheets As Integer = workPart.DrawingSheets.ToArray.Length
        'lw.WriteLine("number of drawing sheets: " & totalSheets.ToString)

        Dim curSheetNumber As Integer = SheetNumber(workPart.DrawingSheets.CurrentDrawingSheet)
        'lw.WriteLine("current sheet: " & curSheetNumber.ToString)

        'For Each kvp As KeyValuePair(Of Integer, Drawings.DrawingSheet) In drawingDic
        '    lw.WriteLine("sheet number: " & kvp.Key.ToString & " name: " & kvp.Value.Name)
        'Next

        Dim newSheetNum As Integer = curSheetNumber + 1
        If newSheetNum > totalSheets Then
            newSheetNum = 1
        End If

        Dim newSheet As Drawings.DrawingSheet
        If drawingDic.TryGetValue(newSheetNum, newSheet) Then
            newSheet.Open()
        Else
            'sheet not found
            lw.WriteLine("error: sheet not found")
        End If

        lw.Close()

    End Sub

    Function SheetNumber(ByVal theSheet As Drawings.DrawingSheet) As Integer

        Dim sheetNum As Integer
        Dim theSheetBuilder As Drawings.DrawingSheetBuilder = theSession.Parts.Work.DrawingSheets.DrawingSheetBuilder(theSheet)
        sheetNum = theSheetBuilder.Number

        theSheetBuilder.Destroy()

        Return sheetNum

    End Function

End Module

www.nxjournaling.com
 
EXCELLENT, but not sure how to use that code, How do I use it?

Cj Silver
Tooling Engineer BAE Systems
Working to remember all I forgotten
 
Copy the text into notepad. Change the .txt extension to .vb.
In Nx goto tools - journal - play (or ALT+F8)browse to the .vb file and run. You can make a shortcut for this by customising a toolbar.

Best regards,

Michaël.

NX7.5.4.4 (NX8.5.3) + TC Unified 8.3
Win 7 64 bit



 
Status
Not open for further replies.
Back
Top