Basically, I need to create the view labels using leaders because the labels so created are very friendly: they can be underlined or bold as required, deleted unnecessary or add additional text, add blank row etc..
I am using the center of the selected view. I am getting what I need, but I have two issues:
- I am still selecting a linear drawing curve (in addition to selecting a drawing view)
- Leader exists after the rule is done (need to know how can I delete the leader)
I delete the leader (manually) at the end.
Is it possible to assign the ordinates of the picked point (oPickedPoint) in the view:
e.g.: ...CreatePoint2d(oPickedPoint)
Sub Main()
On Error Goto 100:' Set a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
' Set a reference to the active sheet.
Dim oActiveSheet As Sheet
oActiveSheet = oDrawDoc.ActiveSheet
' Manually select a drawing view
Dim oDrawingView As DrawingView
oDrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "SELECT A DRAWING VIEW:")
oDrawingViewName = oDrawingView.Name
oCurve_Selected = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "SELECT A SUITABLE CURVE FROM A DRAWING VIEW")
' Set a reference to the drawing curve segment.
' This assumes that a drawing curve is selected.
Dim oDrawingCurveSegment As DrawingCurveSegment
oDrawingCurveSegment = oCurve_Selected 'oDrawDoc.SelectSet.Item(1)
' Set a reference to the drawing curve.
Dim oDrawingCurve As DrawingCurve
oDrawingCurve = oDrawingCurveSegment.Parent
' a reference to the center of the base view.
Dim oPoint As Point2d
oPoint = oDrawingView.Center
Dim oTG As TransientGeometry
oTG = ThisApplication.TransientGeometry
Dim oLeaderPoints As ObjectCollection
oLeaderPoints = ThisApplication.TransientObjects.CreateObjectCollection
' Create a few leader points.
oAdjust_X_Left = -oDrawingView.Width*0
oAdjust_Y_Down = -oDrawingView.Height/2-1
MessageBox.Show("oAdjust_Y: " & oAdjust_Y_Down, "Title")
Call oLeaderPoints.Add(oTG.CreatePoint2d(oPoint.X + oAdjust_X_Left, oPoint.Y + oAdjust_Y_Down))
Dim oGeometryIntent As GeometryIntent
oGeometryIntent = oActiveSheet.CreateGeometryIntent(oDrawingCurve)
Call oLeaderPoints.Add(oGeometryIntent)
Dim sText As String
oModelDoc = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName)
If iProperties.Value(oModelDoc, "Custom", "TOTAL_QTY") = "1" Then
iProperties.Value(oModelDoc, "Custom", "TOTAL_QTY_VL") = "ONE"
Else
iProperties.Value(oModelDoc, "Custom", "TOTAL_QTY_VL") = iProperties.Value(oModelDoc, "Custom", "TOTAL_QTY")
End If
'sText = "API Leader Note"
oTOTAL_QTY_VL = iProperties.Value(oModelDoc, "Custom", "TOTAL_QTY_VL")
oTITLE = iProperties.Value(oModelDoc, "Summary", "Title")
oPartNumber = iProperties.Value(oModelDoc, "Project", "Part Number")
sText = oTOTAL_QTY_VL & " REQ'D " & " - " & oTITLE & " - " & oPartNumber _
& vbCrLf & "NOTE:" & vbCrLf & "SOME COMPONENTS NOT SHOWN FOR CLARITY"
Dim oLeaderNote As LeaderNote
oLeaderNote = oActiveSheet.DrawingNotes.LeaderNotes.Add(oLeaderPoints, sText)
' Insert a node.
Dim oFirstNode As LeaderNode
oFirstNode = oLeaderNote.Leader.RootNode.ChildNodes.Item(1)
100:End Sub
Could you help.
Thanks.