Submitted by Varuna on Fri, 08/26/2016 - 10:09
Forums:
Hi I am beginner in journaling.
I am trying to make journal for extracting curves from a body "All in view"
Can anyone help in writing a journal.
Thanks
Hi I am beginner in journaling.
I am trying to make journal for extracting curves from a body "All in view"
Can anyone help in writing a journal.
Thanks
re: extract curves
Are you extracting the curves in a modeling view or drafting view? Also, what version of NX?
Extract Edge Curves
Yes, I am using NX 10.0 version and i am trying to set the Visualisation to Static Wireframe and Extract curves "All in Work view" in modeling.
Thanks
Varuna
re: extract curves
The code below will extract the curves of bodies in a part file (some tweaks need to be made if you want it to work in the context of an assembly). It works in the context of a modeling view (tested on NX 9).
Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF
Module Module1
Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()
Dim theUI As UI = UI.GetUI()
Dim lw As ListingWindow = theSession.ListingWindow
Sub Main()
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "NXJ")
lw.Open()
Dim visibleBodies As New List(Of Body)
For Each tempBody As Body In theSession.Parts.Work.Bodies
'skip hidden bodies
If tempBody.IsBlanked Then
Continue For
End If
'skip bodies on an invisible layer
If theSession.Parts.Work.Layers.GetState(tempBody.Layer) = Layer.State.Hidden Then
Continue For
End If
'if we make it to here, we have a solid body that is visible
visibleBodies.Add(tempBody)
Next
For Each tempBody As Body In visibleBodies
For Each tempEdge As Edge In tempBody.GetEdges
Dim edgeArcTag As Tag
theUfSession.Modl.CreateCurveFromEdge(tempEdge.Tag, edgeArcTag)
Next
Next
lw.Close()
End Sub
Public Function GetUnloadOption(ByVal dummy As String) As Integer
'Unloads the image immediately after execution within NX
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
End Function
End Module
Extract curves
Thanks much, I have tried to tweak this code to achieve my actual requirement.
Here is what i am trying to do in a model
Replace view ( Ex: Top) => Preferences => Visualisation => Static Wireframe => After this extracting the curves from edges only which is visible.
(If it is done in manual method Insert => Derived curve => Extract => All in Work view)
Below is the code i have written but i am not able to find out where i went wrong.
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports System.Collections.Generic
Module NXJournal
Sub Main (ByVal args() As String)
Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
Dim workPart As NXOpen.Part = theSession.Parts.Work
Dim displayPart As NXOpen.Part = theSession.Parts.Display
Dim theUI As UI = UI.GetUI()
Dim lw As ListingWindow = theSession.ListingWindow
' ----------------------------------------------
Dim layout1 As NXOpen.Layout = CType(workPart.Layouts.FindObject("L1"), NXOpen.Layout)
Dim modelingView1 As NXOpen.ModelingView = CType(workPart.ModelingViews.FindObject("Top"), NXOpen.ModelingView)
layout1.ReplaceView(workPart.ModelingViews.WorkView, modelingView1, True)
' ----------------------------------------------
Dim displayAppearanceOptions1 As NXOpen.Preferences.ViewVisualizationVisual.DisplayAppearanceOptions
displayAppearanceOptions1.RenderingStyle = NXOpen.Preferences.ViewVisualizationVisual.RenderingStyle.StaticWireframe
displayAppearanceOptions1.HiddenEdges = NXOpen.Preferences.ViewVisualizationVisual.HiddenEdges.Invisible
displayAppearanceOptions1.Silhouettes = True
displayAppearanceOptions1.SmoothEdges = False
displayAppearanceOptions1.SmoothEdgeColor = 0
displayAppearanceOptions1.SmoothEdgeFont = NXOpen.Preferences.ViewVisualizationVisual.SmoothEdgeFont.Original
displayAppearanceOptions1.SmoothEdgeWidth = NXOpen.Preferences.ViewVisualizationVisual.SmoothEdgeWidth.Original
displayAppearanceOptions1.SmoothEdgeAngleTolerance = 0.2
modelingView1.VisualizationVisualPreferences.DisplayAppearance = displayAppearanceOptions1
' ----------------------------------------------
lw.Open()
Dim visibleBodies As New List(Of Body)
For Each tempEdge As Edge In tempBody.GetEdges
Dim edgeArcTag As Tag
theUfSession.Modl.CreateCurveFromEdge(tempEdge.Tag, edgeArcTag)
Next
lw.Close()
End Sub
Public Function GetUnloadOption(ByVal dummy As String) As Integer
'Unloads the image immediately after execution within NX
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
End Function
End Module
Varuna
re: extract curves
Thanks for the update; I have a better idea of what you want to accomplish now.
Unfortunately, I've not found a function that will replicate the "all in view" functionality (but this does not mean that it doesn't exist). I would suggest that you contact GTAC to see if such a command or workaround exists in the API.
Extract Curves
I am sorry, i meant "Extract curves => All in work view". Thanks!
Varuna
Extract Curves
I have got the same thing which you have used to create curves in NX open ref guide (UF_MODL_create_curve_from_edge). But i am unable to list the edges which is only visible
in that particular view (not the hidden edges). Thanks much for the support!
Varuna