Information on object # 1
Owning part C:\Users\metinm\Desktop\New folder (2)\impeller.prt
Layer 1
Type Spline
Color 36 (Green)
Font SOLID
Width Normal
Modified Version 11 04 Haz 2015 09:57 (by user metinm)
Created Version 11 04 Haz 2015 09:57 (by user metinm)
Information Units mm
Closure Status Open
Degree 3
Number of Poles 718
Number of Segments 560
Number of C0 Knots 0
Number of C1 Knots 155
Number of C2 Knots 404
Rational Status Polynomial
Defining Data None
------------------------------------------------------------
Object Dependency Graph:
Spline - ID 1010
Used by:
None
Hello ,
This is the information window of a selected spline. I would like to get the spline ID by the selection window. I could not find the correct code for this:
lw.WriteLine("Object ID: " & mySelectedObject.ID.ToString)
re: spline ID
What do you plan on doing with the ID once you have it?
I ask because I have not yet found a situation where the ID was needed.
I will construct a surface
I will construct a surface from splines and the code for the spline is
Dim spline1 As Spline = CType(workPart.Splines.FindObject("HANDLE R-1010"), Spline)
I am trying to get "1010" by selection dialog.
re: spline ID
Do you have a reference to the spline object? I think I know how to get the ID of the spline, but you will need a reference to the spline object; and if you have a reference to the spline object, you don't need its ID...
I first recorded the
I first recorded the journaling and made it refined as below:
there is an iges file which includes 9 splines. Those are starting by a random id number for example 1010 (it changes model by model) then it goes down for 9 splines : 1010,1009,....1002
I put a selection window. When you selected the first spline the code will put the remaining 8 numbers and construct the geometry.
Thanks for fast reply
Option Strict Off
Imports System
Imports NXOpen
Module NXJournal
Sub Main
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim nullFeatures_Feature As Features.Feature = Nothing
Dim lw As ListingWindow = theSession.ListingWindow
Dim mySelectedObject As NXObject
If Not workPart.Preferences.Modeling.GetHistoryMode Then
Throw(New Exception("Create or edit of a Feature was recorded in History Mode but playback is in History-Free Mode."))
End If
Dim throughCurvesBuilder1 As Features.ThroughCurvesBuilder
throughCurvesBuilder1 = workPart.Features.CreateThroughCurvesBuilder(nullFeatures_Feature)
throughCurvesBuilder1.PatchType = Features.ThroughCurvesBuilder.PatchTypes.Multiple
throughCurvesBuilder1.Alignment.AlignCurve.DistanceTolerance = 0.0254
throughCurvesBuilder1.Alignment.AlignCurve.ChainingTolerance = 0.02413
throughCurvesBuilder1.SectionTemplateString.DistanceTolerance = 0.0254
throughCurvesBuilder1.SectionTemplateString.ChainingTolerance = 0.02413
throughCurvesBuilder1.Alignment.AlignCurve.AngleTolerance = 0.5
throughCurvesBuilder1.SectionTemplateString.AngleTolerance = 0.5
lw.Open
Do Until SelectAnObject("Select Root Spline", _
mySelectedObject) = Selection.Response.Cancel
lw.WriteLine("Object Tag: " & mySelectedObject.Tag)
lw.WriteLine("Object Type: " & mySelectedObject.GetType.ToString)
lw.WriteLine("")
Loop
lw.Close
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim section1 As Section
'section1 = workPart.Sections.CreateSection(0.02413, 0.0254, 0.5)
section1 = workPart.Sections.CreateSection( 0, 0, 0)
throughCurvesBuilder1.SectionsList.Append(section1)
Dim curves1(0) As Curve
Dim spline1 As Spline = CType(workPart.Splines.FindObject("HANDLE R-1010"), Spline)
curves1(0) = spline1
Dim curveDumbRule1 As CurveDumbRule
curveDumbRule1 = workPart.ScRuleFactory.CreateRuleCurveDumb(curves1)
section1.AllowSelfIntersection(False)
Dim rules1(0) As SelectionIntentRule
rules1(0) = curveDumbRule1
Dim nullNXObject As NXObject = Nothing
'Dim helpPoint1 As Point3d = New Point3d(-0.497345459095931, 7.72335316174076, 34.536886040469)
Dim helpPoint1 As Point3d = New Point3d(0, 0,0)
section1.AddToSection(rules1, spline1, nullNXObject, nullNXObject, helpPoint1, Section.Mode.Create, False)
Dim sections1(0) As Section
sections1(0) = section1
throughCurvesBuilder1.Alignment.SetSections(sections1)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim section2 As Section
'section2 = workPart.Sections.CreateSection(0.02413, 0.0254, 0.5)
section2 = workPart.Sections.CreateSection(0, 0, 0)
throughCurvesBuilder1.SectionsList.Append(section2)
Dim curves2(0) As Curve
Dim spline2 As Spline = CType(workPart.Splines.FindObject("HANDLE R-1009"), Spline)
curves2(0) = spline2
Dim curveDumbRule2 As CurveDumbRule
curveDumbRule2 = workPart.ScRuleFactory.CreateRuleCurveDumb(curves2)
section2.AllowSelfIntersection(False)
Dim rules2(0) As SelectionIntentRule
rules2(0) = curveDumbRule2
'Dim helpPoint2 As Point3d = New Point3d(-0.47085171196338, 11.2741306270377, 34.5208423535177)
Dim helpPoint2 As Point3d = New Point3d(0, 0,0)
section2.AddToSection(rules2, spline2, nullNXObject, nullNXObject, helpPoint2, Section.Mode.Create, False)
Dim sections2(1) As Section
sections2(0) = section1
sections2(1) = section2
throughCurvesBuilder1.Alignment.SetSections(sections2)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim section3 As Section
'section3 = workPart.Sections.CreateSection(0.02413, 0.0254, 0.5)
section3 = workPart.Sections.CreateSection(0, 0, 0)
throughCurvesBuilder1.SectionsList.Append(section3)
Dim curves3(0) As Curve
Dim spline3 As Spline = CType(workPart.Splines.FindObject("HANDLE R-1008"), Spline)
curves3(0) = spline3
Dim curveDumbRule3 As CurveDumbRule
curveDumbRule3 = workPart.ScRuleFactory.CreateRuleCurveDumb(curves3)
section3.AllowSelfIntersection(False)
Dim rules3(0) As SelectionIntentRule
rules3(0) = curveDumbRule3
'Dim helpPoint3 As Point3d = New Point3d(-0.569549366703497, 14.8718526944548, 34.5552979106851)
Dim helpPoint3 As Point3d = New Point3d(0, 0, 0)
section3.AddToSection(rules3, spline3, nullNXObject, nullNXObject, helpPoint3, Section.Mode.Create, False)
Dim sections3(2) As Section
sections3(0) = section1
sections3(1) = section2
sections3(2) = section3
throughCurvesBuilder1.Alignment.SetSections(sections3)
Dim feature1 As Features.Feature
feature1 = throughCurvesBuilder1.CommitFeature()
Dim displayModification1 As DisplayModification
displayModification1 = theSession.DisplayManager.NewDisplayModification()
displayModification1.ApplyToAllFaces = False
displayModification1.SetNewGrid(0, 0)
displayModification1.PoleDisplayState = False
displayModification1.KnotDisplayState = False
Dim objects1(0) As DisplayableObject
Dim throughCurves1 As Features.ThroughCurves = CType(feature1, Features.ThroughCurves)
throughCurvesBuilder1.Destroy()
workPart.FacetedBodies.DeleteTemporaryFacesAndEdges()
End Sub
Function SelectAnObject(prompt As String, _
ByRef selObj As NXObject) As Selection.Response
Dim theUI As UI = UI.GetUI
Dim cursor As Point3d
Dim typeArray() As Selection.SelectionType = _
{Selection.SelectionType.All, _
Selection.SelectionType.Faces, _
Selection.SelectionType.Edges, _
Selection.SelectionType.Features}
Dim resp As Selection.Response = theUI.SelectionManager.SelectObject( _
prompt, "Selection", _
Selection.SelectionScope.AnyInAssembly, _
False, typeArray, selobj, cursor)
If resp = Selection.Response.ObjectSelected Or _
resp = Selection.Response.ObjectSelectedByName Then
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
End If
End Function
End Module
re: spline ID
I don't think there is any guarantee that the spline ID's will be in numerical order. That is not a very robust way to select the desired spline objects.
But if you want the ID, the code in the link below will get it:
http://nxjournaling.com/comment/458#comment-458