Vba or iLogic for exact drawing scale x:y not x.yz

Vba or iLogic for exact drawing scale x:y not x.yz

engilic
Advocate Advocate
697 Views
8 Replies
Message 1 of 9

Vba or iLogic for exact drawing scale x:y not x.yz

engilic
Advocate
Advocate

Hi,

 

is it possible to set drawing scale exactly to x:y, not to x.yz.

 

I tried with string hut the scale need to be a number, reasonable.

 

For example 1:5 and not to 0.2.

 

Then if you want to change it by mouse scroll it will just go to the next scale, much better than suddenly to go to highest scale.

 

Have a lovely day.

0 Likes
Accepted solutions (3)
698 Views
8 Replies
Replies (8)
Message 2 of 9

WCrihfield
Mentor
Mentor
Accepted solution

Hi @engilic.  Neither the DrawingDocument object itself, nor the Sheet object actually have a 'Scale' property.  Only the DrawingView object has the Scale, ScaleFromBase, and ScaleString properties.  The Scale property has a Double type value, so it wants a normal number with a decimal point.  The ScaleString property has a String type value, and is Read/Write, and it will accept the "1:2" type format and understands it as a ratio.

Here is a simple iLogic rule example that worked in a quick test:

 

Dim oDDoc As DrawingDocument = ThisDoc.Document
oSheet = oDDoc.ActiveSheet
oView = oSheet.DrawingViews.Item(1)
oView.ScaleString = "1:2"

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.

If you want and have time, I would appreciate your Vote(s) for My IDEAS :bulb: or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 9

WCrihfield
Mentor
Mentor
Accepted solution

Also, just another related tip.  If you want to be able to specify the list of scales you want to see available in the drop down list of scales you see when editing a view, you can set that up within the following location (preferably within your drawing template).  Manage tab > Styles and Standards panel > Styles Editor (brings up a dialog) > select your current Standard Stye (top most node, then Bold named).  Now on the right side, within the 'Preset Values' area, change the drop-down list from 'Line Weight' to 'Scale'.  It will now be showing the currently available list of scales.  You can select ones you don't want, then click the [Delete] button, or you can click the [New...] button to add more scales to the list.

WCrihfield_0-1645461204930.png

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 4 of 9

engilic
Advocate
Advocate

@WCrihfield you are the champion, this is great, also the tip is great.
I'm so happy, if I have a tail I will wave with it.

0 Likes
Message 5 of 9

engilic
Advocate
Advocate

One more question @WCrihfield , since it seems you know everything.

Can I get all Scale preset values as a collection or any other way?

0 Likes
Message 6 of 9

WCrihfield
Mentor
Mentor

Well, I know I don't know it all, but...

Yes, there is a fairly easy way to access that list by code.  Below is the rule I used at some point in the past to set up my own list of scales quickly.  You will notice that I changed the format of the scales at the zero point from fractions to ratios.  That's just fine...it knows what you mean and it will work OK.  I just like to see it that way in my list.

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
	MsgBox("This rule only works for Drawing Documents.  Exiting rule.", vbCritical, "")
	Exit Sub
End If
Dim oDDoc As DrawingDocument = ThisApplication.ActiveDocument

Dim oScalesList As New List(Of String)
oScalesList.Add("1 / 30")
oScalesList.Add("1 / 29")
oScalesList.Add("1 / 28")
oScalesList.Add("1 / 27")
oScalesList.Add("1 / 26")
oScalesList.Add("1 / 25")
oScalesList.Add("1 / 24")
oScalesList.Add("1 / 23")
oScalesList.Add("1 / 22")
oScalesList.Add("1 / 21")
oScalesList.Add("1 / 20")
oScalesList.Add("1 / 19")
oScalesList.Add("1 / 18")
oScalesList.Add("1 / 17")
oScalesList.Add("1 / 16")
oScalesList.Add("1 / 15")
oScalesList.Add("1 / 14")
oScalesList.Add("1 / 13")
oScalesList.Add("1 / 12")
oScalesList.Add("1 / 11")
oScalesList.Add("1 / 10")
oScalesList.Add("1 / 9")
oScalesList.Add("1 / 8")
oScalesList.Add("1 / 7")
oScalesList.Add("1 / 6")
oScalesList.Add("1 / 5")
oScalesList.Add("1 / 4")
oScalesList.Add("1 / 3")
oScalesList.Add("1 / 2")
oScalesList.Add("1 : 1")
oScalesList.Add("2 : 1")
oScalesList.Add("3 : 1")
oScalesList.Add("4 : 1")
oScalesList.Add("5 : 1")
oScalesList.Add("6 : 1")
oScalesList.Add("7 : 1")
oScalesList.Add("8 : 1")
oScalesList.Add("9 : 1")
oScalesList.Add("10 : 1")
Dim oScales As String() = oScalesList.ToArray()
oDDoc.StylesManager.ActiveStandardStyle.PresetScales = oScales

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 7 of 9

engilic
Advocate
Advocate

I did not mean to manually set all scales, is it possible to read them from Styles, so whatever is there just get it from the syles?
It is in case Styles changes, you don't need to change the code too.

0 Likes
Message 8 of 9

WCrihfield
Mentor
Mentor
Accepted solution

Sure.  This code just gets the list of scales that are already there to an Array of String type variable.  Then I just added a line of code to show you the contents of that variable, using an InputListBox.

Dim oDDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oScales() As String = oDDoc.StylesManager.ActiveStandardStyle.PresetScales
'just to show contents of oScales variable
oReport = InputListBox("", oScales)

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 9 of 9

engilic
Advocate
Advocate

thank you @WCrihfield 

whoever says that you do not know everything is lying (except you, you can say that.)

0 Likes