Here. I'll make your day. Exactly as mine is. It's a little more complicated; we use 2 symbols just because the orientation of the text changes with respect to the arrows for 2 cases, but it'll get you most of the way there
'SECTION SYMBOL WIZARD
'JRK - 30.Jun.15
'PURPOSE - By running this rule, it allows you to place section symbols and tweak them for each drawing view in the sheet
'v0 - RELEASE
Sub Main()
'Variable Declarations
Dim oDwgDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSelectSet As SelectSet
Dim oCommandMgr As CommandManager = ThisApplication.CommandManager
Dim oDLine As DrawingCurveSegment
Dim oView As DrawingView
Dim oSketch As DrawingSketch
Dim oLine As SketchLine
Dim oSecLine As SketchLine
Dim oSecEP As Point2d
Dim oSecSP As Point2d
Dim angle As Double
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oGeometryIntent1 As GeometryIntent
Dim oLeaderPoints1 As ObjectCollection
Dim oGeometryIntent2 As GeometryIntent
Dim oLeaderPoints2 As ObjectCollection
Dim oSSD As SketchedSymbolDefinition
Dim oSSD1 As SketchedSymbolDefinition
Dim oSSD2 As SketchedSymbolDefinition
Dim oSSD3 As SketchedSymbolDefinition
Dim oControlDef1 As ControlDefinition
Dim oTextBoxes As TextBoxes
Dim FS As Boolean = True
Dim RS As Boolean = True
'''Begin functionality
oDLine = oCommandMgr.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Select the LINE")
oSP = oDLine.StartPoint
oEP = oDLine.EndPoint
Dim oV1 As Vector2d
Dim oV2 As Vector2d
If oEP.Y > oSP.Y
oV1 = ThisApplication.TransientGeometry.CreateVector2d(oEP.X - oSP.X, oEP.Y - oSP.Y)
oV2 = ThisApplication.TransientGeometry.CreateVector2d(1, 0)
Else
oV1 = ThisApplication.TransientGeometry.CreateVector2d(oSP.X - oEP.X, oSP.Y - oEP.Y)
oV2 = ThisApplication.TransientGeometry.CreateVector2d(1, 0)
End If
angle = oV2.AngleTo(oV1)
For Each oView In oDwgDoc.ActiveSheet.DrawingViews
For Each oSketch In oView.Sketches
For Each oLine In oSketch.SketchLines
If Math.Abs(Math.Round(oView.Scale*(oLine.StartSketchPoint.Geometry.X - oLine.EndSketchPoint.Geometry.X),3)) = Math.Abs(Math.Round((oSP.X - oEP.X),3)) And _
Math.Abs(Math.Round(oView.Scale*(oLine.StartSketchPoint.Geometry.Y - oLine.EndSketchPoint.Geometry.Y),3)) = Math.Abs(Math.Round((oSP.Y - oEP.Y),3))
oSecLine = oLine
oCP = oTG.CreatePoint2d(oSketch.Parent.Position.X, oSketch.Parent.Position.Y)
oSecSP = oTG.CreatePoint2d(oCP.X +oSecLine.StartSketchPoint.Geometry.X*oView.Scale, oCP.Y + oSecLine.StartSketchPoint.Geometry.Y*oView.Scale)
oSecEP = oTG.CreatePoint2d(oCP.X +oSecLine.EndSketchPoint.Geometry.X*oView.Scale, oCP.Y + oSecLine.EndSketchPoint.Geometry.Y*oView.Scale)
End If
Next
Next
Next
oLeaderPoints1 = ThisApplication.TransientObjects.CreateObjectCollection
'oLeaderPoints1.Add(oSP)
'oLeaderPoints1.Add(oSecSP)
oGeometryIntent1 = oDwgDoc.ActiveSheet.CreateGeometryIntent(oSecLine, oSecSP)
oLeaderPoints1.Add(oGeometryIntent1)
oLeaderPoints2 = ThisApplication.TransientObjects.CreateObjectCollection
'oLeaderPoints2.Add(oEP)
'oLeaderPoints2.Add(oSecEP)
oGeometryIntent2 = oDwgDoc.ActiveSheet.CreateGeometryIntent(oSecLine, oSecEP)
oLeaderPoints2.Add(oGeometryIntent2)
Dim PromptStrings(0 To 1) As String
PromptStrings(0) = ""
PromptStrings(1) = ""
oSSD1 = oDwgDoc.SketchedSymbolDefinitions.Item("Section Tail")
oSSD2 = oDwgDoc.SketchedSymbolDefinitions.Item("Section Symbol - Up")
oSSD3 = oDwgDoc.SketchedSymbolDefinitions.Item("Section Symbol - Down")
angle = NormalizeAngle(angle + Math.PI)
'Decide which sketched symbol to use based upon angle
If (0 <= angle And angle < (Math.PI/2)) Or (3*Math.PI/2) <= angle And angle < (2*Math.PI)
oSSD = oSSD2
angle1 = angle
Else
oSSD = oSSD3
angle1 = NormalizeAngle(angle + Math.PI)
End If
oS1 = oDwgDoc.ActiveSheet.SketchedSymbols.AddWithLeader(oSSD1,oLeaderPoints1,angle,1,,False,True)
oS1.LeaderVisible = False
oS2 = oDwgDoc.ActiveSheet.SketchedSymbols.AddWithLeader(oSSD,oLeaderPoints2,angle1,1,PromptStrings,False,True)
oS2.LeaderVisible = False
oSelectSet = oDwgDoc.SelectSet
oSelectSet.Clear
oSelectSet.Select(oS2)
oControlDef1 = oCommandMgr.ControlDefinitions.Item("DrawingEditFieldTextCmd")
oControlDef1.Execute
oTextBoxes = oS2.Definition.Sketch.TextBoxes
PromptStrings(0) = oS2.GetResultText(oTextBoxes.Item(1))
PromptStrings(1) = oS2.GetResultText(oTextBoxes.Item(2))
While FS = True And RS = True
'Reset
FS = True
RS = True
'Rotate Symbol
oRS = MsgBox("Rotate Symbols 180 degrees?", MsgBoxStyle.YesNo, "Section Symbols")
If oRS = vbNo
RS = False
Else
oS1.Delete
oS2.Delete
angle = NormalizeAngle(angle + Math.PI)
If (0 <= angle And angle < (Math.PI/2)) Or (3*Math.PI/2) <= angle And angle < (2*Math.PI)
oSSD = oSSD2
Else
oSSD = oSSD3
angle1 = NormalizeAngle(angle + Math.PI)
End If
oS1 = oDwgDoc.ActiveSheet.SketchedSymbols.AddWithLeader(oSSD1,oLeaderPoints1,angle,1,,False,True)
oS1.LeaderVisible = False
oS2 = oDwgDoc.ActiveSheet.SketchedSymbols.AddWithLeader(oSSD,oLeaderPoints2,angle1,1,PromptStrings,False,True)
oS2.LeaderVisible = False
End If
'Swap Symbols
oFS = MsgBox("Swap Head and Tail?", MsgBoxStyle.YesNo, "Section Symbols")
If oFS = vbNo
FS = False
Else
oS1.Delete
oS2.Delete
oS1 = oDwgDoc.ActiveSheet.SketchedSymbols.AddWithLeader(oSSD1,oLeaderPoints2,angle,1,,False,True)
oS1.LeaderVisible = False
oS2 = oDwgDoc.ActiveSheet.SketchedSymbols.AddWithLeader(oSSD,oLeaderPoints1,angle1,1,PromptStrings,False,True)
oS2.LeaderVisible = False
End If
End While 'Fs / RS = True
oRemoveLabels
End Sub
Function NormalizeAngle(angle As Double)
Dim oAngle As Double
Dim multiple As Integer
If Math.Abs(angle) >= 2*Math.PI
multiple = angle \ 2*Math.PI
oAngle = angle - multiple*2*Math.PI
Else
oAngle = angle
End If
Return oAngle
End Function
Sub oRemoveLabels
Dim oDoc As Document = ThisApplication.ActiveDocument
Dim oView As DrawingView
Dim i As String = ""
For Each oView In oDoc.ActiveSheet.DrawingViews
If oView.Type = ObjectTypeEnum.kSectionDrawingViewObject
oView.ShowLabel = False
i = " " + i
oView.Name = i
End If
Next
End Sub
--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.