Option Strict Off
Imports System
Imports NXOpen
Imports System.Collections
Imports NXOpen.UI
Imports NXOpen.UF
Imports NXOpen.Utilities
Imports NXOpen.Assemblies
Imports NXOpen.Features
'RAW Source
'[URL unfurl="true"]http://www.eng-tips.com/viewthread.cfm?qid=359434[/URL]
'11 Feb 14 13:27
Module Extract_Edges_Of_Solid_or_Sheet_MOD
Sub Main()
Dim theSession As Session = Session.GetSession()
Dim theUI As UI = UI.GetUI()
Dim lw As ListingWindow = theSession.ListingWindow()
Dim obj() As NXObject
Dim workPart As Part = theSession.Parts.Work
Dim theUFSession As UFSession = UFSession.GetUFSession()
Dim ufs As UFSession = UFSession.GetUFSession()
If select_edges(obj) = Selection.Response.Cancel Then
Exit Sub
End If
For Each tmpEdge As NXObject In obj
Dim thisEdge As NXOpen.Tag = tmpEdge.Tag
Dim newCurve As NXOpen.Tag = NXOpen.Tag.Null
ufs.Modl.CreateCurveFromEdge(thisEdge, newCurve)
Dim displayModification1 As DisplayModification
displayModification1 = theSession.DisplayManager.NewDisplayModification()
displayModification1.ApplyToAllFaces = True
displayModification1.ApplyToOwningParts = False
displayModification1.NewColor = 4
displayModification1.NewFont = DisplayableObject.ObjectFont.Phantom
displayModification1.NewLayer = 5 'layer of desire
Dim object1(0) As DisplayableObject
object1(0) = CType(NXObjectManager.Get(newCurve), DisplayableObject)
displayModification1.Apply(object1)
displayModification1.Dispose()
Next
End Sub
Function select_edges(ByRef obj() As NXObject)
Dim ui As UI = ui.GetUI()
Dim message As String = "Select Edge"
Dim title As String = "Selection"
Dim selectionMask_array(0) As Selection.MaskTriple
selectionMask_array(0).Type = UFConstants.UF_solid_type
selectionMask_array(0).Subtype = UFConstants.UF_solid_edge_subtype
selectionMask_array(0).SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_ANY_EDGE
Dim resp As Selection.Response = _
ui.SelectionManager.SelectObjects(message, title, _
Selection.SelectionScope.AnyInAssembly, _
Selection.SelectionAction.ClearAndEnableSpecific, _
False, False, selectionMask_array, obj)
If resp = Selection.Response.ObjectSelected Or _
resp = Selection.Response.ObjectSelectedByName Or _
resp = Selection.Response.Ok Then
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
End If
End Function
End Module