Hello,
I am wanting to have my sheet names enter automatically into my titleblock, but it is not a selectable "Text Parameter" to enter.
I am currently using a "Prompted Entry" to produce the Page Name in the titleblock, but would like to use what I name the sheet.
Any way this is possible?
Solved! Go to Solution.
Solved by HermJan.Otterman. Go to Solution.
Are you unable to copy the sheet name to the base model iProperty?
Instead of changing the sheet names, you could name an iProperty on the model of your intended sheet name and then use that as part of your title block.
That's a good idea, but for my assemblies, there will not be a standard sheet per model/part number.
I am simply using Architectural type of numbers like A1.0, A1.1, A1.2....ETC....
Hello James,
try this (iLogic code)
Private Sub SetSheetname()
Dim oDrawDoc As Inventor.DrawingDocument = Thisapplication.ActiveDocument
' Set a reference to the drawing document.
' This assumes a drawing document is active.
' Obtain a reference to the desired border defintion.
Dim oTitleBlockDef As TitleBlockDefinition
oTitleBlockDef = oDrawDoc.TitleBlockDefinitions.Item("Sample Title Block")
Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet
' Check to see if the sheet already has a title block and delete it if it does.
If Not oSheet.TitleBlock Is Nothing Then
oSheet.TitleBlock.Delete()
End If
' This title block definition contains one prompted string input. An array
' must be input that contains the strings for the prompted strings.
Dim sPromptStrings(0) As String 'start counting by 0 !!!
sPromptStrings(0) = oSheet.Name 'if there is only one promped entry
'sPromptStrings(1) = "String 2"
' Add an instance of the title block definition to the sheet.
Dim oTitleBlock As TitleBlock
oTitleBlock = oSheet.AddTitleBlock(oTitleBlockDef, , sPromptStrings)
End Sub
most of it comes from the Inventor help.
important is that you addres ALL prompted entries, so in this case there is only one.
if you have more, for example 2 then start counting by zero, so you have two lines: (0 and 1)
this will work for the active sheet, if you have more than one, make a for each loop to go through all sheets.
put this rule on a befor save trigger
I don't know if this will help you or not, but the first line is to simply get the sheet name, the second line is to get the base model name, and the third line is to change an iProperty to what you want in the model.
oSheet=ThisApplication.ActiveDocument.ActiveSheet.Name model = ThisDrawing.ModelDocument.DisplayName & ".iam" iProperties.Value(model,"Project", "Project") = oSheet
With what you want to do it sounds like you'll need to do some restructuring to make it work right. I'm happy to help more if I can.
Go to Manage > iLogic > iLogic Browser
Then open the Rules tab and right click in the empty space to add a rule.
It's helpful if you know some Visual Basic but Inventor is pretty forgiving with the code. Once you hit OK the rule will run. To get the rule to work in any drawing, you'll have to create an external rule.
Hello James,
what Inventor version are you using?
here is an Inventor 2015 drawing with three sheets.
in it is an iLogic rule that will set the sheetname in the title block (on all sheets, code is a little changed)
look at my screencast: http://autode.sk/2knOzER
Maybe this will help. I posted it a while ago. This is based on the Display Name but you can change it to any iProperty you want. It basically does the opposite of you are doing but the result is the same.
Edit the iProperty for the Part / Assembly
Change the browser name to that iProperty value
Thread can be found Here
Code:
Public Sub ReNameSheets() Dim oDoc As DrawingDocument Set oDoc = ThisApplication.ActiveDocument Dim osheets As Sheets Set osheets = oDoc.Sheets Dim oSheet As Sheet Set oSheet = oDoc.ActiveSheet Dim defSheetLabel As String defSheetLabel = oDoc.SheetSettings.SheetLabel Dim sCount As Integer For Each oSheet In osheets On Error Resume Next 'oSheet.Activate Dim oDrawingView As DrawingView Set oDrawingView = oSheet.DrawingViews(1) omodelname = oDrawingView.ReferencedDocumentDescriptor.ReferencedDocument.DisplayName
oSheet.Name = omodelname & " - " & defSheetLabel
'If you only want the Display Name, Comment out the above line & Uncomment the below line
'oSheet.Name = omodelname
Next
Reset the sheets to the default 'Sheet'
Public Sub ResetSheets() Dim oDoc As DrawingDocument Set oDoc = ThisApplication.ActiveDocument Dim osheets As Sheets Set osheets = oDoc.Sheets Dim oSheet As Sheet Set oSheet = oDoc.ActiveSheet Dim defSheetLabel As String defSheetLabel = oDoc.SheetSettings.SheetLabel Dim sCount As Integer For Each oSheet In osheets 'oSheet.Activate Dim oDrawingView As DrawingView Set oDrawingView = oSheet.DrawingViews(1) oSheet.Name = defSheetLabel Next
Video Here
Hope that helps
Nacho
Automation & Design Engineer
Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC
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.
if you would use iPorperties than you would need an iProperty for every sheet.
I don't say it is not possible but you would get many iProperties, if you have many sheets..
I know this is an old post but this page got me super close to my goal! thank you
How do I have it so the sheet name in the title block won't show the sheet number (:2) at the end?
Thanks
Hello Ryan,
here is how you can get rid of the :x
positionOfDubbleDot = strings.InStrRev(oSheet.Name,":")
Length = Len(oSheet.Name)
stringYouNeed = Left(oSheet.Name, Length-(Length-positionOfDubbleDot)-1)
thank you,
I'm new to the more document driven code, where would I place those lines in my code?
'https://forums.autodesk.com/t5/inventor-customization/sheet-names/td-p/6824616 Dim oDrawDoc As Inventor.DrawingDocument = ThisApplication.ActiveDocument ' Set a reference to the drawing document. ' This assumes a drawing document is active. ' Obtain a reference to the desired border defintion. Dim oTitleBlockDef As TitleBlockDefinition oTitleBlockDef = oDrawDoc.TitleBlockDefinitions.Item("Standard (WB)") Dim oSheet As Sheet Dim oSheets As Sheets = oDrawDoc.Sheets 'oSheet = oDrawDoc.ActiveSheet For Each oSheet In oSheets ' Check to see if the sheet already has a title block and delete it if it does. If Not oSheet.TitleBlock Is Nothing Then oSheet.TitleBlock.Delete() End If ' This title block definition contains one prompted string input. An array ' must be input that contains the strings for the prompted strings. Dim sPromptStrings(0) As String 'start counting by 0 !!! sPromptStrings(0) = oSheet.Name 'if there is only one promped entry 'sPromptStrings(1) = "String 2" ' Add an instance of the title block definition to the sheet. Dim oTitleBlock As TitleBlock oTitleBlock = oSheet.AddTitleBlock(oTitleBlockDef, , sPromptStrings) Next
I have updated my code slightly, but I still struggle in figuring out where to put the lines you sent me on Friday.
Any help would be appreciated!
Sub main () Rename_SheetName () Create_PageNo() End Sub Function Rename_SheetName Dim oDoc As DrawingDocument oDoc = ThisApplication.ActiveDocument Dim oSheet As Sheet oSheet = oDoc.ActiveSheet Number = InputBox("Input initial number", "Rename sheets", "1") Letter = "A" FirstSheet=True For Each oSheet In oDoc.Sheets If FirstSheet = True oSheet.Name = Number FirstSheet = False Else oSheet.Name=Number + Letter Letter = Chr(Asc(Letter) + 1) End If Next End Function Function Create_PageNo Dim oDrawDoc As Inventor.DrawingDocument = ThisApplication.ActiveDocument ' Set a reference to the drawing document. ' This assumes a drawing document is active. ' Obtain a reference to the desired border defintion. Dim oTitleBlockDef As TitleBlockDefinition oTitleBlockDef = oDrawDoc.TitleBlockDefinitions.Item("Standard (WB)") Dim oSheet As Sheet Dim oSheets As Sheets = oDrawDoc.Sheets 'oSheet = oDrawDoc.ActiveSheet For Each oSheet In oSheets ' Check to see if the sheet already has a title block and delete it if it does. If Not oSheet.TitleBlock Is Nothing Then oSheet.TitleBlock.Delete() End If ' This title block definition contains one prompted string input. An array ' must be input that contains the strings for the prompted strings. Dim sPromptStrings(0) As String 'start counting by 0 !!! sPromptStrings(0) = oSheet.Name 'if there is only one promped entry 'sPromptStrings(1) = "String 2" ' Add an instance of the title block definition to the sheet. Dim oTitleBlock As TitleBlock oTitleBlock = oSheet.AddTitleBlock(oTitleBlockDef, , sPromptStrings) Next End Function
i was learning i logic,for my understanding, this can be use with single prompted entry. can it be use with multiple prompted entry?
Hello RSeufzer,
this code should work:
Sub Main() Dim oDrawDoc As Inventor.DrawingDocument oDrawDoc = ThisApplication.ActiveDocument Rename_SheetName(oDrawDoc) Create_PageNo(oDrawDoc) End Sub Sub Rename_SheetName(ByVal oDrawdoc As Inventor.DrawingDocument) Dim oSheet As Sheet oSheet = oDrawdoc.ActiveSheet Dim Number As String = InputBox("Input initial number", "Rename sheets", "1") Dim Letter As String = "A" Dim FirstSheet As Boolean = True For Each oSheet In oDrawdoc.Sheets If FirstSheet = True Then oSheet.Name = Number FirstSheet = False Else oSheet.Name = Number + Letter Letter = Chr(Asc(Letter) + 1) End If Next End Sub Sub Create_PageNo(ByVal oDrawdoc As Inventor.DrawingDocument) ' Set a reference to the drawing document. ' This assumes a drawing document is active. ' Obtain a reference to the desired border defintion. Dim oTitleBlockDef As TitleBlockDefinition oTitleBlockDef = oDrawdoc.TitleBlockDefinitions.Item("Standard (WB)") Dim oSheet As Sheet Dim oSheets As Sheets = oDrawdoc.Sheets 'oSheet = oDrawDoc.ActiveSheet For Each oSheet In oSheets ' Check to see if the sheet already has a title block and delete it if it does. If Not oSheet.TitleBlock Is Nothing Then oSheet.TitleBlock.Delete() End If ' This title block definition contains one prompted string input. An array ' must be input that contains the strings for the prompted strings. ' remove the ":1" Dim positionOfDubbleDot As Integer = Strings.InStrRev(oSheet.Name, ":") Dim Length As Integer = Len(oSheet.Name) Dim stringYouNeed As String = Strings.Left(oSheet.Name, Length - (Length - positionOfDubbleDot) - 1) Dim sPromptStrings(0) As String 'start counting by 0 !!! sPromptStrings(0) = stringYouNeed 'if there is only one promped entry 'sPromptStrings(1) = "String 2" ' Add an instance of the title block definition to the sheet. Dim oTitleBlock As TitleBlock oTitleBlock = oSheet.AddTitleBlock(oTitleBlockDef, , sPromptStrings) Next End Sub
That is correct,
the example here is with one Prompted entry, but in the code is also for a second Prompted entry the code as comment,
you can copy that for aditional prompted entries.
Can you attach the example that contain 2 or more prompted entries.it more easy to understand how the code function.....thanks you
Where does the code
positionOfDubbleDot = Strings.InStrRev(oSheet.Name,":") Length = Len(oSheet.Name) stringYouNeed = Left(oSheet.Name, Length-(Length-positionOfDubbleDot)-1)
go to get rid of the :2 in the sheet name? I have tried to use the original code you put out there for inserting sheet names into the title block. Also, there is no trigger to make it happen or it's not working properly.
Can't find what you're looking for? Ask the community or share your knowledge.