I got this to work. Highlighted the parts in red I added.
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
MsgBox("A Drawing Document must be active for this rule to work. Exiting.", vbOKOnly + vbCritical, "WRONG DOCUMENT TYPE")
Exit Sub
End If
Dim oDDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Inventor.Sheet = oDDoc.ActiveSheet
Dim oDCurve As DrawingCurveSegment
Dim prpname As String = "Tag"
Dim oDesc As String
RepeatProcess :
oDCurve = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Select a DrawingCurveSegment.")
If oDCurve Is Nothing Then
MsgBox("Nothing was selected. Exiting.")
Exit Sub
End If
Dim oView As DrawingView = oDCurve.Parent.Parent
'check view doc's type first, then use that to determine edge type (Edge or EdgeProxy), and other stuff
Dim oDTProps As PropertySet
Dim oQty As Integer
Dim oPN As String
If oView.ReferencedDocumentDescriptor.ReferencedDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
Dim oViewDoc As AssemblyDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument
Dim oEdge As EdgeProxy = oDCurve.Parent.ModelGeometry
Dim oBody As SurfaceBodyProxy = oEdge.Parent
Dim oOcc As ComponentOccurrence = oBody.Parent
Dim prp As PropertySet = Nothing
Do Until oOcc Is Nothing
Try
prp = oOcc.OccurrencePropertySets.Item(1)
Exit Do
Catch : End Try
oOcc = oOcc.ParentOccurrence
Loop
If prp Is Nothing Then
MessageBox.Show("No instance property exists")
Exit Sub
End If
Dim oOccDoc As Document = oOcc.Definition.Document
oDTProps = oOccDoc.PropertySets.Item("Design Tracking Properties")
oPN = oDTProps.Item("Part Number").Value
oQty = oViewDoc.ComponentDefinition.Occurrences.AllLeafOccurrences(oOcc.Definition).Count
oDesc = prp.Item(prpname).Value
End If
'create a new LeaderNote attached to the selected geometry
Dim oGeomIntent As GeometryIntent = oSheet.CreateGeometryIntent(oDCurve.Parent, .5)
Dim oPt As Point2d = ThisApplication.TransientGeometry.CreatePoint2d((oView.Left + oView.Width), oView.Top)
Dim oLeaderPoints As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
oLeaderPoints.Add(oPt)
oLeaderPoints.Add(oGeomIntent)
Dim oFText As String = oDesc & "<Br/>" & "Part No. " & oPN & "<Br/>" & "Qty. " & oQty
Dim oLNote As LeaderNote = oSheet.DrawingNotes.LeaderNotes.Add(oLeaderPoints, oFText)
oRepeat = MsgBox("Create another custom leader?", vbYesNo + vbQuestion, "REPEAT?")
If oRepeat = vbYes Then GoTo RepeatProcess
You might want to add a way to change the leader point when creating multiple leaders in a view so they arnt all stacked up on eachother.