Change Titleblock Textfields with iLogic

Change Titleblock Textfields with iLogic

Daan_M
Collaborator Collaborator
755 Views
2 Replies
Message 1 of 3

Change Titleblock Textfields with iLogic

Daan_M
Collaborator
Collaborator

Hi,

 

I have a iLogic rule inside my assembly that generates a 2D .dwg drawing of the assembly inside a custom template.

Inside the Titleblock of this template i have 2 Textfields i want to change according to some specs that originate from the assembly.

 

In the picture below you see <ShortDesc> and <LongDesc>, i basically want the iLogic rule inside my assembly that generates the drawing fill these boxes everytime i generates a drawing.

 

I only need the code that lets me adjust the these textfields fromout my assembly iLogic rule, i tried looking for solutions in the API help but alot of these seem overkill to me.

 

Daan_M_0-1596716642122.png

 

0 Likes
Accepted solutions (1)
756 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor
Accepted solution

 

Try this:

(You can get rid of the beginning portion of the code if you already have your own code for it.)

 

Dim oADoc As AssemblyDocument = ThisAssembly.Document
Dim oADef As AssemblyComponentDefinition = oADoc.ComponentDefinition
Dim oDType As DocumentTypeEnum = DocumentTypeEnum.kDrawingDocumentObject
Dim oDTFileName As String = ThisApplication.FileManager.GetTemplateFile(oDType)
Dim oDDoc As DrawingDocument = ThisApplication.Documents.Add(oDType, oDTFileName, True)
Dim oSheet As Sheet = oDDoc.ActiveSheet
Dim oTB As TitleBlock = oSheet.TitleBlock
Dim oTBD As TitleBlockDefinition = oTB.Definition
Dim oSketch As DrawingSketch
oTBD.Edit(oSketch)
Dim oTBox, oLTBox, oSTBox As Inventor.TextBox
For Each oTBox In oSketch.TextBoxes
	If oTBox.FormattedText.Contains("LongDesc") Then
		oLTBox = oTBox
	ElseIf oTBox.FormattedText.Contains("ShortDesc") Then
		oSTBox = oTBox
	End If
Next
oTBD.ExitEdit(True)
Dim oNewLongDesc As String = "New Long Desc"
Dim oNewShortDesc As String = "New Short Desc"
oTB.SetPromptResultText(oLTextBox,oNewLongDesc)
oTB.SetPromptResultText(oSTextBox,oNewShortDesc)

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click 'LIKE" 👍.

Also, when you have time, please review & vote for these 'Ideas' I'd like to get implemented.

  • Add more capabilities to the 'Customize' dialog box (exe. Add Tab & Add Panel) Click Here
  • Constrain & Dimension Images In Assembly Sketches & Drawing Sketches (TitleBlocks & SketchedSymbols) Click Here
  • Save Section View Status In DesignViewRepresentation (So It Can Be Used In The Drawing) Click Here
  • Add SolidBodies Folder In iLogic Rule Editor Model Tab Click Here
  • Convert All Views To Raster Before Autosave Stores To 'OldVersions' Folder Click Here
  • SetDesignViewRepresentation - Fix limitations for DrawingView of a Part Click Here
  • Create DocumentSubTypeEnum Click Here
  • Add kRevisionTag or kDrawingRevisionTag to ObjectTypeEnum Click Here

Inventor 2020 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 3

Daan_M
Collaborator
Collaborator

Hi  @WCrihfield 

 

Worked perfectly, thanks alot! Little note in case anyone else wants to use the code, adjust the last 2 code lines from

 

oTB.SetPromptResultText(oLTextBox,oNewLongDesc)
oTB.SetPromptResultText(oSTextBox,oNewShortDesc)

 

to:

 

 

oTB.SetPromptResultText(oLTBox,oNewLongDesc)
oTB.SetPromptResultText(oSTBox,oNewShortDesc)

 

 

0 Likes