Drawing sheet list with more properties

Drawing sheet list with more properties

kresh.bell
Collaborator Collaborator
766 Views
10 Replies
Message 1 of 11

Drawing sheet list with more properties

kresh.bell
Collaborator
Collaborator

Hi,

is it possible to make iLogic that would generate a sheet list on the first sheet and also use, for example, description custom properties from each sheet?

0 Likes
Accepted solutions (2)
767 Views
10 Replies
Replies (10)
Message 2 of 11

Andrii_Humeniuk
Advisor
Advisor

Hi @kresh.bell . Yes, it is possible. Using the DrawingDocument.Sheets method you can get all your sheets and make a list of them. An example of solving a problem: Link, Link, GitHub.
We can help you implement a more personalized iLogic code if you share with us more information about your case and your needs.

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

0 Likes
Message 3 of 11

kresh.bell
Collaborator
Collaborator

This is ok for me iLogic.

Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument

Dim oSheet, oIndexSheet As Sheet
Dim sSheetName, sSheetNo, sSheetRev As String
Dim oTitleBlock As TitleBlock
Dim oTextBox As Inventor.TextBox

oIndexSheet = oDoc.Sheets(1)'In order to put table on sheet 1

'[Table Setup
Dim oColumns, oRows, oCells, i As Integer
oColumns = 3
i = 0
oRows = oDoc.Sheets.Count
oCells = oColumns * oRows 'calculate number of cells

Dim oContents(oCells - 1) As String 'Minus 1 as array will start from zero
Dim oTitles(oColumns - 1) As String 'Minus 1 as array will start from zero
'Hardcoded titles 
oTitles(2) = "DESCRIPTION"
oTitles(1) = "SHEET #"
oTitles(0) = "SHEET REV"
']

iCount = 1
For Each oSheet In oDoc.Sheets

	sSplit = Split(oSheet.Name, ":")

	Try : sSheetName = sSplit(0) : Catch : sSheetName = oSheet.Name : End Try
	sSheetNo = iCount
		
	sSheetRev = oSheet.Revision

	Try 'to get title block
		oTitleBlock = oSheet.TitleBlock

		For Each oTextBox In oTitleBlock.Definition.Sketch.TextBoxes
			If oTextBox.Text = "SHEET-NAME" Then
				Call oTitleBlock.SetPromptResultText(oTextBox, sSheetName)
			End If
		Next
	Catch 
		'handle error when no title block is on the sheet
	End Try
	
	'[Table Data
	oContents(i) = sSheetRev 'Add to string 
	i = i + 1
	oContents(i) = sSheetNo  'Add to string 
	i = i + 1
	oContents(i) = sSheetName  'Add to string 
	i = i + 1
	']

	iCount = iCount +1
Next

Dim InsP As Point2d
InsP = ThisApplication.TransientGeometry.CreatePoint2d(10, 15)

Dim oCustomTable As CustomTable
oTableName = "DRAWING INDEX"

Try : oIndexSheet.CustomTables.Item(1).Delete : Catch : End Try

oCustomTable = oIndexSheet.CustomTables.Add(oTableName, InsP, oColumns, oRows, oTitles, oContents)

 

Can I use custom properties from the title block to populate the Description column?

kreshbell_0-1728996811449.png

 

Also Revision number.

 

0 Likes
Message 4 of 11

WCrihfield
Mentor
Mentor

Just a tip...

Be careful using a 'For Each...Next' type of loop, with a separate Index counter, if that Index is important.  When iterating through a collection that way, the order of that iteration is not guaranteed.  If Index is important, then you should use a 'For i = # to #...Next' type of loop.  That ensures that the items will be encountered in their 'natural' order.  In a drawing, the Sheets collection seems to be ordered a bit differently than most types of collections, because the 'sheet number' will always be in the order they are seen in the model browser tree.  If you physically drag the first sheet down to the next position after the current sheet 3, it will become Sheet 3 itself, because the original sheet 2 will become sheet 1, and the original sheet 3 will become sheet 2.  The first part of the sheet's name will stay the same, but the Index number is managed automatically by Inventor.

 

Also, you are likely aware of this, but there is a document level revision level (in the standard iProperties), then there is also a sheet level revision level (Sheet.Revision ).  However, sheets do not have their own PropertySets, like Documents do.  So, if you have a different model file being referenced on each sheet of your drawing, and have the description of that model file in the title block of that sheet, but want that information to be shown in a table cell on the first sheet, it will be relatively complicated to gather that information in the first place, and will likely be 'static' information within the table cell, instead of 'linked'.  Because it would require iterating through each TextBox within the sketch, within the definition of each title block, and somehow knowing which TextBox is for which property (because a TextBox does not have a name), and retrieving its 'Text' value.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 11

Andrii_Humeniuk
Advisor
Advisor
Accepted solution

If I understood you correctly. Your code should look like this:

Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument

Dim oSheet, oIndexSheet As Sheet
Dim sSheetName, sSheetNo, sSheetRev As String
Dim oTitleBlock As TitleBlock
Dim oTextBox As Inventor.TextBox

oIndexSheet = oDoc.Sheets(1)'In order to put table on sheet 1

'[Table Setup
Dim oColumns, oRows, oCells, i As Integer
oColumns = 3
i = 0
oRows = oDoc.Sheets.Count
oCells = oColumns * oRows 'calculate number of cells

Dim oContents(oCells - 1) As String 'Minus 1 as array will start from zero
Dim oTitles(oColumns - 1) As String 'Minus 1 as array will start from zero
'Hardcoded titles 
oTitles(2) = "DESCRIPTION"
oTitles(1) = "SHEET NAME"
oTitles(0) = "SHEET №"
']

iCount = 1
For Each oSheet In oDoc.Sheets

	sSplit = Split(oSheet.Name, ":")

	Try : sSheetName = sSplit(0) : Catch : sSheetName = oSheet.Name : End Try
	sSheetNo = iCount
		
	sSheetRev = oSheet.Revision

	Try 'to get title block
		Dim oTB As TitleBlock = oSheet.TitleBlock
		Dim oTextBoxes As TextBoxes = oTB.Definition.Sketch.TextBoxes
		For Each oTBox As Inventor.TextBox In oTextBoxes
			Dim sData As String = oTB.GetResultText(oTBox)
			If Not oTBox.Text = "<DESCRIPTION>" Then Continue For
			sSheetRev = oTB.GetResultText(oTBox)
		Next
	Catch 
		'handle error when no title block is on the sheet
	End Try
	
	'[Table Data
	oContents(i) = sSheetNo 'Add to string 
	i = i + 1
	oContents(i) = sSheetName  'Add to string 
	i = i + 1
	oContents(i) = sSheetRev  'Add to string 
	i = i + 1
	']

	iCount = iCount +1
Next

Dim InsP As Point2d
InsP = ThisApplication.TransientGeometry.CreatePoint2d(10, 15)

Dim oCustomTable As CustomTable
oTableName = "DRAWING INDEX"

Try : oIndexSheet.CustomTables.Item(1).Delete : Catch : End Try

oCustomTable = oIndexSheet.CustomTables.Add(oTableName, InsP, oColumns, oRows, oTitles, oContents)

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

0 Likes
Message 6 of 11

kresh.bell
Collaborator
Collaborator

Hi @Andrii_Humeniuk 

thanks, sorry for delay. yes, it works well. exept description column. is it possible instead desciption add revision number? also, if I want add some column, for manual populate, what can I do?

0 Likes
Message 7 of 11

kresh.bell
Collaborator
Collaborator

Hi @Andrii_Humeniuk 

please, can you add 4 columns in iLogic that do not have custom properties, they are free to fill? Text1, Text2, Text3 and Text4?

0 Likes
Message 8 of 11

Andrii_Humeniuk
Advisor
Advisor
Accepted solution

Sorry for the delay. Changed the 3rd column from the description column to the revision number column and added an additional 4 columns.

 

Dim oInvApp As Inventor.Application = ThisApplication
Dim oDoc As DrawingDocument = oInvApp.ActiveDocument

Dim oSheet, oIndexSheet As Sheet
Dim sSheetName, sSheetNo, sSheetRev As String
Dim oTitleBlock As TitleBlock
Dim oTextBox As Inventor.TextBox

oIndexSheet = oDoc.Sheets(1)'In order to put table on sheet 1

'[Table Setup
Dim oColumns, oRows, oCells, i As Integer
oColumns = 7
i = 0
oRows = oDoc.Sheets.Count
oCells = oColumns * oRows 'calculate number of cells

Dim oContents(oCells - 1) As String 'Minus 1 as array will start from zero
Dim oTitles(oColumns - 1) As String 'Minus 1 as array will start from zero
'Hardcoded titles 
oTitles(6) = "Text4"
oTitles(5) = "Text3"
oTitles(4) = "Text2"
oTitles(3) = "Text1"
oTitles(2) = "REVISION"
oTitles(1) = "SHEET NAME"
oTitles(0) = "SHEET №"
']

iCount = 1
For Each oSheet In oDoc.Sheets

	sSplit = Split(oSheet.Name, ":")

	Try : sSheetName = sSplit(0) : Catch : sSheetName = oSheet.Name : End Try
	sSheetNo = iCount
		
	sSheetRev = oSheet.Revision
	
	'[Table Data
	oContents(i) = sSheetNo 'Add to string 
	i += 1
	oContents(i) = sSheetName  'Add to string 
	i += 1
	oContents(i) = sSheetRev  'Add to string 
	i += 1
	oContents(i) = ""  'Add to string Text1
	i += 1
	oContents(i) = ""  'Add to string Text2
	i += 1
	oContents(i) = ""  'Add to string Text3
	i += 1
	oContents(i) = ""  'Add to string Text4
	i += 1
	']

	iCount += 1
Next

Dim InsP As Point2d = oInvApp.TransientGeometry.CreatePoint2d(10, 15)

Dim oCustomTable As CustomTable
oTableName = "DRAWING INDEX"

Try : oIndexSheet.CustomTables.Item(1).Delete : Catch : End Try

oCustomTable = oIndexSheet.CustomTables.Add(oTableName, InsP, oColumns, oRows, oTitles, oContents)

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

Message 9 of 11

kresh.bell
Collaborator
Collaborator

Hi @Andrii_Humeniuk 

works great, great job. Thank you very much. Revision number is not filled in automatically, but somehow I can do without it

0 Likes
Message 10 of 11

DeptaM
Enthusiast
Enthusiast

Hello,
if you add a revision label to the sheet, it will be overwritten in the revision table.

 

rev_01.png

rev_02.png

0 Likes
Message 11 of 11

rcF4Z23
Explorer
Explorer

Hi @Andrii_Humeniuk 

is it possible to add the date of the revision and the name of the designer?

 

0 Likes