Extract Curves Off Solid or Sheet
Extract Curves Off Solid or Sheet
(OP)
I am getting back into writing some journals and I am struggling with extracting edge curves off a solid or sheet. I can't seem to record it or find any examples.
Some background info, I have new data on layer 1 and old data on layer 2 and would like to extract curves off both and place those curves on layer 3. The curves extracted from layer 1 to be colored red and curves from layer 2 to be blue. Layers 1 and 2 could be multiple skins or solids.
We currently have a macro that works in 7.5 but is failing in 8.0. I was hoping to rewrite it in .vb to ease transitions to newer versions.
Any help would be greatly appreciated.
Thanks,
Kevin
Some background info, I have new data on layer 1 and old data on layer 2 and would like to extract curves off both and place those curves on layer 3. The curves extracted from layer 1 to be colored red and curves from layer 2 to be blue. Layers 1 and 2 could be multiple skins or solids.
We currently have a macro that works in 7.5 but is failing in 8.0. I was hoping to rewrite it in .vb to ease transitions to newer versions.
Any help would be greatly appreciated.
Thanks,
Kevin





RE: Extract Curves Off Solid or Sheet
Public Sub CreateCurveFromEdge ( _
edge_id As Tag, _
<OutAttribute> ByRef ugcrv_id As Tag _
)
Frank Swinkels
RE: Extract Curves Off Solid or Sheet
Thank you, I will give that a try.
Kevin
RE: Extract Curves Off Solid or Sheet
____________
ufs.Obj.CycleObjsInPart(workPart.Tag(), UFConstants.UF_solid_type, tmpTag)
If tmpTag > NXOpen.Tag.Null Then
If ufs.Assem.IsOccurrence(tmpTag) = False Then
ufs.Obj.AskTypeAndSubtype(tmpTag, type, subtype)
If subtype = UFConstants.UF_solid_face_subtype Then
Dim thisFace As Face = NXObjectManager.Get(tmpTag)
____________
layerObjects = workPart.Layers.GetAllObjectsOnLayer(7)
If layerObjects.Length > 0 Then
____________
My current program:
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
Module Extract_Edges_Of_Solid_or_Sheet
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 tmpEdgeLayer As DisplayableObject
tmpEdgeLayer = CType(NXObjectManager.Get(thisEdge), DisplayableObject)
Dim newCurve As NXOpen.Tag = NXOpen.Tag.Null
If tmpEdgeLayer.Layer = 7 Then
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
Dim object1(0) As DisplayableObject
object1(0) = CType(NXObjectManager.Get(newCurve), DisplayableObject)
displayModification1.Apply(object1)
displayModification1.Dispose()
Else If tmpEdgeLayer.Layer = 9 Then
ufs.Modl.CreateCurveFromEdge(thisEdge, newCurve)
Dim displayModification1 As DisplayModification
displayModification1 = theSession.DisplayManager.NewDisplayModification()
displayModification1.ApplyToAllFaces = True
displayModification1.ApplyToOwningParts = False
displayModification1.NewColor = 1
displayModification1.NewFont = DisplayableObject.ObjectFont.Phantom
displayModification1.NewLayer = 5
Dim object1(0) As DisplayableObject
object1(0) = CType(NXObjectManager.Get(newCurve), DisplayableObject)
displayModification1.Apply(object1)
displayModification1.Dispose()
Else
End If
Next
End Sub
Function select_edges(ByRef obj() As NXObject)
Dim ui As UI = ui.GetUI()
Dim message As String = "Select a circular object"
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
Thanks,
Kevin
RE: Extract Curves Off Solid or Sheet
If automatically, what filter should the journal use (e.g. all solid bodies on layer 2)?
www.nxjournaling.com
RE: Extract Curves Off Solid or Sheet
This works as filters when manually selecting:
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
Kevin
RE: Extract Curves Off Solid or Sheet
CODE
www.nxjournaling.com
RE: Extract Curves Off Solid or Sheet
Kevin
RE: Extract Curves Off Solid or Sheet
Sorry for using the old thread again but I think I am not that off-topic.
I have got a question relating to kr7530’s post on 11 Feb 14 13:27 (post #4). The modification of the code I am currently working on simply creates a spline after the selection of a specific edge and moves it to the layer of desire, see below.
Is there any chance to force the spline to be displayed in the Part Navigator (currently it is NOT listed), like as “Spline 794”? The spline is needed for further manipulations. Probably there is some kind of command missing similar to this:
Spline -> “.IsAssociative = True”
If you select a spline, open the Studio Spline window and go to settings there appears a checkbox called “Make Associative”. Therefore it must be possible to code it too, but I cannot find it
CODE -->
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 'http://www.eng-tips.com/viewthread.cfm?qid=359434 '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 ModuleBest regards,
Polynom2000
RE: Extract Curves Off Solid or Sheet
The resulting spline will be associative to the underlying data, not to the edge that you picked (this is true of both the spline object or the spline feature). If you need to have the spline associated to the edge, try using a composite curve feature instead of extracting the edge.
One thing to keep in mind is not every curve created by your journal will be a spline; the resulting curve will inherit the underlying edge type (it may be a line or arc). You should test to see what type of curve you have before trying to convert it to a spline feature.
www.nxjournaling.com
RE: Extract Curves Off Solid or Sheet
Currently I don’t know what name I have to paste instead of "SPLINE(780)" in order to refer to the new spline. Below is some fractional code of the Point Set function which refers to a spline (associative = true, also visible in the Part Navigator).
CODE -->
Dim studioSpline1 As Features.StudioSpline = CType(workPart.Features.FindObject("SPLINE(780)"), Features.StudioSpline)I have recorded a journal, double clicked the spline, checked the "associative" option and examined the resulting code. There appears some StudioSplineBuilderEx feature but there is some problem: Instead of FindObject(~NewSplineCreated) spline1 refers to some strange entity which differs during time and other circumstances.
CODE -->
Dim spline1 As Spline = CType(workPart.Splines.FindObject("ENTITY 9 1 1"), Spline) Dim studioSplineBuilderEx1 As Features.StudioSplineBuilderEx studioSplineBuilderEx1 = workPart.Features.CreateStudioSplineBuilderEx(spline1)I am looking for something similar to the code above (example just shows Wave Linker). This code snippet should be located close to the “spline builder”. For later purposes you can reuse the string “Object_Want_to_use_later”.
CODE -->
It seems that object1(0).JournalIdentifier does not work properly, because it ALWAYS returns “ENTITY 9 1 1” which is in fact NOT true. I have created multiple splines with the code of my previous post (30 Jul 14 7:13) and executed a simple Point Set Journal with the following FindObject input: "ENTITY 9 1 1", "ENTITY 9 2 1", "ENTITY 9 3 1". The modified entity number works pretty well – I am confused why object1(0).JournalIdentifier does not work in this context.
Any idea how to get (always) the correct name of the spline just created so that it can be used as input for the Point Set function?
Best regards,
Polynom2000
RE: Extract Curves Off Solid or Sheet
CODE
www.nxjournaling.com
RE: Extract Curves Off Solid or Sheet
Best regards,
Polynom2000