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: 

Sheet Names

27 REPLIES 27
SOLVED
Reply
Message 1 of 28
Anonymous
6232 Views, 27 Replies

Sheet Names

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?

27 REPLIES 27
Message 2 of 28
Anonymous
in reply to: Anonymous

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.

 

Message 3 of 28
Anonymous
in reply to: Anonymous

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....

Message 4 of 28
HermJan.Otterman
in reply to: Anonymous

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

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


Message 5 of 28
Anonymous
in reply to: Anonymous

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.

Message 6 of 28
Anonymous
in reply to: Anonymous

where do I enter this first line?

I haven't entered any custom code as of yet.

Message 7 of 28
tolgay.hickiran
in reply to: Anonymous

small tip for you,

Dim oDrawDoc As Inventor.DrawingDocument = Thisapplication.ActiveDocument

Everytime you see a code Thisapplication.ActiveDocument, you immediately know that this bit of the code would work on the same document that you want to do some changes, in this case, your drawing

Some worthwhile ideas
Copy Design should rename ilogic Rules too!
Why Nastran In-CAD doesn't have an SDK?IMPLEMENTED!

Tolgay Hickiran
Founding Partner
SignatureSignature

website
emailskypelinkedinyoutubeemail

Message 8 of 28
Anonymous
in reply to: Anonymous

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.

Message 9 of 28
HermJan.Otterman
in reply to: Anonymous

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

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


Message 10 of 28

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 Programmer (C#, VB.Net / iLogic)


EESignature


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.


Message 11 of 28

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..

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


Message 12 of 28
Anonymous
in reply to: HermJan.Otterman

@HermJan.Otterman 

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

Message 13 of 28
HermJan.Otterman
in reply to: Anonymous

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)

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


Message 14 of 28
Anonymous
in reply to: HermJan.Otterman

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



Message 15 of 28
Anonymous
in reply to: Anonymous

@HermJan.Otterman 

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
Message 16 of 28
Anonymous
in reply to: HermJan.Otterman

i was learning i logic,for my understanding, this can be use with single prompted entry. can it be use with multiple prompted entry?

Message 17 of 28
HermJan.Otterman
in reply to: Anonymous

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
If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


Message 18 of 28
HermJan.Otterman
in reply to: Anonymous

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.

 

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


Message 19 of 28
Anonymous
in reply to: HermJan.Otterman

Can you attach the example that contain 2 or more prompted entries.it more easy to understand how the code function.....thanks you

Message 20 of 28
Anonymous
in reply to: HermJan.Otterman

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.

Post to forums  

Technology Administrators


Autodesk Design & Make Report