The requirement is to make a LeaderNote which is constrained with the hole centers. Thus when the geometry changes, the LeaderNote will update accordingly.

The code below shows how to create a leader with one or more hole centers.
' create leader note with one hole Sub AddLeaderNoteWithHoleCenter() ' assumes you have had Inventor application Dim oDrawDoc As DrawingDocument = _ _InvApplication.ActiveDocument Dim oActiveSheet As Sheet = _ oDrawDoc.ActiveSheet ' get curve, assume a hole curve is selected Dim oDrawingCurveSegment As DrawingCurveSegment = _ oDrawDoc.SelectSet(1) Dim oDrawingCurve As DrawingCurve = _ oDrawingCurveSegment.Parent ' get center point Dim oMidPoint As Point2d = _ oDrawingCurve.CenterPoint Dim oTG As TransientGeometry = _ _InvApplication.TransientGeometry Dim oLeaderPoints As ObjectCollection = _ _InvApplication.TransientObjects. _ CreateObjectCollection Call oLeaderPoints.Add(oTG.CreatePoint2d( _ oMidPoint.X + 5, _ oMidPoint.Y + 5)) ' Create geometry intent from center point Dim oGeometryIntent As GeometryIntent = _ oActiveSheet.CreateGeometryIntent(oDrawingCurve, _ oMidPoint) Call oLeaderPoints.Add(oGeometryIntent) Dim sText As String sText = "Leader Note for one hole center" ' add leader note Dim o
LeaderNote As LeaderNote = _ oActiveSheet.DrawingNotes.LeaderNotes.Add _ (oLeaderPoints, _ sText) End Sub
<p> </p> <pre class="line-numbers"><code>' create leader notes for two holes</code></pre>
Sub AddLeaderNoteWithTwoHoles() _InvApplication = _ Runtime.InteropServices.Marshal. _ GetActiveObject("Inventor.Application") ' assumes you have had Inventor application Dim oDrawDoc As DrawingDocument = _ _InvApplication.ActiveDocument Dim oActiveSheet As Sheet = _ oDrawDoc.ActiveSheet Dim oTG As TransientGeometry = _ _InvApplication.TransientGeometry Dim oLeaderPoints1 As ObjectCollection = _ _InvApplication.TransientObjects. _ CreateObjectCollection Call oLeaderPoints1.Add( _ oTG.CreatePoint2d(25, 15)) Dim oDrawingCurveSegment1 As DrawingCurveSegment = _ oDrawDoc.SelectSet(1) Dim oDrawingCurveSegment2 As DrawingCurveSegment = _ oDrawDoc.SelectSet(2) Dim oDrawingCurve1 As DrawingCurve = _ oDrawingCurveSegment1.Parent Dim oMidPoint1 As Point2d = _ oDrawingCurve1.CenterPoint Dim oGeometryIntent1 As GeometryIntent = _ oActiveSheet.CreateGeometryIntent( _ oDrawingCurve1, oMidPoint1) Call oLeaderPoints1.Add(oGeometryIntent1) Dim sText As String sText = "LeaderNote for two hole centers" Dim oLeaderNote As LeaderNote = _ oActiveSheet.DrawingNotes.LeaderNotes.Add( _ oLeaderPoints1, sText) Dim oDrawingCurve2 As DrawingCurve = _ oDrawingCurveSegment2.Parent Dim oMidPoint2 As Point2d = _ oDrawingCurve2.CenterPoint Dim oGeometryIntent2 As GeometryIntent = _ oActiveSheet.CreateGeometryIntent( _ oDrawingCurve2, oMidPoint2) Dim oLeaderPoints2 As ObjectCollection = _ _InvApplication.TransientObjects. _ CreateObjectCollection oLeaderPoints2.Add(oGeometryIntent2) ' add a new leader if the leader note has no leader, ' otherwise add a branch leader If oLeaderNote.Leader.HasRootNode Then ' add a branch leader based on the root node oLeaderNote.Leader.RootNode.AddLeader(oLeaderPoints2) Else ' add a new leader when 'LeaderNote.Leader.HasRootNode = False oLeaderNote.Leader.AddLeader(oLeaderPoints2) End If End Sub

Leave a Reply