Hello,
i have search the Forums and have not been able to find any info on this topic as it relates to my issue. if i am redundant posting, i apologize....
we are currently switching over from autocad to Inventor. our drawing sets have multiple pages, and the pages have prefixes to the numbers... W01, W02, W03... S01,S02, S03... in Inventor FEATURE TREE, they show up as W01:1, W02:2..S01:3, S04:4.....this was a simple operation in Acad... right click the sheet tab, rename the sheet, regen and the new name shows up in the field in the titleblock. i must admit i was surprise that this feature , to my knowledge, is not available in Inventor.. all you can do in Inventor is add the number (see attachments) am i missing something? i've written some code to extract the prefix part, and can get it into a custom property, but how do i get it onto my drawing sheet, having each sheet update with the proper prefix? we can have up to 30 sheets, or a few of 6, depending on the project. sheets can be added or removed... this should be a simple operation (as mention above, easy to do in Autocad, and in other parametric software i have used), but i can't find a simple way. any help or direction would be greatly appreicated!
So the sheet names in AutoCAD must be unique, but in Inventor they do not. This is probably why they don't make it an accessible field. To work around, you can run through each sheet, and find the prompted entry you want to change and set to the Sheet Name.
This rule can be set to "BeforeSave" Event Trigger to AutoUpdate those prompted entries, or it can just be manually run:
Sub Main
Dim dDoc As DrawingDocument = ThisDoc.Document
Dim PEname As String = "PromtedEntryName"
Dim DefTextBox As TextBox
Dim ReturnSheet As Sheet = dDoc.ActiveSheet
For Each s As Sheet In dDoc.Sheets
For Each tb As TextBox In s.TitleBlock.Definition.Sketch.TextBoxes
If GetPromptField(tb.FormattedText) = PEname Then DefTextBox = tb : Logger.Trace("found in: " & s.Name): Exit For
Next
If Not IsNothing(DefTextBox)
If s.TitleBlock.GetResultText(DefTextBox)<> s.Name
s.Activate
s.TitleBlock.SetPromptResultText(DefTextBox, s.Name)
End If
End If
Next
ReturnSheet.Activate
InventorVb.DocumentUpdate()
End Sub
Function GetPromptField(ByVal FormattedText As String) As String
On Error GoTo ErrorFound
' Verify that this is a prompt field.
If Left$(FormattedText, 7) <> "<Prompt"
GetPromptField = ""
Exit Function
End If
' Get the text that is to the Right Of the first ">" symbol
' and to the left of the last "<" symbol.
GetPromptField = Right$(FormattedText,Len(FormattedText) - InStr(FormattedText, ">"))
GetPromptField = Left$(GetPromptField, InStr(GetPromptField, "<") -1)
' Replace any < or > With < And > symbols.
GetPromptField = Replace(GetPromptField, "<", "<")
GetPromptField = Replace(GetPromptField, ">", ">")
Exit Function
ErrorFound :
Logger.Trace("ErrorFound")
GetPromptField = ""
End Function
You just need to change this line:
Dim PEname As String = "PromtedEntryName"
to what ever your prompted entry name is in the titleblock sketch textbox.
Let me know if you have any questions.
Good afternoon
I am not able to get it to work on my end and can not seem to figure out why.
Any chance someone could help me identify my error?
Thank you
Did you change the prompted entry name in the code to match your prompted entry name?
Also try ruining the code in log level: Trace. You should see some feedback in the ilogic log that will help determine what info it is finding. Let me knew what you see
Good day @J-Camper
Thank you for your time. I replaced the Prompt entry in the beginning of the code, but not any where else. I am copying below:
Sub Main Dim dDoc As DrawingDocument = ThisDoc.Document Dim PEname As String = "DRAWING NO" Dim DefTextBox As TextBox Dim ReturnSheet As Sheet = dDoc.ActiveSheet For Each s As Sheet In dDoc.Sheets For Each tb As TextBox In s.TitleBlock.Definition.Sketch.TextBoxes If GetPromptField(tb.FormattedText) = PEname Then DefTextBox = tb : Logger.Trace("found in: " & s.Name): Exit For Next If Not IsNothing(DefTextBox) If s.TitleBlock.GetResultText(DefTextBox)<> s.Name s.Activate s.TitleBlock.SetPromptResultText(DefTextBox, s.Name) End If End If Next ReturnSheet.Activate InventorVb.DocumentUpdate() End Sub Function GetPromptField(ByVal FormattedText As String) As String On Error GoTo ErrorFound ' Verify that this is a prompt field. If Left$(FormattedText, 7) <> "<Prompt" GetPromptField = "" Exit Function End If ' Get the text that is to the Right Of the first ">" symbol ' and to the left of the last "<" symbol. GetPromptField = Right$(FormattedText,Len(FormattedText) - InStr(FormattedText, ">")) GetPromptField = Left$(GetPromptField, InStr(GetPromptField, "<") -1) ' Replace any < or > With < And > symbols. GetPromptField = Replace(GetPromptField, "<", "<") GetPromptField = Replace(GetPromptField, ">", ">") Exit Function ErrorFound : Logger.Trace("ErrorFound") GetPromptField = "" End Function
This is what I am getting in the iLogic log:
INFO| 4: >>---------------------------
TRACE|Entering rule: "BeforeSave" (in WAX POOL BUS NO 3.dwg)
TRACE|Exiting rule: "BeforeSave" (in WAX POOL BUS NO 3.dwg)
INFO| 5: >>---------------------------
TRACE|Entering rule: "BeforeSave" (in WAX POOL BUS NO 3.dwg)
TRACE|Exiting rule: "BeforeSave" (in WAX POOL BUS NO 3.dwg)
Any advice is appreciated, Thank you
I forgot I was only tracing the good results. Try this and let me know what the Trace shows:
Sub Main
Dim dDoc As DrawingDocument = ThisDoc.Document
Dim PEname As String = "DESCRIPTION 1"
Dim DefTextBox As TextBox
Dim ReturnSheet As Sheet = dDoc.ActiveSheet
For Each s As Sheet In dDoc.Sheets
For Each tb As TextBox In s.TitleBlock.Definition.Sketch.TextBoxes
If GetPromptField(tb.FormattedText) = PEname Then DefTextBox = tb : Logger.Trace("found : " & PEname & " on sheet: " & s.Name): Exit For
Next
If Not IsNothing(DefTextBox)
If s.TitleBlock.GetResultText(DefTextBox)<> s.Name
s.Activate
s.TitleBlock.SetPromptResultText(DefTextBox, s.Name)
End If
Else
Logger.Trace("Could not find: " & PEname & " in TitleBlock of Sheet: " & s.Name)
End If
Next
ReturnSheet.Activate
InventorVb.DocumentUpdate()
End Sub
Function GetPromptField(ByVal FormattedText As String) As String
On Error GoTo ErrorFound
' Verify that this is a prompt field.
If Left$(FormattedText, 7) <> "<Prompt"
GetPromptField = ""
Exit Function
End If
' Get the text that is to the Right Of the first ">" symbol
' and to the left of the last "<" symbol.
GetPromptField = Right$(FormattedText,Len(FormattedText) - InStr(FormattedText, ">"))
GetPromptField = Left$(GetPromptField, InStr(GetPromptField, "<") -1)
' Replace any < or > With < And > symbols.
GetPromptField = Replace(GetPromptField, "<", "<")
GetPromptField = Replace(GetPromptField, ">", ">")
Logger.Trace("Promted Entry name found: " & GetPromptField)
Exit Function
ErrorFound :
Logger.Trace("ErrorFound")
GetPromptField = ""
End Function
You should see something like this when it can't find the right prompt:
INFO| 4: >>---------------------------
TRACE|Entering rule: Rule1 (in Drawing1)
TRACE|Promted Entry name found: DESCRIPTION 1
TRACE|Promted Entry name found: DESCRIPTION 2
TRACE|Could not find: DRAWING NO in TitleBlock of Sheet: SD-1:1
TRACE|Exiting rule: Rule1 (in Drawing1)
You should see something like this when it finds the right prompt:
INFO| 6: >>---------------------------
TRACE|Entering rule: Rule1 (in Drawing1)
TRACE|Promted Entry name found: DESCRIPTION 1
TRACE|found : DESCRIPTION 1 on sheet: SD-1:1
TRACE|Exiting rule: Rule1 (in Drawing1)
It will print out the name of each prompted entry as it goes, and lets you know if it failed to find the intended Prompted entry.
I am getting this in the iLogic log:
INFO| 1: >>---------------------------
TRACE|Entering rule: "BeforeSave" (in WAX POOL BUS NO 3.dwg)
TRACE|Could not find: DESCRIPTION 1 in TitleBlock of Sheet: 1456-141:1
TRACE|Could not find: DESCRIPTION 1 in TitleBlock of Sheet: 1456-142:2
TRACE|Could not find: DESCRIPTION 1 in TitleBlock of Sheet: 1456-143:3
TRACE|Could not find: DESCRIPTION 1 in TitleBlock of Sheet: 1456-144:4
TRACE|Could not find: DESCRIPTION 1 in TitleBlock of Sheet: 1456-145:5
TRACE|Exiting rule: "BeforeSave" (in WAX POOL BUS NO 3.dwg)
INFO| 2: >>---------------------------
TRACE|Entering rule: "BeforeSave" (in WAX POOL BUS NO 3.dwg)
TRACE|Could not find: DESCRIPTION 1 in TitleBlock of Sheet: 1456-141:1
TRACE|Could not find: DESCRIPTION 1 in TitleBlock of Sheet: 1456-142:2
TRACE|Could not find: DESCRIPTION 1 in TitleBlock of Sheet: 1456-143:3
TRACE|Could not find: DESCRIPTION 1 in TitleBlock of Sheet: 1456-144:4
TRACE|Could not find: DESCRIPTION 1 in TitleBlock of Sheet: 1456-145:5
TRACE|Exiting rule: "BeforeSave" (in WAX POOL BUS NO 3.dwg)
I have attached a snip showing my Model tree view, and the Prompt entry form; where I am currently attempting to use the custom iProperty: DRAWING NO to populate the drawing number in the title block. Should I change my current approach?
Thank you
It seems like you don't have any prompted entries in the titleblock. Are you only using iProperties in your titleblock?
This screen cast: created by: HermJan.Otterman shows how to add a prompted entry to a titleblock.
Also You want the Prompted Entry name created in the steps outlined by the video above [It is named: "Sheetname" in the video sample] to match what you put in this line of code:
Dim PEname As String = "PromtedEntryName"
Let me know if you have any other questions, or if you need help making the Prompted entry, you could post a drawing file with your titleblock an I can add the prompted entry.
Thanks, Jcamper (and others) for your input here. i have not had a chance to implement, but will give it a shot. again, much appreciated!! have a good weekend!!
Can't find what you're looking for? Ask the community or share your knowledge.