@Anonymous
Check out the below links that are available on the Inventor Customization forum.
https://forums.autodesk.com/t5/inventor-customization/automatic-scale-and-view-position/td-p/5784680
https://forums.autodesk.com/t5/inventor-customization/scaling-functionality-for-a-set-of-drawing-views/td-p/7928218
There are several ways of doing this, you can add equations based on your sheet and view size and view positions, you can also predefine the scales and use them etc.
Check out the below code as well, which I use sometimes, which does not require the scales to be set manually or via scale string function. In the below code, you just need to change the values in the fourth line (30,30) that represents an imaginary box within which the view will always be fit, you can try this rule and then it will automatically set the view in that imaginary box regardless of the size of your model. You can do some tests and fix the values(currently (30,30)) and once you are satisfied it will always work. In this you need to be aware that the scales will be set automatically so it will not follow the standards (i.e. 1:5 or 1:10 etc.) you will see quite random values in scale.
'This code is only for first view, you can use it for more views by modifying it.
Sub Main
Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Sheet = oDoc.ActiveSheet
Dim oView As DrawingView = oSheet.DrawingViews.Item(1)
ReScale_View(oView, 30, 30)
End Sub
Public Sub ReScale_View (aView As DrawingView, X As Double, Y As Double)
Dim XOrg As Double = aView.Width / aView.Scale
Dim YOrg As Double = aView.Height / aView.Scale
Dim XScale As Double = X / XOrg
Dim YScale As Double = Y / YOrg
aView.Scale = Math.Min(XScale, YScale)
End Sub
Hope this will be helpful.
If this answer has solved your problem please ACCEPT SOLUTION and hit like if you found it helpful..!
Regards,
Dutt Thakar
LinkedIn