Submitted by harun on Fri, 08/26/2016 - 15:24
Forums:
Hello,
how to count points of selected sketch (i need those for iteration, cuz i want to create Axis Systems on those points) and how to get those points for creatin of AS.
Hello,
how to count points of selected sketch (i need those for iteration, cuz i want to create Axis Systems on those points) and how to get those points for creatin of AS.
re: sketch points
The code below shows one way to get the point objects in the sketch. The journal code only processes the first sketch in the work part. It can be modified to process all sketches or a particular sketch of interest.
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 partSketches() As Sketch = theSession.Parts.Work.Sketches.ToArray
'if there are no sketches, exit journal
If partSketches.Length = 0 Then
Return
End If
'process the first sketch
Dim sketchObjects() As NXObject = partSketches(0).GetAllGeometry
If sketchObjects.Length = 0 Then
lw.WriteLine(partSketches(0).Name & " contains no geometry")
End If
Dim sketchPoints As New List(Of Point)
For Each temp As NXObject In sketchObjects
If TypeOf (temp) Is Point Then
sketchPoints.Add(temp)
End If
Next
lw.WriteLine(partSketches(0).Name & " contains " & sketchPoints.Count.ToString & " point objects")
For Each temp As Point In sketchPoints
lw.WriteLine(temp.Coordinates.ToString)
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