Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Filling out scale field in title block and sketched symbols

1 REPLY 1
Reply
Message 1 of 2
SMGordon
513 Views, 1 Reply

Filling out scale field in title block and sketched symbols

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.

 

1 REPLY 1
Message 2 of 2
wayne.brill
in reply to: SMGordon

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 



Wayne Brill
Developer Technical Services
Autodesk Developer Network

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report