Wednesday, February 1, 2023

iLogic : Set View Scale from Standard Preset Set List

 Issue:

You would like to set the view scale of your drawing views using the predefined scale list as found at Manage tab > Styles Editor button > Standard > Standard name > General tab > Preset Values > Scale




Solution:

Here is a quick bit of code to get this list and set the scale based on the scale selected from the input list box.

( Thank you! to Zach B. for the idea for the rule) 





Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oStyleManager As DrawingStylesManager = oDoc.StylesManager

Dim oActiveStandard As DrawingStandardStyle
oActiveStandard = oDoc.StylesManager.ActiveStandardStyle

Dim oList As New List(Of String)
For Each oItem In oActiveStandard.PresetScales
	oList.Add(oItem)
Next

Dim oView As DrawingView
oCurrentScale = oDoc.ActiveSheet.DrawingViews.Item(1).ScaleString

Dim oScale As String = InputListBox("Select a scale", _
oList, oCurrentScale, "iLogic", "Standard Scale List")

If String.IsNullOrWhiteSpace(oScale) Then Exit Sub

For Each oView In oDoc.ActiveSheet.DrawingViews
	If oView.ScaleFromBase = False Then
		oView.ScaleString = oScale
	End If
Next