Hi @MichaelLockhart3046
I don't know if you want the code to write the feature name in the holes or if you just want to compare the feature name to a string with your IsEqual-function. I've edited the code for both scenarios.
Write name of feature in hole:
Sub Main()
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisDoc.Document
Dim oSketch As DrawingSketch
oSketch = oDrawDoc.ActiveSheet.Sketches.Add
oSketch.Edit
Dim oTG As TransientGeometry
oTG = ThisApplication.TransientGeometry
Dim oView As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select Drawing View")
For Each oCurve As DrawingCurve In oView.DrawingCurves
Try
If oCurve.CurveType = kCircleCurve Then
Dim oEdge As Edge = oCurve.ModelGeometry
If oEdge IsNot Nothing
For Each oFace As Face In oEdge.Faces
If TypeOf (oFace.CreatedByFeature) Is HoleFeature
x = oCurve.CenterPoint.X
y = oCurve.CenterPoint.Y
txtbx = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(x, y), oFace.CreatedByFeature.Name)
txtbx.HorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextCenter
txtbx.VerticalJustification = VerticalTextAlignmentEnum.kAlignTextMiddle
txtbx.Style.FontSize = 0.23
End If
Next
End If
End If
Catch
'MsgBox("Error")
End Try
Next
' Exit the sketch from the edit environment.
oSketch.ExitEdit
End Sub
Compare feature name to string with function:
Sub Main()
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisDoc.Document
Dim oSketch As DrawingSketch
oSketch = oDrawDoc.ActiveSheet.Sketches.Add
oSketch.Edit
Dim oTG As TransientGeometry
oTG = ThisApplication.TransientGeometry
Dim oView As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select Drawing View")
For Each oCurve As DrawingCurve In oView.DrawingCurves
Try
If oCurve.CurveType = kCircleCurve Then
Dim oEdge As Edge = oCurve.ModelGeometry
If oEdge IsNot Nothing
If IsEqual(oEdge, "Hole1")
x = oCurve.CenterPoint.X
y = oCurve.CenterPoint.Y
txtbx = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(x, y), "S12")
txtbx.HorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextCenter
txtbx.VerticalJustification = VerticalTextAlignmentEnum.kAlignTextMiddle
txtbx.Style.FontSize = 0.23
End If
End If
End If
Catch
'MsgBox("Error")
End Try
Next
' Exit the sketch from the edit environment.
oSketch.ExitEdit
End Sub
Function IsEqual(oEdge As Edge, fName As String) As Boolean
For Each oFace As Face In oEdge.Faces
If oFace.CreatedByFeature.Name = fName Then Return True
Next
Return False
End Function
I hope one of them is what youre looking for 🙂