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: 

Have the sheet name automatically generate in Title block

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
brandon.lee97
734 Views, 7 Replies

Have the sheet name automatically generate in Title block

brandon.lee97
Contributor
Contributor

I am trying to have my title block sheet name automatically populated once the sheet name has been set. 

 

For example, the image i have attached shows the sheet names we type in, 

but our current process requires us to type in the sheet name multiple times to appear both in the sidebar shown as well as the title block.

 

I am wondering if there is a way to make the title block auto-populate once the sheet name has been filled out in the sidebar. 

0 Likes

Have the sheet name automatically generate in Title block

I am trying to have my title block sheet name automatically populated once the sheet name has been set. 

 

For example, the image i have attached shows the sheet names we type in, 

but our current process requires us to type in the sheet name multiple times to appear both in the sidebar shown as well as the title block.

 

I am wondering if there is a way to make the title block auto-populate once the sheet name has been filled out in the sidebar. 

7 REPLIES 7
Message 2 of 8
JelteDeJong
in reply to: brandon.lee97

JelteDeJong
Mentor
Mentor

you can try this.

Dim doc As DrawingDocument = ThisDoc.Document
Dim sheet As Sheet = doc.ActiveSheet
Dim titleBlock As TitleBlock = sheet.TitleBlock

Dim textBox As Inventor.TextBox = titleBlock.Definition.Sketch.TextBoxes.
        Cast(Of Inventor.TextBox).
        Where(Function(tb) tb.FormattedText.Contains("<Prompt")).
        Where(Function(tb) tb.FormattedText.Contains("SHEET DESCRIPTION")).
        FirstOrDefault()
If (textBox Is Nothing) Then Throw New Exception("Promted entry not found.")
titleBlock.SetPromptResultText(textBox, sheet.Name)

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

you can try this.

Dim doc As DrawingDocument = ThisDoc.Document
Dim sheet As Sheet = doc.ActiveSheet
Dim titleBlock As TitleBlock = sheet.TitleBlock

Dim textBox As Inventor.TextBox = titleBlock.Definition.Sketch.TextBoxes.
        Cast(Of Inventor.TextBox).
        Where(Function(tb) tb.FormattedText.Contains("<Prompt")).
        Where(Function(tb) tb.FormattedText.Contains("SHEET DESCRIPTION")).
        FirstOrDefault()
If (textBox Is Nothing) Then Throw New Exception("Promted entry not found.")
titleBlock.SetPromptResultText(textBox, sheet.Name)

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 3 of 8
brandon.lee97
in reply to: JelteDeJong

brandon.lee97
Contributor
Contributor

Is there a way to update the code to remove the :1, :2 at the end 

 

brandonlee97_0-1637971104059.png

 

0 Likes

Is there a way to update the code to remove the :1, :2 at the end 

 

brandonlee97_0-1637971104059.png

 

Message 4 of 8
JelteDeJong
in reply to: brandon.lee97

JelteDeJong
Mentor
Mentor

here is an updated rule:

Dim doc As DrawingDocument = ThisDoc.Document
Dim sheet As Sheet = doc.ActiveSheet
Dim titleBlock As TitleBlock = sheet.TitleBlock

Dim textBox As Inventor.TextBox = titleBlock.Definition.Sketch.TextBoxes.
        Cast(Of Inventor.TextBox).
        Where(Function(tb) tb.FormattedText.Contains("<Prompt")).
        Where(Function(tb) tb.FormattedText.Contains("SHEET DESCRIPTION")).
        FirstOrDefault()
If (textBox Is Nothing) Then Throw New Exception("Promted entry not found.")

Dim sheetDescription = sheet.Name
Dim puntPlace = InStr(sheetDescription, ":") - 1
sheetDescription = sheetDescription.Substring(0, puntPlace)
titleBlock.SetPromptResultText(textBox, sheetDescription)

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

here is an updated rule:

Dim doc As DrawingDocument = ThisDoc.Document
Dim sheet As Sheet = doc.ActiveSheet
Dim titleBlock As TitleBlock = sheet.TitleBlock

Dim textBox As Inventor.TextBox = titleBlock.Definition.Sketch.TextBoxes.
        Cast(Of Inventor.TextBox).
        Where(Function(tb) tb.FormattedText.Contains("<Prompt")).
        Where(Function(tb) tb.FormattedText.Contains("SHEET DESCRIPTION")).
        FirstOrDefault()
If (textBox Is Nothing) Then Throw New Exception("Promted entry not found.")

Dim sheetDescription = sheet.Name
Dim puntPlace = InStr(sheetDescription, ":") - 1
sheetDescription = sheetDescription.Substring(0, puntPlace)
titleBlock.SetPromptResultText(textBox, sheetDescription)

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 5 of 8
brandon.lee97
in reply to: JelteDeJong

brandon.lee97
Contributor
Contributor

Thank you for the help on this, one last thing, the code has to be run on each sheet. Is there a way to have to automatically run on each sheet in the drawing. 

0 Likes

Thank you for the help on this, one last thing, the code has to be run on each sheet. Is there a way to have to automatically run on each sheet in the drawing. 

Message 6 of 8
JelteDeJong
in reply to: brandon.lee97

JelteDeJong
Mentor
Mentor
Accepted solution

try this:

Dim doc As DrawingDocument = ThisDoc.Document
For Each sheet As Sheet In doc.Sheets
    Dim titleBlock As TitleBlock = Sheet.TitleBlock

    Dim textBox As Inventor.TextBox = titleBlock.Definition.Sketch.TextBoxes.
	    Cast(Of Inventor.TextBox).
	    Where(Function(tb) tb.FormattedText.Contains("<Prompt")).
	    Where(Function(tb) tb.FormattedText.Contains("SHEET DESCRIPTION")).
	    FirstOrDefault()
    If (textBox Is Nothing) Then 
		MsgBox("Promted entry not found on sheet: " & Sheet.Name)
		continue for
	End If

    Dim sheetDescription = Sheet.Name
    Dim puntPlace = InStr(sheetDescription, ":") - 1
    sheetDescription = sheetDescription.Substring(0, puntPlace)
    titleBlock.SetPromptResultText(textBox, sheetDescription)
Next

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

try this:

Dim doc As DrawingDocument = ThisDoc.Document
For Each sheet As Sheet In doc.Sheets
    Dim titleBlock As TitleBlock = Sheet.TitleBlock

    Dim textBox As Inventor.TextBox = titleBlock.Definition.Sketch.TextBoxes.
	    Cast(Of Inventor.TextBox).
	    Where(Function(tb) tb.FormattedText.Contains("<Prompt")).
	    Where(Function(tb) tb.FormattedText.Contains("SHEET DESCRIPTION")).
	    FirstOrDefault()
    If (textBox Is Nothing) Then 
		MsgBox("Promted entry not found on sheet: " & Sheet.Name)
		continue for
	End If

    Dim sheetDescription = Sheet.Name
    Dim puntPlace = InStr(sheetDescription, ":") - 1
    sheetDescription = sheetDescription.Substring(0, puntPlace)
    titleBlock.SetPromptResultText(textBox, sheetDescription)
Next

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 7 of 8
brandon.lee97
in reply to: JelteDeJong

brandon.lee97
Contributor
Contributor

Instead of having the code reference a prompted entry. How would you adjust this to referencing iproperty vaule "SHEET DESCRIPTION" 

0 Likes

Instead of having the code reference a prompted entry. How would you adjust this to referencing iproperty vaule "SHEET DESCRIPTION" 

Message 8 of 8
j.oudalstoel
in reply to: JelteDeJong

j.oudalstoel
Contributor
Contributor

JelteDeJong

 

Just wanted to say thank you for providing this code. It solved an issue I was having with getting my title block to reflect the sheet name. 

 



0 Likes

JelteDeJong

 

Just wanted to say thank you for providing this code. It solved an issue I was having with getting my title block to reflect the sheet name. 

 



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

Post to forums  

Autodesk Design & Make Report