Showing results for 
Search instead for 
Do you mean 
Reply

Hide/Show journal

' NX 5.0.1.4
' Journal created by cohon on Wed Aug 01 21:31:27 2007 Central Daylight Time
'
Option Strict Off
Imports System
Imports NXOpen

Module NXJournal
Sub Main

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

Dim displayPart As Part = theSession.Parts.Display

' ----------------------------------------------
'   Menu: Fit
' ----------------------------------------------
workPart.ModelingViews.WorkView.Fit()

' ----------------------------------------------
'   Menu: Edit->Show and Hide->Show and Hide...
' ----------------------------------------------
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")

theSession.SetUndoMarkName(markId1, "Show and Hide")

theSession.SetUndoMarkVisibility(markId1, Nothing, Session.MarkVisibility.Invisible)

Dim markId2 As Session.UndoMarkId
markId2 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Hide Sketches")

Dim numberHidden1 As Integer
numberHidden1 = theSession.DisplayManager.HideByType(DisplayManager.ShowHideType.Sketches, DisplayManager.ShowHideScope.AnyInAssembly)

Dim markId3 As Session.UndoMarkId
markId3 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Hide Curves")

Dim numberHidden2 As Integer
numberHidden2 = theSession.DisplayManager.HideByType(DisplayManager.ShowHideType.Curves, DisplayManager.ShowHideScope.AnyInAssembly)

Dim markId4 As Session.UndoMarkId
markId4 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Hide Datums")

Dim numberHidden3 As Integer
numberHidden3 = theSession.DisplayManager.HideByType(DisplayManager.ShowHideType.Datums, DisplayManager.ShowHideScope.AnyInAssembly)

' ----------------------------------------------
'   Menu: Fit
' ----------------------------------------------
workPart.ModelingViews.WorkView.Fit()

' ----------------------------------------------
'   Menu: Tools->Journal->Stop
' ----------------------------------------------

End Sub
End Module

I've been using this journal for many years now. Is there a way to edit it so it doesn't "Hide" specific entities so long are Named?

 

Example, I name saved CSYS and/or Datum CSYS for my machining coordinate systems. I do not machine in NX, but my CAM system brings in NX CSYS's and if they're named they are easier to pick out on the list. I also tend to make lines on the csys and label those X,Y,Z.

 

But when I run the Hide construction geometry journal it hides everything except sheets and solids.

Rob Newcomb, CAD/CNC/Simulation manager
Elmhirst Industries, Specializing in Prototype sheet metal stampings and assemblies

Production: NX 11.0.2.7 / Autoform r7 /WorkNC 2017 r2
Testing:NX12 EAP
PC: Rave Cadbeast: Intel(R) i7-4790K CPU @ 4.GHz /32gb ram /NVIDIA Quadro K2200 on Win10 Pro
7 REPLIES

Re: Hide/Show journal

So if a saved csys or curve is named, you want it to be shown; is this correct? Are you working with an individual part file or is this an assembly (in other words, what file owns the csys objects and curves that you want to show, the display part? or perhaps you need to display every named csys and curve in every component?)

 

Also, what is your current version of NX?

Re: Hide/Show journal

[ Edited ]

When I Run the Hide construction geometry journal, I would like to Hide all of the displayed construction geometry with the exception of those that are named via user defined Name.

 

for example I right click on a saved WCS, go down to properties and under the General tab. Name the saved WCS Die Tip.

I then run the hide all construction geometry journal, it hides all my datums,curves , sketches and other CSYS with the exception of the one I named.

Rob Newcomb, CAD/CNC/Simulation manager
Elmhirst Industries, Specializing in Prototype sheet metal stampings and assemblies

Production: NX 11.0.2.7 / Autoform r7 /WorkNC 2017 r2
Testing:NX12 EAP
PC: Rave Cadbeast: Intel(R) i7-4790K CPU @ 4.GHz /32gb ram /NVIDIA Quadro K2200 on Win10 Pro

Re: Hide/Show journal

The following code will unblank all of the named coordinate systems and curves in the current work part. I'm not sure this is quite what you want; any named objects in other component files will not show up. Also, this code will not change the layer visibility; if the layer of a named object is invisible, this code will not make it visible.

 

' NX 5.0.1.4
' Journal created by cohon on Wed Aug 01 21:31:27 2007 Central Daylight Time
'
Option Strict Off
Imports System
Imports NXOpen

Module Module2
    Sub Main()

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

        Dim displayPart As Part = theSession.Parts.Display

        ' ----------------------------------------------
        '   Menu: Fit
        ' ----------------------------------------------
        workPart.ModelingViews.WorkView.Fit()

        ' ----------------------------------------------
        '   Menu: Edit->Show and Hide->Show and Hide...
        ' ----------------------------------------------
        Dim markId1 As Session.UndoMarkId
        markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")

        theSession.SetUndoMarkName(markId1, "Show and Hide")

        theSession.SetUndoMarkVisibility(markId1, Nothing, Session.MarkVisibility.Invisible)

        Dim markId2 As Session.UndoMarkId
        markId2 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Hide Sketches")

        Dim numberHidden1 As Integer
        numberHidden1 = theSession.DisplayManager.HideByType(DisplayManager.ShowHideType.Sketches, DisplayManager.ShowHideScope.AnyInAssembly)

        Dim markId3 As Session.UndoMarkId
        markId3 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Hide Curves")

        Dim numberHidden2 As Integer
        numberHidden2 = theSession.DisplayManager.HideByType(DisplayManager.ShowHideType.Curves, DisplayManager.ShowHideScope.AnyInAssembly)

        Dim markId4 As Session.UndoMarkId
        markId4 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Hide Datums")

        Dim numberHidden3 As Integer
        numberHidden3 = theSession.DisplayManager.HideByType(DisplayManager.ShowHideType.Datums, DisplayManager.ShowHideScope.AnyInAssembly)

        For Each temp As CoordinateSystem In workPart.CoordinateSystems
            If temp.Name <> "" Then
                temp.Unblank()
                temp.RedisplayObject()
            End If
        Next

        For Each temp As Curve In workPart.Curves
            If temp.Name <> "" Then
                temp.Unblank()
                temp.RedisplayObject()
            End If
        Next

        ' ----------------------------------------------
        '   Menu: Fit
        ' ----------------------------------------------
        workPart.ModelingViews.WorkView.Fit()

        ' ----------------------------------------------
        '   Menu: Tools->Journal->Stop
        ' ----------------------------------------------

    End Sub
End Module

Re: Hide/Show journal

This version might work better, it should show all the named lines and coordinate systems even if they are an occurrence object (owned by a component but shown in the assembly).

 

' NX 5.0.1.4
' Journal created by cohon on Wed Aug 01 21:31:27 2007 Central Daylight Time
'
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module Module2
    Sub Main()

        Dim theSession As Session = Session.GetSession()
        Dim theUfSession As UFSession = UFSession.GetUFSession
        Dim workPart As Part = theSession.Parts.Work

        Dim displayPart As Part = theSession.Parts.Display

        ' ----------------------------------------------
        '   Menu: Fit
        ' ----------------------------------------------
        workPart.ModelingViews.WorkView.Fit()

        ' ----------------------------------------------
        '   Menu: Edit->Show and Hide->Show and Hide...
        ' ----------------------------------------------
        Dim markId1 As Session.UndoMarkId
        markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")

        theSession.SetUndoMarkName(markId1, "Show and Hide")

        theSession.SetUndoMarkVisibility(markId1, Nothing, Session.MarkVisibility.Invisible)

        Dim markId2 As Session.UndoMarkId
        markId2 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Hide Sketches")

        Dim numberHidden1 As Integer
        numberHidden1 = theSession.DisplayManager.HideByType(DisplayManager.ShowHideType.Sketches, DisplayManager.ShowHideScope.AnyInAssembly)

        Dim markId3 As Session.UndoMarkId
        markId3 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Hide Curves")

        Dim numberHidden2 As Integer
        numberHidden2 = theSession.DisplayManager.HideByType(DisplayManager.ShowHideType.Curves, DisplayManager.ShowHideScope.AnyInAssembly)

        Dim markId4 As Session.UndoMarkId
        markId4 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Hide Datums")

        Dim numberHidden3 As Integer
        numberHidden3 = theSession.DisplayManager.HideByType(DisplayManager.ShowHideType.Datums, DisplayManager.ShowHideScope.AnyInAssembly)

        Dim objTag As Tag = Tag.Null
        Do
            theUfSession.Obj.CycleObjsInPart(theSession.Parts.Display.Tag, UFConstants.UF_line_type, objTag)
            If objTag = Tag.Null Then
                Exit Do
            End If

            Dim aLine As Line = Utilities.NXObjectManager.Get(objTag)
            If aLine.Name <> "" Then
                aLine.Unblank()
                aLine.RedisplayObject()
            End If

        Loop While True


        objTag = Tag.Null
        Do
            theUfSession.Obj.CycleObjsInPart(theSession.Parts.Display.Tag, UFConstants.UF_coordinate_system_type, objTag)
            If objTag = Tag.Null Then
                Exit Do
            End If

            Dim aCsys As CoordinateSystem = Utilities.NXObjectManager.Get(objTag)
            If aCsys.Name <> "" Then
                aCsys.Unblank()
                aCsys.RedisplayObject()
            End If

        Loop While True


        ' ----------------------------------------------
        '   Menu: Fit
        ' ----------------------------------------------
        workPart.ModelingViews.WorkView.Fit()

        ' ----------------------------------------------
        '   Menu: Tools->Journal->Stop
        ' ----------------------------------------------

    End Sub
End Module

Re: Hide/Show journal

Close,

 

If its already hidden and happens to have a name such as sketch curves I do not want them to become visible.

 

I'd also like Named Points to stay visible.

 

 

Thanks.

 

 

Rob Newcomb, CAD/CNC/Simulation manager
Elmhirst Industries, Specializing in Prototype sheet metal stampings and assemblies

Production: NX 11.0.2.7 / Autoform r7 /WorkNC 2017 r2
Testing:NX12 EAP
PC: Rave Cadbeast: Intel(R) i7-4790K CPU @ 4.GHz /32gb ram /NVIDIA Quadro K2200 on Win10 Pro

Re: Hide/Show journal

Ok, try this one.

 

' NX 5.0.1.4
' Journal created by cohon on Wed Aug 01 21:31:27 2007 Central Daylight Time
'
Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF

Module Module2
    Sub Main()

        Dim theSession As Session = Session.GetSession()
        Dim theUfSession As UFSession = UFSession.GetUFSession
        Dim workPart As Part = theSession.Parts.Work

        Dim displayPart As Part = theSession.Parts.Display

        Dim namedAndUnblanked As New List(Of DisplayableObject)

        'find current coordinate systems, curves, and points that are named and not hidden
        Dim objTag As Tag = Tag.Null
        Do
            theUfSession.Obj.CycleObjsInPart(theSession.Parts.Display.Tag, UFConstants.UF_line_type, objTag)
            If objTag = Tag.Null Then
                Exit Do
            End If

            Dim theFeatureTag As Tag = Tag.Null
            theUfSession.Modl.AskObjectFeat(objtag, theFeatureTag)

            Dim theFeature As Features.Feature = Nothing

            If theFeatureTag = Tag.Null Then
                'unassociative line
                'continue processing
            Else
                theFeature = Utilities.NXObjectManager.Get(theFeatureTag)
                If TypeOf (theFeature) Is Features.SketchFeature Then
                    'skip sketch curves
                    Continue Do
                Else
                    'continue processing this line
                End If
            End If


            Dim aLine As Line = Utilities.NXObjectManager.Get(objTag)
            If aLine.Name <> "" AndAlso (Not aLine.IsBlanked) Then
                namedAndUnblanked.Add(aLine)
            End If

        Loop While True

        objTag = Tag.Null
        Do
            theUfSession.Obj.CycleObjsInPart(theSession.Parts.Display.Tag, UFConstants.UF_coordinate_system_type, objTag)
            If objTag = Tag.Null Then
                Exit Do
            End If

            Dim aCsys As CoordinateSystem = Utilities.NXObjectManager.Get(objTag)
            If aCsys.Name <> "" AndAlso (Not aCsys.IsBlanked) Then
                namedAndUnblanked.Add(aCsys)
            End If

        Loop While True

        objTag = Tag.Null
        Do
            theUfSession.Obj.CycleObjsInPart(theSession.Parts.Display.Tag, UFConstants.UF_point_type, objTag)
            If objTag = Tag.Null Then
                Exit Do
            End If

            Dim aPoint As Point = Utilities.NXObjectManager.Get(objTag)
            If aPoint.Name <> "" AndAlso (Not aPoint.IsBlanked) Then
                namedAndUnblanked.Add(aPoint)
            End If

        Loop While True

        ' ----------------------------------------------
        '   Menu: Fit
        ' ----------------------------------------------
        workPart.ModelingViews.WorkView.Fit()

        ' ----------------------------------------------
        '   Menu: Edit->Show and Hide->Show and Hide...
        ' ----------------------------------------------
        Dim markId1 As Session.UndoMarkId
        markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")

        theSession.SetUndoMarkName(markId1, "Show and Hide")

        theSession.SetUndoMarkVisibility(markId1, Nothing, Session.MarkVisibility.Invisible)

        Dim markId2 As Session.UndoMarkId
        markId2 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Hide Sketches")

        Dim numberHidden1 As Integer
        numberHidden1 = theSession.DisplayManager.HideByType(DisplayManager.ShowHideType.Sketches, DisplayManager.ShowHideScope.AnyInAssembly)

        Dim markId3 As Session.UndoMarkId
        markId3 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Hide Curves")

        Dim numberHidden2 As Integer
        numberHidden2 = theSession.DisplayManager.HideByType(DisplayManager.ShowHideType.Curves, DisplayManager.ShowHideScope.AnyInAssembly)

        Dim markId4 As Session.UndoMarkId
        markId4 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Hide Datums")

        Dim numberHidden3 As Integer
        numberHidden3 = theSession.DisplayManager.HideByType(DisplayManager.ShowHideType.Datums, DisplayManager.ShowHideScope.AnyInAssembly)

        'redisplay named objects
        For Each temp As DisplayableObject In namedAndUnblanked
            temp.Unblank()
            temp.RedisplayObject()
        Next


        ' ----------------------------------------------
        '   Menu: Fit
        ' ----------------------------------------------
        workPart.ModelingViews.WorkView.Fit()

        ' ----------------------------------------------
        '   Menu: Tools->Journal->Stop
        ' ----------------------------------------------

    End Sub
End Module

Re: Hide/Show journal

Seems to work, I've been on the shop floor most of the day.
Thanks!
Rob Newcomb, CAD/CNC/Simulation manager
Elmhirst Industries, Specializing in Prototype sheet metal stampings and assemblies

Production: NX 11.0.2.7 / Autoform r7 /WorkNC 2017 r2
Testing:NX12 EAP
PC: Rave Cadbeast: Intel(R) i7-4790K CPU @ 4.GHz /32gb ram /NVIDIA Quadro K2200 on Win10 Pro