NX 7.5 Journaling: Problems with using arc center of created arc later on in code
NX 7.5 Journaling: Problems with using arc center of created arc later on in code
(OP)
So, I've been combing through the help file and trying all sorts of round about options which don't see to be any good or very robust. Here's my issue: I create an associative arc from three points (start, end, mid) and then need to use the center point of the arc later to create an associative line. Here's my function for creating the arc:
Function Arc_Three_Points(ByVal Start_Point As Point, ByVal End_Point As Point, ByVal Mid_Point As Point, ByVal Name As String) As Features.AssociativeArc
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim featureList As Features.FeatureCollection = workPart.Features
Dim nullFeatures_AssociativeArc As Features.AssociativeArc = Nothing
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 associativeArcBuilder1 As Features.AssociativeArcBuilder
associativeArcBuilder1 = workPart.BaseFeatures.CreateAssociativeArcBuilder(nullFeatures_AssociativeArc)
Dim nullXform As Xform = Nothing
Dim start_pt As Point
Dim end_pt As Point
Dim mid_pt As Point
start_pt = workPart.Points.CreatePoint(Start_Point, nullXform, SmartObject.UpdateOption.WithinModeling)
end_pt = workPart.Points.CreatePoint(End_Point, nullXform, SmartObject.UpdateOption.WithinModeling)
mid_pt = workPart.Points.CreatePoint(Mid_Point, nullXform, SmartObject.UpdateOption.WithinModeling)
associativeArcBuilder1.StartPoint.Value = start_pt
associativeArcBuilder1.StartPointOptions = Features.AssociativeArcBuilder.StartOption.Point
associativeArcBuilder1.EndPoint.Value = end_pt
associativeArcBuilder1.EndPointOptions = Features.AssociativeArcBuilder.EndOption.Point
associativeArcBuilder1.MidPoint.Value = mid_pt
associativeArcBuilder1.MidPointOptions = Features.AssociativeArcBuilder.MidOption.Point
Dim nXObject1 As Features.AssociativeArc
nXObject1 = associativeArcBuilder1.Commit()
nXObject1.SetName(Name)
Return nXObject1
End Function
Later, I call it using these lines:
Dim Best_Fit_Arc As Features.AssociativeArc
Best_Fit_Arc = Arc_Three_Points(posterior_pt, anterior_pt, superior_pt, "Best Fit Circle")
And finally, to create the line, I use this function:
Function Line_Start_End_Points(ByVal Start_Point As Point, ByVal End_Point As Point, ByVal Name As String) As Features. AssociativeLine
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim pointList As PointCollection = workPart.Points
Dim featureList As Features.FeatureCollection = workPart.Features
Dim nullFeatures_AssociativeLine As Features.AssociativeLine = Nothing
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 associativeLineBuilder1 As Features.AssociativeLineBuilder
associativeLineBuilder1 = workPart.BaseFeatures.CreateAssociativeLineBuilder(nullFeatures_AssociativeLine)
Dim nullXform As Xform = Nothing
Dim start_pt As Point
start_pt = workPart.Points.CreatePoint(Start_Point, nullXform, SmartObject.UpdateOption.WithinModeling)
associativeLineBuilder1.StartPoint.Value = start_pt
associativeLineBuilder1.StartPointOptions = Features.AssociativeLineBuilder.StartOption.Point
Dim end_pt As Point
end_pt = workPart.Points.CreatePoint(End_Point, nullXform, SmartObject.UpdateOption.WithinModeling)
associativeLineBuilder1.EndPoint.Value = end_pt
associativeLineBuilder1.EndPointOptions = Features.AssociativeLineBuilder.EndOption.Point
Dim nXObject1 As Features.AssociativeLine
nXObject1 = associativeLineBuilder1.Commit()
nXObject1.SetName(Name)
Return nXObject1
End Function
And then call it using:
Dim Initial_Planning_Axis As Features.AssociativeLine
Initial_Planning_Axis = Line_Start_Point_End(medial_border_pt, Best_Fit_Arc.CenterPoint, "Initial Planning Axis")
Where all points used for inputs are of type Point, not Point3D.
Is there anyway for me to get the arc center when it's being created and then use it later for the line creation? Also, I'd prefer the arc center to be of type Point and not Point3D. If it is of type Point3D, then how would I go about using that to create the line while still keeping associativity.
Thank you so much, any help is greatly appreciated.
Function Arc_Three_Points(ByVal Start_Point As Point, ByVal End_Point As Point, ByVal Mid_Point As Point, ByVal Name As String) As Features.AssociativeArc
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim featureList As Features.FeatureCollection = workPart.Features
Dim nullFeatures_AssociativeArc As Features.AssociativeArc = Nothing
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 associativeArcBuilder1 As Features.AssociativeArcBuilder
associativeArcBuilder1 = workPart.BaseFeatures.CreateAssociativeArcBuilder(nullFeatures_AssociativeArc)
Dim nullXform As Xform = Nothing
Dim start_pt As Point
Dim end_pt As Point
Dim mid_pt As Point
start_pt = workPart.Points.CreatePoint(Start_Point, nullXform, SmartObject.UpdateOption.WithinModeling)
end_pt = workPart.Points.CreatePoint(End_Point, nullXform, SmartObject.UpdateOption.WithinModeling)
mid_pt = workPart.Points.CreatePoint(Mid_Point, nullXform, SmartObject.UpdateOption.WithinModeling)
associativeArcBuilder1.StartPoint.Value = start_pt
associativeArcBuilder1.StartPointOptions = Features.AssociativeArcBuilder.StartOption.Point
associativeArcBuilder1.EndPoint.Value = end_pt
associativeArcBuilder1.EndPointOptions = Features.AssociativeArcBuilder.EndOption.Point
associativeArcBuilder1.MidPoint.Value = mid_pt
associativeArcBuilder1.MidPointOptions = Features.AssociativeArcBuilder.MidOption.Point
Dim nXObject1 As Features.AssociativeArc
nXObject1 = associativeArcBuilder1.Commit()
nXObject1.SetName(Name)
Return nXObject1
End Function
Later, I call it using these lines:
Dim Best_Fit_Arc As Features.AssociativeArc
Best_Fit_Arc = Arc_Three_Points(posterior_pt, anterior_pt, superior_pt, "Best Fit Circle")
And finally, to create the line, I use this function:
Function Line_Start_End_Points(ByVal Start_Point As Point, ByVal End_Point As Point, ByVal Name As String) As Features. AssociativeLine
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim pointList As PointCollection = workPart.Points
Dim featureList As Features.FeatureCollection = workPart.Features
Dim nullFeatures_AssociativeLine As Features.AssociativeLine = Nothing
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 associativeLineBuilder1 As Features.AssociativeLineBuilder
associativeLineBuilder1 = workPart.BaseFeatures.CreateAssociativeLineBuilder(nullFeatures_AssociativeLine)
Dim nullXform As Xform = Nothing
Dim start_pt As Point
start_pt = workPart.Points.CreatePoint(Start_Point, nullXform, SmartObject.UpdateOption.WithinModeling)
associativeLineBuilder1.StartPoint.Value = start_pt
associativeLineBuilder1.StartPointOptions = Features.AssociativeLineBuilder.StartOption.Point
Dim end_pt As Point
end_pt = workPart.Points.CreatePoint(End_Point, nullXform, SmartObject.UpdateOption.WithinModeling)
associativeLineBuilder1.EndPoint.Value = end_pt
associativeLineBuilder1.EndPointOptions = Features.AssociativeLineBuilder.EndOption.Point
Dim nXObject1 As Features.AssociativeLine
nXObject1 = associativeLineBuilder1.Commit()
nXObject1.SetName(Name)
Return nXObject1
End Function
And then call it using:
Dim Initial_Planning_Axis As Features.AssociativeLine
Initial_Planning_Axis = Line_Start_Point_End(medial_border_pt, Best_Fit_Arc.CenterPoint, "Initial Planning Axis")
Where all points used for inputs are of type Point, not Point3D.
Is there anyway for me to get the arc center when it's being created and then use it later for the line creation? Also, I'd prefer the arc center to be of type Point and not Point3D. If it is of type Point3D, then how would I go about using that to create the line while still keeping associativity.
Thank you so much, any help is greatly appreciated.





RE: NX 7.5 Journaling: Problems with using arc center of created arc later on in code
Frank swinkels
CODE -->
Option Strict Off Imports System Imports NXOpen Imports NXOpen.Features Module associatives1 Dim s As Session = Session.GetSession() Dim ui As UI = UI.GetUI() Dim workPart As Part = s.Parts.Work Sub Main() Dim spoint As Point = Nothing Dim mpoint As Point = Nothing Dim epoint As Point = Nothing Dim arcname As String = "Arc1" Dim linename As String = "Line1" Dim point1 As Point3d = New Point3d(50.0, 0.0, 0.0) Dim spointObj As Point = workPart.Points.CreatePoint(point1) Dim point2 As Point3d = New Point3d(0.0, 20.0, 0.0) Dim mpointObj As Point = workPart.Points.CreatePoint(point2) Dim point3 As Point3d = New Point3d(-50.0, 0.0, 0.0) Dim epointObj As Point = workPart.Points.CreatePoint(point3) Dim assocarc As AssociativeArc = Arc_Three_Points(spointObj, epointObj, mpointObj, arcname) Dim arc1() As NXObject = assocarc.GetEntities Dim arc2 As Arc = DirectCast(arc1(0), Arc) Dim cpointobj As Point = workPart.Points.CreatePoint(arc2, SmartObject.UpdateOption.WithinModeling) Dim assocline As AssociativeLine = Line_Start_End_Points(cpointobj, epointObj, linename) End Sub Function Arc_Three_Points(ByVal Start_Point As Point, ByVal End_Point As Point, ByVal Mid_Point As Point, ByVal Name As String) As Features.AssociativeArc Dim nullFeatures_AssociativeArc As Features.AssociativeArc = Nothing Dim associativeArcBuilder1 As Features.AssociativeArcBuilder associativeArcBuilder1 = workPart.BaseFeatures.CreateAssociativeArcBuilder(nullFeatures_AssociativeArc) Dim nullXform As Xform = Nothing Dim start_pt As Point Dim end_pt As Point Dim mid_pt As Point start_pt = workPart.Points.CreatePoint(Start_Point, nullXform, SmartObject.UpdateOption.WithinModeling) end_pt = workPart.Points.CreatePoint(End_Point, nullXform, SmartObject.UpdateOption.WithinModeling) mid_pt = workPart.Points.CreatePoint(Mid_Point, nullXform, SmartObject.UpdateOption.WithinModeling) associativeArcBuilder1.StartPoint.Value = start_pt associativeArcBuilder1.StartPointOptions = Features.AssociativeArcBuilder.StartOption.Point associativeArcBuilder1.EndPoint.Value = end_pt associativeArcBuilder1.EndPointOptions = Features.AssociativeArcBuilder.EndOption.Point associativeArcBuilder1.MidPoint.Value = mid_pt associativeArcBuilder1.MidPointOptions = Features.AssociativeArcBuilder.MidOption.Point Dim nXObject1 As Features.AssociativeArc nXObject1 = associativeArcBuilder1.Commit() nXObject1.SetName(Name) Return nXObject1 End Function Function Line_Start_End_Points(ByVal Start_Point As Point, ByVal End_Point As Point, ByVal Name As String) As Features.AssociativeLine Dim nullFeatures_AssociativeLine As Features.AssociativeLine = Nothing Dim associativeLineBuilder1 As Features.AssociativeLineBuilder associativeLineBuilder1 = workPart.BaseFeatures.CreateAssociativeLineBuilder(nullFeatures_AssociativeLine) Dim nullXform As Xform = Nothing Dim start_pt As Point start_pt = workPart.Points.CreatePoint(Start_Point, nullXform, SmartObject.UpdateOption.WithinModeling) associativeLineBuilder1.StartPoint.Value = start_pt associativeLineBuilder1.StartPointOptions = Features.AssociativeLineBuilder.StartOption.Point Dim end_pt As Point end_pt = workPart.Points.CreatePoint(End_Point, nullXform, SmartObject.UpdateOption.WithinModeling) associativeLineBuilder1.EndPoint.Value = end_pt associativeLineBuilder1.EndPointOptions = Features.AssociativeLineBuilder.EndOption.Point Dim nXObject1 As Features.AssociativeLine nXObject1 = associativeLineBuilder1.Commit() nXObject1.SetName(Name) Return nXObject1 End Function Public Function GetUnloadOption(ByVal arg As String) As Integer Return CType(Session.LibraryUnloadOption.Immediately, Integer) End Function End Module