Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

NX Open Unblank Routing Objects 1

Status
Not open for further replies.

MEichWey

Industrial
Apr 16, 2014
39
Hi all,

I would like to write a small VB-Program that should unblank all Routing Objects with subtype anchor, port and controlpoint. The NX Standard function with CTRL+W didn´t work, cause routing objects are not supported (NX8, NX8.5, NX9). We Need also to blank the objects first, but I thought this will be easy, if I have a way to unblank the objects.
My first idea was to select all objects with the MaskTriple (object type 220, 221 and 225, no subtype). But how do I have to select them, if they are blanked? If the blanked objects are selected, then they should by unblanked.

Have anyone an idea, how to do that?

Michael
 
Replies continue below

Recommended for you

I really don't think there is a way to do what you want.
Utilizing layers instead of blanking is a betters was to go,
 
The part has a .RouteManager property that will give you access to various routing objects. You might unblank all the anchor objects like this:

Code:
For Each tempAnchor As Routing.Anchor In workPart.RouteManager.Anchors
    tempAnchor.Unblank()
Next

The code would be similar for ports and control points. Bear in mind that even if the object is shown (unblanked), it will not be visible if the layer is turned off.


www.nxjournaling.com
 
Hi cowski,

fine, this works, but only in the single part where the routing objects are defined. Now I need to blank and unblank them in a top-level assembly, where these object are objects of the components.

I test it with:

For Each tempAnchor As Routing.Anchor In displayPart.RouteManager.Anchors
tempAnchor.Unblank()
Next

But this doesn´t work (In top of the program I defined what displayPart is (Dim displayPart ...)

Michael
 
MEichWey said:
For Each tempAnchor As Routing.Anchor In displayPart.RouteManager.Anchors
tempAnchor.Unblank()
Next

That code won't work because the anchors in the components are not owned by the display part.

Have you considered using reference sets in the components to filter the routing objects in the assembly?

www.nxjournaling.com
 
Hi Cowski,

the routing object are all on Layer 1 (same as the model geometry)and not in a special reference set. This is what the users have done in old parts and will also do in new parts. Actually they can use two macros to blank or unblank the routing objects. But these macros works only in drawing application and the users would like to use it also in modeling application.
So I tried to make a new journal program to blank/unblank the objects independently of the application.

Michael
 
Which part 'owns' the routing objects, the piece part or the assembly?
Can you post a small example (part and/or assembly)? I don't have access to the routing application and I don't understand the situation as well as I'd like...

www.nxjournaling.com
 
Hi cowski,

OK. Next week on Monday I can upload a small example and also a functional diagram, to show where the objects are in the assembly. Routing works a little bit different then legacy work.

Michael
 
The following journal will hide the routing objects (control points, ports, and anchors) in the display part. There is a line of code near the end of Sub Main that will allow you to show the routing objects (it is currently commented out); if you uncomment the line it will show the routing objects. You can split this into 2 journals to hide/show or you can add some logic to 'toggle' the display on each run of the journal.

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

Module Module2

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

    Sub Main()

        If IsNothing(theSession.Parts.Work) Then
            [COLOR=#4E9A06]'active part required[/color]
            Return
        End If

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

        Const undoMarkName As String = "hide routing objects"
        Dim markId1 As Session.UndoMarkId
        markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)

        Dim routeTags As New List(Of Tag)
        Dim routeObjs As New List(Of DisplayableObject)

        FindObjects(routeTags, UFConstants.UF_route_control_point_type)
        FindObjects(routeTags, UFConstants.UF_route_port_type)
        FindObjects(routeTags, UFConstants.UF_route_part_anchor_type)

        For Each tempTag As Tag In routeTags

            Dim tmpDisplay As DisplayableObject = Utilities.NXObjectManager.Get(tempTag)
            routeObjs.Add(tmpDisplay)
        Next

        [COLOR=#4E9A06]'Hide routing objects (control points, ports, and anchors)[/color]
        theSession.DisplayManager.BlankObjects(routeObjs.ToArray)

        [COLOR=#4E9A06]'Show routing objects (control points, ports, and anchors)[/color]
        [highlight #EDD400][COLOR=#4E9A06]'theSession.DisplayManager.ShowObjects(routeObjs.ToArray, DisplayManager.LayerSetting.ChangeLayerToSelectable)[/color][/highlight]

        lw.Close()

    End Sub

    Sub FindObjects(ByRef tagList As List(Of Tag), ByVal objType As Integer)

        Dim tmpObj As NXOpen.Tag = NXOpen.Tag.Null

        Do
            theUfSession.Obj.CycleObjsInPart(theSession.Parts.Display.Tag, objType, tmpObj)
            If tmpObj = NXOpen.Tag.Null Then
                Continue Do
            End If
            If tmpObj <> NXOpen.Tag.Null Then
                tagList.Add(tmpObj)
            End If
        Loop Until tmpObj = NXOpen.Tag.Null

    End Sub

End Module

www.nxjournaling.com
 
Hi.
That journal worked great, really useful as we never want to show routing objects(except from the solids) on drawing.

In my case I need to hide the routing path as well. I have managed to hide them by adding
FindObjects(routeTags, UFConstants.UF_route_path_subtype)

but this does not take care of the bends/routing arcs, only the straight routing lines disappear.

Anyone got an Idea?

-Hallvar
 
For the FindObjects() subroutine, you must pass in the type of the object you wish to find, not the subtype. The constant: UFConstants.UF_route_path_subtype evaluates to "3" which is equivalent to the UF_line_type. You have found all the lines in the part, whether they are routing objects or not. I'm not familiar with the routing application, but I'd suggest using the type constant: UF_route_route_type. This should pick up the subtypes:
wire, harness, path, path_fmbd, path_offset, built_in_path, cable, jumper_wire, segment_set, and subroute.

www.nxjournaling.com
 
Thanks for the reply!


Unfortunately, I had already tried UF_route_route_type which hid everything I needed except the bends/routing arcs.
When I do a manual CTRL+W -->hide curves, they disappear, but that might hide more than needed.

I'm very new to NXopen, and I don't have programming background, but I guess I can keep using UF_route_route_type and continue the search for a second line,which will hide the arcs/bends? When I select the arc in the graphics window, it has the name "Route Arc".

thanks,

Hallvar
 
Can you post a small sample file that contains both objects that you would like to blank and objects you would like to keep visible? I don't have a routing license, so I can't create them myself.

www.nxjournaling.com
 
I attached a file routed pipe with bends.

I think maybe it would work if I use UF_route_route_type to hide all routing except arcs,and then add a function into the code, to hide curves ( the "curves" that are hidden when using CTRL+W -->hide curves), to take care of the arcs.

But one possible drawback by using hide curve, is that more than the routing is hidden.
To exemplify that, I have created some curves below the pipe.

I hope NX 8.5 is OK by the way.
 
 http://files.engineering.com/getfile.aspx?folder=61a95767-9e47-4e11-a33e-a1bd32829221&file=Show_hide_routing_objs.prt
Code added to find routing segments.

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

Module Module3

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

    Sub Main()

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

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

        Const undoMarkName As String = "hide routing objects"
        Dim markId1 As Session.UndoMarkId
        markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)

        Dim routeTags As New List(Of Tag)
        Dim routeObjs As New List(Of DisplayableObject)

        findRouteSegments(routeObjs)

        FindObjects(routeTags, UFConstants.UF_route_control_point_type)
        FindObjects(routeTags, UFConstants.UF_route_port_type)
        FindObjects(routeTags, UFConstants.UF_route_part_anchor_type)

        'lw.WriteLine("number of routing object tags: " & routeTags.Count.ToString)

        For Each tempTag As Tag In routeTags

            Dim tmpDisplay As DisplayableObject = Utilities.NXObjectManager.Get(tempTag)
            routeObjs.Add(tmpDisplay)
        Next

        'lw.WriteLine("number of routing objects: " & routeObjs.Count.ToString)

        'Hide routing objects (control points, ports, and anchors)
        theSession.DisplayManager.BlankObjects(routeObjs.ToArray)

        'Show routing objects (control points, ports, and anchors)
        'theSession.DisplayManager.ShowObjects(routeObjs.ToArray, DisplayManager.LayerSetting.ChangeLayerToSelectable)

        lw.Close()

    End Sub

    Sub FindObjects(ByRef tagList As List(Of Tag), ByVal objType As Integer)

        Dim tmpObj As NXOpen.Tag = NXOpen.Tag.Null
        'Dim type As Integer
        'Dim subtype As Integer

        Do
            theUfSession.Obj.CycleObjsInPart(theSession.Parts.Display.Tag, objType, tmpObj)
            If tmpObj = NXOpen.Tag.Null Then
                Continue Do
            End If
            If tmpObj <> NXOpen.Tag.Null Then
                'theUfSession.Obj.AskTypeAndSubtype(tmpTabNote, type, subtype)
                'If subtype = UFConstants.UF_tabular_note_section_subtype Then

                tagList.Add(tmpObj)

                'End If
            End If
        Loop Until tmpObj = NXOpen.Tag.Null

    End Sub

    Sub findRouteSegments(ByRef segmentList As List(Of DisplayableObject))

        For Each temp As Routing.ArcSegment In workPart.SegmentManager.ArcSegments
            segmentList.Add(temp)
        Next

        For Each temp As Routing.LineSegment In workPart.SegmentManager.LineSegments
            segmentList.Add(temp)
        Next

        For Each temp As Routing.SplineSegment In workPart.SegmentManager.SplineSegments
            segmentList.Add(temp)
        Next

    End Sub

    Public Function GetUnloadOption(ByVal dummy As String) As Integer

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

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

        'Unloads the image explicitly, via an unload dialog
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
        '-------------------------------

    End Function

End Module

www.nxjournaling.com
 
Thanks a lot!

This works.
I want to make it work for assemblies as well, but I can try this modification myself, as you have already done a lot more than I expected.

-Hallvar
 
Hi all,

I have tried to change the last code from cowski, to select all segments (lines, arcs, splines) in the routing assembly. Currently the program blank or unblank only the control-points, part-anchors and ports in an assembly. The Segment will blank / unblank only if they are member of the workpart.
Now I find out that there is a UFConstant "UF_route_segment_type". But this doesn´t work. There is no error massage and it still do not blank or unblank routing-segments if I uses it:

FindObjects(routeTags, UFConstants.UF_route_segment_type)

Is there a way to use this constant in code or a way to enhance the code in the subroutine "FindRouteSegments" to select the segments in componentes of an routing-assembly?

Michael



 
The constant UF_route_segment_type was made obsolete in NX 1; the value has been recycled and is now used for UF_mdm_sensor_type. This means that this call:
FindObjects(routeTags, UFConstants.UF_route_segment_type)
will find objects of type UF_mdm_sensor_type, not UF_route_segment_type.

www.nxjournaling.com
 
Hi Hallvar and Cowski,

I have try to make some changes to the last code. Now I have found a way to blank/unblank the routing-segments with a UFConstant, so the segments will be blanked und unblanked over a complete assembly-struktur. You can see it in the code. I have also add a toggle-funktion. Cowski has shown this toggle-funktion in an other thread with some other objects. Now we have o good working tool. The only thing is, if there is a way to toggle without to set an Attribute. If I found a solution I will post it here again.
Thank you very much Cowski for your very good journaling tips.
Here the new Code:
Code:
Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Assemblies

Module BlankRouting

    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 RoutObjAttribute As String = "RoutObjVis" 

    Sub Main()

        If IsNothing(theSession.Parts.Work) Then
            'active part required
            Return
        End If
		
[highlight #8AE234]        'Is Routing Objekt Attribute set or not?
        Dim RoutObjVisible As Boolean = True  
		
        Try  
            RoutObjVisible = workPart.GetBooleanUserAttribute(RoutObjAttribute, 0)  

        Catch ex As NXException  
            If ex.ErrorCode = 512008 Then  
           'attribute not found
                workPart.SetBooleanUserAttribute(RoutObjAttribute, 0, False, Update.Option.Later)  
            Else  
           'unexpected error
                MsgBox(ex.ErrorCode & " : " & ex.Message)  
                Return  
            End If  
        End Try  		[/highlight]

        'Find Routing Objects
        Const undoMarkName As String = "hide routing objects"
        Dim markId1 As Session.UndoMarkId
        markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)

        Dim routeTags As New List(Of Tag)
        Dim routeObjs As New List(Of DisplayableObject)

        FindObjects(routeTags, UFConstants.UF_route_control_point_type)
        FindObjects(routeTags, UFConstants.UF_route_port_type)
        FindObjects(routeTags, UFConstants.UF_route_part_anchor_type)
        [highlight #8AE234]FindObjects(routeTags, UFConstants.UF_route_path_subtype)[/highlight]
		
        For Each tempTag As Tag In routeTags

            Dim tmpDisplay As DisplayableObject = Utilities.NXObjectManager.Get(tempTag)
            routeObjs.Add(tmpDisplay)
        Next

[highlight #8AE234]        'Blank or Unblank Routing Objects
        If RoutObjVisible Then  
            HideRoutObj(routeObjs)  
        Else  
            ShowRoutObj(routeObjs)  
        End If[/highlight] 
    End Sub

    Sub FindObjects(ByRef tagList As List(Of Tag), ByVal objType As Integer)

        Dim tmpObj As NXOpen.Tag = NXOpen.Tag.Null

        Do
            theUfSession.Obj.CycleObjsInPart(theSession.Parts.Display.Tag, objType, tmpObj)
            If tmpObj = NXOpen.Tag.Null Then
                Continue Do
            End If
            If tmpObj <> NXOpen.Tag.Null Then

                tagList.Add(tmpObj)

            End If
        Loop Until tmpObj = NXOpen.Tag.Null

    End Sub
	
[highlight #8AE234]	Sub ShowRoutObj(ByRef routeObjs As List(Of DisplayableObject))  
            'Show routing objects (control points, ports, and anchors)
	   theSession.DisplayManager.ShowObjects(routeObjs.ToArray, DisplayManager.LayerSetting.ChangeLayerToSelectable)

	   workPart.SetBooleanUserAttribute(RoutObjAttribute, 0, True, Update.Option.Later)  

	End Sub  

	Sub HideRoutObj(ByRef routeObjs As List(Of DisplayableObject))  
	   'Hide routing objects (control points, ports, and anchors)
	   theSession.DisplayManager.BlankObjects(routeObjs.ToArray)

	   workPart.SetBooleanUserAttribute(RoutObjAttribute, 0, False, Update.Option.Later)  

	End Sub[/highlight]  	

    Public Function GetUnloadOption(ByVal dummy As String) As Integer

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

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

        'Unloads the image explicitly, via an unload dialog
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
        '-------------------------------

    End Function

End Module

Michael
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor