Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Auto Page Numbering (1, 1A, 1B...)

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
Anonymous
1519 Views, 9 Replies

Auto Page Numbering (1, 1A, 1B...)

I'm trying to find a way to automate the numbering process. We number our pages currently as prompted entries and the order usually goes something like this: 

# = any number

Sheet 1 = #      (2)

Sheet 2 = #A   (2A)

Sheet 3 = #B   (2B)

Sheet 4 = #C   (2C)

 

The time consumption comes in when I have a drawing that goes up to letter N and I need to add a sheet in between say #C & #D....that means I need to update all sheets that follow. I'm not sure if there is a way to do this, but it's worth a shot!

 

Thank you in advance! 

9 REPLIES 9
Message 2 of 10
Mark.Lancaster
in reply to: Anonymous

@Anonymous 

 

You would need some code (ilogic, vb net) to do this.   There's nothing in Inventor out of the box that will do this.

 

Have you checked the Inventor Exchange app store:  https://apps.autodesk.com/INVNTOR/en/Home/Index

 

 

Mark Lancaster


  &  Autodesk Services MarketPlace Provider


Autodesk Inventor Certified Professional & not an Autodesk Employee


Likes is much appreciated if the information I have shared is helpful to you and/or others


Did this resolve your issue? Please accept it "As a Solution" so others may benefit from it.

Message 3 of 10
AdamAG99T
in reply to: Anonymous

Here's a quick Ilogic rule that should take care of this for you. I wasn't certain if you wanted the first sheet to just be the number so I gave an option for you. Just make a rule and copy this code into it and run whenever you want to fix the sheet names. This does only work for the first 26 sheets unfortunately so you'll need something more advanced if you have more than that.

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
	
	'uncomment all lines below to make the first sheet not have a letter
	'If FirstSheet = True
	'	oSheet.Name = Number
	'	FirstSheet = False
	'Else 
	oSheet.Name=Number + Letter
	Letter = Chr(Asc(Letter) + 1)
	'End If
Next 

 

Message 4 of 10
Anonymous
in reply to: AdamAG99T

That alone is extremely helpful, thank you!

I commented the code back in to have the first page without a letter, and that's what I'm looking for.

Now is there any way to transpose that into the title block page number?

 

so it would look like what's shown?

Page Number.JPG

Message 5 of 10
AdamAG99T
in reply to: Anonymous

Unfortunately I don't believe that is currently possible within the title block, although I'm no Ilogic master so I could be mistaken. You may have better luck asking in the Inventor customization board: https://forums.autodesk.com/t5/inventor-customization/bd-p/120

 

I suppose it might be possible to write a more complicated program that simply creates a separate text box with the appropriate name in the exact position on each sheet, but you would need to know the exact location the text is supposed to be, and it would be separate from the title block. Plus it would be tricky to find and delete the previous text box if you change the order. 

Message 6 of 10
mslosar
in reply to: AdamAG99T

Probably should take this to the customization forum.

 

However...you can save that output from the ilogic to any iproperty (as in a custom one) and then reference that iproperty for your sheet number. As long as you're leaving 'sheet:1', 'sheet:2', etc in the browser, you can add, rearrange sheets etc and when the ilogic is run manually or autotriggered, it would renumber all your titleblocks for you.

 

Instead of writing the value to osheet.name, you could just write it to another iproperty. Make up an iproperty "mySheetNumber" as a custom iproperty and set the value from ilogic. In the title block, reference in that iproperty. If that can't be directly referenced, create a custom prompted text value and use ilogic or an addin to set the prompted text value that way.

Message 7 of 10
AdamAG99T
in reply to: mslosar

I looked into that but from what I can tell saving it to an iproperty would apply to the entire drawing file, not just the sheet. I have not done much with iproperties before though so I could be mistaken with this, I'm simply reading some old threads and ideas such as this one: https://forums.autodesk.com/t5/inventor-ideas/custom-sheet-properties/idi-p/6470116

Message 8 of 10
mslosar
in reply to: AdamAG99T

Yeah, iproperty won't work. My fault there.

 

You can take the function where it increments the letter and loop it through all sheets. I'm not fluent enough to write it off the top of my head, but...

 

total the sheets in your drawing

loop the it (something like i=2 to totalsheets)  (skips sheet 1)

in the loop set the prompted text value of the sheet, to whatever letter you like. If i=2, then letter =A, else letter = A + (i-1)

That should loop it From A to whatever. If you cross 26 sheets, you may have to adjust it to double letters as the next numerical character isn't AA.

 

You could even extract the prompted text value of sheet 1 to if you rename that sheet, it'll pick up the rest after the fact.

 

My first plugin was a mini-app to fill in the title block because i hate have to dig in the browser and right clicking field text/edit.  I loop through the prompted text for my titleblock value and have the ability to enter them/redefine them. On subsequent pages i can acquire the values from sheet one, and in the case of my sheet number it looks at sheet 1 and will change the sheet number from xxxxxxx-xxxx-xxx- 0001 to 0002, 3, 4 etc, whatever sheet i'm on. It doesn't do all sheets at once, but in my case it doesn't have to because we average 2-3 sheets at most. Occasionally we go further but it's easy to cycle through my dialog box and make the changes even to 15 sheets. It is now in full VB, but it originate as VBA. I'll see if i can find it.

 

 

 

Message 9 of 10
mslosar
in reply to: mslosar

Ok, it looks like the looping i did was added after moving to full visual studio. Nothing in VBA other than being able to show how look for prompted text values

Message 10 of 10
Anonymous
in reply to: Anonymous

I have found a solution!

Thank you @AdamAG99T  for providing some excellent code to make this work!

sharing the solution for anyone who may need it.

First, have your page number in your title block set up as a prompted entryPrompted Entry Page Number.JPG

 

 

 

 

 

 

 

 

 

then create an external rule with this code as the body.

 

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
		
		'uncomment all lines below to make the first sheet not have a letter
		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.

			positionOfDubbleDot = Strings.InStrRev(oSheet.Name, ":")
			Length = Len(oSheet.Name)
		Dim sPromptStrings(0) As String 'start counting by 0 !!!

		sPromptStrings(0) = Left(oSheet.Name, Length-(Length-positionOfDubbleDot)-1) '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

 

Run the rule, put your page number in when prompted and the rest is automated. 

If you add a page or move pages into a different order, run the rule and it will update the page numbers.

 

Hope this helps!

 

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

Post to forums  

Autodesk Design & Make Report