Automated & Prompted Drawing View Scale
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
OK so I did some digging and found a few bits of code that all did almost what I was looking for. But none were quite there.
I just wanted to share this little rule with everyone.
This assumes that you've got a title block on your drawing with a prompted entry for sheet scale called <Scale>.
If you then create a rule in your document with this code it will bring a prompt up for each drawing sheet consecutively. If you simply hit ok leaving "ignor" in the inputBox it will bring through the scale of the first drawing view to the title block. Otherwise you can enter any scale you like and it will use that instead.
The only drawback I can find so far is that it doesn't tell you which sheet you're doing the scale for in the inputBox but I'm hoping that might be fixable at a later date.
I hope this helps someone anyway 🙂
Sub Main() Dim oDrawDoc As DrawingDocument = ThisDrawing.Document Dim oSheet As Sheet = oDrawDoc.ActiveSheet Dim oSheets As Sheets Dim oView As DrawingView Dim oViews As DrawingViews Dim oScale As Double Dim oViewCount As Integer = 0 Dim drawingDoc As DrawingDocument = TryCast(ThisDoc.Document, DrawingDocument) For Each sheetX As Sheet In drawingDoc.Sheets dwgScale = InputBox("Enter Sheet Scale", "SheetX", "ignor") Dim titleBlockX As TitleBlock = sheetX.TitleBlock If (titleBlockX Is Nothing) Then Continue For Dim scaleTextBox As TextBox = GetScaleTextBox(titleBlockX.Definition) If (scaleTextBox Is Nothing) Then Continue For Dim scaleString As String = String.Empty For Each viewX As DrawingView In sheetX.DrawingViews If (Not String.IsNullOrEmpty(viewX.ScaleString)) Then If dwgScale = "ignor" Then scaleString = viewX.ScaleString Else scaleString = dwgScale Exit For End If End If Next titleBlockX.SetPromptResultText(scaleTextBox, scaleString) Next End Sub Function GetScaleTextBox(ByVal titleDef As TitleBlockDefinition) As TextBox For Each defText As TextBox In titleDef.Sketch.TextBoxes If (defText.Text = "<Scale>" Or defText.Text = "Scale") Then Return defText End If Next Return Nothing End Function