cquinker
Bioengineer
- Sep 20, 2012
- 16
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.