by Eric Paul, April 22, 2019

Standardize View Size on Drawings of Parts

Streamline your documentation process by learning how to automate scale settings within Inventor.
Back to Blog

We recently had a customer who wanted to streamline their documentation process. This company had a part with a lot of variety in length and found themselves having to manually set the scale for their views on each drawing. Today, I’ll show you how you can automate this process, which tends to be very common issue for a number of our customers. In this case, I’ll show an example where we know there’s a part in the very first view placed on the drawing and we’ll set it to always take up the same amount of space on the page.

Also, if this is your first time making an iLogic script, take a look at our AVA session all about getting started with iLogic. This will teach you the basics of creating iLogic scripts as well as some of the options on how you can have them run automatically. You can view that AVA video here: https://youtu.be/VO5SPwSZ6HM.

Check it out in action:

 

Getting Started

To start, I’ll give an overview of the objects we’re going to need from the inventor file. First, we’re going to need to read the current file that’s open. iLogic calls this the ActiveDocument. Next, we’ll collect the active Sheet that it’s open to. Once we have that, we’ll get the data on the first view that was created on the sheet, as well as the part in that view. With the part data, we’ll find the maximum X distance of the part. Next, we’ll set the absolute size that we want the view to be on the page. Then, we’ll divide that absolute size by that maximum X distance from the part to give us our new scale that we’ll set for the view.

I’ll break up each step below, then the full script will be available at the bottom.

A quick note before we go on, this script is meant to be run on a drawing (either DWG or IDW) with at least 1 view, and the 1st view placed on the page needs to be of a single Part.

So first, let’s get the active file and the active sheet open:

Dim oDoc As Document
oDoc = ThisApplication.ActiveDocument


Dim oSheet As Sheet
oSheet = oDoc.ActiveSheet

 

Next, we’ll select the first view on the sheet:

 

Dim oView As DrawingView
oView = oSheet.DrawingViews.Item(1)

 

With the view selected, we need to get data for the referenced part:

 

Dim oModel As PartDocument
oModel = oView.ReferencedDocumentDescriptor.ReferencedDocument

 

Now that we have that, we can get information we need to find out how long the part is on the Z axis. We’ll need to add an extra step, because you can’t just get the maximum point of Z and call it a day. We’ll have to subtract that value from the minimum point of Z as well.

 

Dim totalRange As Box
totalRange = oModel.ComponentDefinition.RangeBox


Dim modelWidth As Double
modelWidth = Abs(totalRange.MaxPoint.Z - totalRange.MinPoint.Z)

 

Next, we need is to set how wide we want the view to be on the sheet. A quick note about distances in Inventor; the API always deals with centimeters for drawings, so plan accordingly! Here, I want it to be 15 inches, so I need to multiply it by 2.54 to get from centimeters.

 

Dim myViewSize As Double = 15 * 2.54

 

Our last step is to divide our desired width by the model width, then set the view scale to that new number.

 

Dim newScale As Double
newScale = myViewSize / modelWidth


oView.Scale = newScale

 

Here’s the full code:

 

Dim oDoc As Document oDoc = ThisApplication.ActiveDocument Dim oSheet As Sheet oSheet = oDoc.ActiveSheet Dim oView As DrawingView oView = oSheet.DrawingViews.Item(1) Dim oModel As PartDocument oModel = oView.ReferencedDocumentDescriptor.ReferencedDocument Dim totalRange As Box totalRange = oModel.ComponentDefinition.RangeBox Dim totalRange As Box totalRange = oModel.ComponentDefinition.RangeBox Dim modelWidth As Double modelWidth = Abs(totalRange.MaxPoint.ZtotalRange.MinPoint.Z) Dim myViewSize As Double = 15 * 2.54 Dim newScale As Double newScale = myViewSize / modelWidth oView.Scale = newScale

 

For more Autodesk tips and tricks, subscribe to Autodesk Virtual Academy here! 

Back to Blog

More stories from KETIV

Blog

Standardize View Size on Drawings of Parts

We recently had a customer who wanted to streamline their documentation process. This company had a part with a lot of variety in length and found themselves having to manually set the scale for their views on each drawing. Today, I’ll show you…

Read post
Blog

What's New in Inventor 2020

Autodesk is constantly working to gather customer data to drive yearly improvements to their products. Customer driven improvements from the Autodesk Knowledge Network and Autodesk forums have helped to drive some exciting changes to the new…

Read post