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.
Solved! Go to Solution.
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.
Solved! Go to Solution.
Solved by JelteDeJong. Go to Solution.
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.
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.
Blog: hjalte.nl - github.com
Is there a way to update the code to remove the :1, :2 at the end
Is there a way to update the code to remove the :1, :2 at the end
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.
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.
Blog: hjalte.nl - github.com
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.
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.
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.
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.
Blog: hjalte.nl - github.com
Instead of having the code reference a prompted entry. How would you adjust this to referencing iproperty vaule "SHEET DESCRIPTION"
Instead of having the code reference a prompted entry. How would you adjust this to referencing iproperty vaule "SHEET DESCRIPTION"
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.
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.