NX Open Unblank Routing Objects
NX Open Unblank Routing Objects
(OP)
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
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





RE: NX Open Unblank Routing Objects
Utilizing layers instead of blanking is a betters was to go,
RE: NX Open Unblank Routing Objects
CODE
For Each tempAnchor As Routing.Anchor In workPart.RouteManager.Anchors tempAnchor.Unblank() NextThe 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
RE: NX Open Unblank Routing Objects
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
RE: NX Open Unblank Routing Objects
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
RE: NX Open Unblank Routing Objects
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
RE: NX Open Unblank Routing Objects
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
RE: NX Open Unblank Routing Objects
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
RE: NX Open Unblank Routing Objects
attached you will find a sample nx-assembly and a PDF-File with some additional Information (in the Zip-File).
Michael
RE: NX Open Unblank Routing Objects
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 '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) 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 '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 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 Modulewww.nxjournaling.com
RE: NX Open Unblank Routing Objects
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
RE: NX Open Unblank Routing Objects
wire, harness, path, path_fmbd, path_offset, built_in_path, cable, jumper_wire, segment_set, and subroute.
www.nxjournaling.com
RE: NX Open Unblank Routing Objects
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
RE: NX Open Unblank Routing Objects
www.nxjournaling.com
RE: NX Open Unblank Routing Objects
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.
RE: NX Open Unblank Routing Objects
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 Modulewww.nxjournaling.com
RE: NX Open Unblank Routing Objects
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
RE: NX Open Unblank Routing Objects
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
RE: NX Open Unblank Routing Objects
FindObjects(routeTags, UFConstants.UF_route_segment_type)
will find objects of type UF_mdm_sensor_type, not UF_route_segment_type.
www.nxjournaling.com
RE: NX Open Unblank Routing Objects
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 '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 '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) FindObjects(routeTags, UFConstants.UF_route_path_subtype) For Each tempTag As Tag In routeTags Dim tmpDisplay As DisplayableObject = Utilities.NXObjectManager.Get(tempTag) routeObjs.Add(tmpDisplay) Next 'Blank or Unblank Routing Objects If RoutObjVisible Then HideRoutObj(routeObjs) Else ShowRoutObj(routeObjs) End If 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 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 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 ModuleMichael
RE: NX Open Unblank Routing Objects
Is your current code correctly hiding routing arcs and routing splines, or just the lines?
www.nxjournaling.com
RE: NX Open Unblank Routing Objects
sorry, we only have routing-parts with line-segments. Now I test it with the part from Hallvar - arcs and splines will not processed. So in this case we have to use the code from you with "Sub findRouteSegments..". For this we have to add a routine to process all components in an assembly-structure. I find a possible solution on nxjournaling.com under Tutorials -> Processing an Assembly.
I will tried to implement this. It is a good learning project.
Michael