Extracting view information for sketch symbols
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I am currently using Ilogic automatically place and name custom view labels in drawings. The script goes through the sheet and for every view deletes any old labels, extracts the scale, view name, sheet number and view number and replaces the view label in roughly the center. The sketch symbol is a series of prompted entries and the info once placed is not associated.
The issue I am running into is when I have to update any of the information on the view label I have to run the script again which deletes all the old labels and replace them with the new information. this move the labels which isn't really a problem its just kind of annoying. What I want is a method or property of the sketch object that tells you what the sketch symbol is linked to. I know there is "parent" but the documentation on that is pretty sparse.
Is there an easier way of doing this I am missing? Here is the script as it stands:
Sub Main() Dim oDoc As DrawingDocument = ThisDoc.Document Dim oSheets As Sheets = oDoc.Sheets Dim oSheet As Sheet Dim oViews As DrawingViews Dim oView As DrawingView Dim oSymbol As SketchedSymbol Dim oSymbols As SketchedSymbols Dim SymbolName = New String("View_label") 'iterate through all of the sheets 'For Each oSheet In oSheets 'remove existing sketched symbols named View Label oSheet = oDoc.ActiveSheet For Each oSymbol In oSheet.SketchedSymbols If oSymbol.Definition.Name = SymbolName Then oSymbol.Delete Else End If Next 'set sheet active oSheet.Activate 'set a refernce to the drawing views collection oViews = oDoc.ActiveSheet.DrawingViews ' Iterate through all of the views Dim ViewNum As Integer = 1 For Each oView In oViews 'removes old label styles If oView.ShowLabel Then oView.ShowLabel = False End If 'This places a sketched symbol with the name "View_Label" Dim oSymDef As SketchedSymbolDefinition 'defind the sketch symbol to be inserted oSymDef = oDoc.SketchedSymbolDefinitions.Item(SymbolName) 'autofill missing info for detail and section views Dim sViewName As String If oView.Type = ObjectTypeEnum.kSectionDrawingViewObject Then sViewName = "SECTION: "& oView.Name & "-" & oView.Name Else If oView.Type = ObjectTypeEnum.kDetailDrawingViewObject Then sViewName = "DETAIL: " & oView.Name Else sViewName = oView.Name Logger.Debug(oView.AttributeSets.Type.ToString) End If 'set a string array with values for the prompted entries found in the symbol Dim sPromptStrings(3) As String sPromptStrings(0) = "SCALE: " & oView.ScaleString 'set to view scale sPromptStrings(1) = sViewName 'set to view name sPromptStrings(2) = ViewNum.ToString.PadLeft(3,"0") sPromptStrings(3) = Mid(oSheet.Name, InStr(1, oSheet.Name, ":") + 1).PadLeft(3,"0") 'set the position for the sketched symbol to be inserted ' and spaced off of the selected view center Dim oPosition As Point2d : oPosition = oView.Center oPosition.Y = oPosition.Y - (oView.Height / 2 + 0.6) 'insert the sketched symbol and set the prompted entries oSymbol = oSheet.SketchedSymbols.Add(oSymDef, oPosition, 0, 1, sPromptStrings) ViewNum+=1 Next End Sub