By utilizing iLogic functionality inside Autodesk Inventor 2014 you can add the scale of your drawing view to the title block of your Inventor Drawing.
To accomplish this you’ll need to add a “Prompted Entry” text parameter to the title block. Edit your title block definition and add a text parameter (at the desired location of the title block) and change the “Type” to “Prompted Entry”. Use <SCALE> for the entry.
The result should look similar to this:
In the Model Browser of the drawing expand Sheet:1 and ANSI – Large and double mouse click on “Field Text”.
In the Edit Property Fields dialog change the drop down to Prompted Entry and verify the presence of <Scale>.
Now create a new iLogic Rule that will display the Scale. In the iLogic browser, right mouse click and select “Add Rule” or locate the “Add Rule” command on the Manage tab along the ribbon menu (on the iLogic panel).
In the Rule Name dialog box enter the name “DrawingScale” and click OK. In the iLogic Rule Editor window enter the following text (code) to populate the scale of the BaseView of the drawing into the title block (the prompted entry field named “Scale” that we created earlier):
<span style="color:#993300;">Sub Main()</span> <span style="color:#993300;"> Dim drawingDoc As DrawingDocument = TryCast(ThisDoc.Document, DrawingDocument)</span> <span style="color:#993300;"> For Each sheetX As Sheet In drawingDoc.Sheets</span> <span style="color:#993300;"> If (sheetX.TitleBlock Is Nothing) Then Continue For</span> <span style="color:#993300;"> Dim titleBlockX As TitleBlock = sheetX.TitleBlock</span> <span style="color:#993300;"> Dim scaleTextBox As TextBox = GetScaleTextBox(titleBlockX.Definition)</span> <span style="color:#993300;"> Dim scaleString As String = String.Empty</span> <span style="color:#993300;"> For Each viewX As DrawingView In sheetX.DrawingViews</span> <span style="color:#993300;"> If (Not String.IsNullOrEmpty(viewX.ScaleString)) Then</span> <span style="color:#993300;"> scaleString = viewX.ScaleString</span> <span style="color:#993300;"> Exit For</span> <span style="color:#993300;"> End If</span> <span style="color:#993300;"> Next</span> <span style="color:#993300;"> titleBlockX.SetPromptResultText(scaleTextBox, scaleString)</span> <span style="color:#993300;"> Next</span> <span style="color:#993300;">End Sub</span> <span style="color:#993300;">Function GetScaleTextBox(ByVal titleDef As TitleBlockDefinition) As TextBox</span> <span style="color:#993300;"> For Each defText As TextBox In titleDef.Sketch.TextBoxes</span> <span style="color:#993300;"> If (defText.Text.IndexOf("<Scale>", StringComparison.OrdinalIgnoreCase) >= 0) Then</span> <span style="color:#993300;"> Return defText</span> <span style="color:#993300;"> End If</span> <span style="color:#993300;"> Next</span> <span style="color:#993300;"> Throw New ArgumentException("No prompted entry string containing <Scale> was found in the title block definition: " & titleDef.Name)</span> <span style="color:#993300;">End Function</span>
Click OK to close the Rule Editor & test the rule. If you have a BaseView present the “Scale” should now be populated to match the BaseView scale. If there is not a BaseView present the “Scale” should be empty. If this is the case go ahead and add a BaseView to the drawing and then run the rule to test. To run the rule manually right mouse click in the iLogic browser (Rules tab selected) and select “Run Rule” or “Regenerate Rule”. You can also select “Regenerate All Rules” from the iLogic panel on the Manage tab along the Ribbon Menu.
Once the rule is verified (as working) we need to set up an Event Trigger to run the rule automatically (otherwise a simple Save or Run Rule command will be necessary to populate the “Scale” field).
To set up an Event Trigger simply select “Event Triggers” from the iLogic panel on the Manage tab along the Ribbon Menu.
Right-Mouse-Click on the “Before Save Document” heading and choose “Select Rules”.
Then select the rule you want to run (in this case it is the DrawingScale rule) and then select OK. (Make sure the “Run these rules when events occur” box is checked at the top of the “Rules Triggered by Events” dialog box)
Now save the file and the Scale should be populated in the title block area. If you change the scale of the BaseView you will need to run the rule or save the file to update the title block.