Through some Googling I found the following code to grab the scale of the base view in a sheet and insert that text into a prompted entry text in the title block:
Sub Main() Dim drawingDoc As DrawingDocument = TryCast(ThisDoc.Document, DrawingDocument) For Each sheetX As Sheet In drawingDoc.Sheets Dim titleBlockX As TitleBlock = sheetX.TitleBlock If (titleBlockX Is Nothing) Then Continue For Dim scaleTextBox As TextBox = GetScaleTextBox(titleBlockX.Definition) If (scaleTextBox Is Nothing) Then Continue For Dim scaleString As String = String.Empty For Each viewX As DrawingView In sheetX.DrawingViews If (Not String.IsNullOrEmpty(viewX.ScaleString)) Then scaleString = viewX.ScaleString Exit For End If Next titleBlockX.SetPromptResultText(scaleTextBox, scaleString) Next End Sub Function GetScaleTextBox(ByVal titleDef As TitleBlockDefinition) As TextBox For Each defText As TextBox In titleDef.Sketch.TextBoxes If (defText.Text = "<SCALE>" Or defText.Text = "SCALE") Then Return defText End If Next Return Nothing End Function
This works marvelously but is far beyond my capabilities and I can barely follow it. What I'm wondering is if there is a way to utilize this to fill in the same prompted entry in a sketched symbol (part label, assembly title label) on the same sheet.
Hi,
You can also use the API to insert a SketchedSymbol and add the prompted text. The API help file has VBA examples that create a SketchSymbolDefinition and inserts it. See these Samples:
Public Sub CreateSketchedSymbolDefinition()
Public Sub InsertSketchedSymbolOnSheet()
The help file is here on my system:
"C:\Program Files\Autodesk\Inventor 2014\Local Help\admapi_18_0.chm"
If you are trying to use this in an iLogic rule you can copy the VBA code into a VB.Net module in Visual Studio to get it close to what would work in iLogic. Basically you need to remove the Set statements and change how the Document is retrieved. In iLogic you can use ThisDoc.Document which is what the code you have in this post is doing.
Thanks,
Wayne