iLogic - How to access Drawing / Sheet properties

j.pavlicek
Collaborator Collaborator
1,547 Views
2 Replies
Message 1 of 3

iLogic - How to access Drawing / Sheet properties

j.pavlicek
Collaborator
Collaborator

Hello,

is somehow possible to read this two Properties with iLogic?

inventor-title-block2.PNGinventor-title-block1.PNG

 

Thank you!



Inventor 2022, Windows 10 Pro
Sorry for bad English.
0 Likes
Accepted solutions (2)
1,548 Views
2 Replies
Replies (2)
Message 2 of 3

Sergio.D.Suárez
Mentor
Mentor
Accepted solution

Hi, I think this code could serve you.
Maybe adapting it to your need

 

Dim oDoc As DrawingDocument= ThisDoc.Document
Dim oSheet As Sheet = oDoc.ActiveSheet
'Calculate number of sheets
Dim oSheetNumbers As String = oDoc.Sheets.Count
Dim i As Integer, SheetNumber As Integer
For i = 1 To oSheetNumbers
	If oDoc.Sheets(i).Name = oSheet.Name Then 
		SheetNumber = i
		Exit For
	End If
Next

MessageBox.Show( "Number of sheets: " & oDoc.Sheets.Count)
MessageBox.Show( "SheetNumber: " &SheetNumber)

 

If you want to add this property to a note, you should access in a similar way to this.

 

Dim oDoc As DrawingDocument = ThisDoc.Document
Dim oView As DrawingView = oDoc.ActiveSheet.DrawingViews(1)

oView.Label.FormattedText = "<StyleOverride><DerivedProperty DerivedID='29704'>Sheet Number</DerivedProperty></StyleOverride><Br/><StyleOverride><DerivedProperty DerivedID='29703'>Number of sheets</DerivedProperty></StyleOverride>"

 In this example, the label of the view of a drawing file will be changed with the two values you are looking for.
I hope this helps with your problem.


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

Message 3 of 3

j.pavlicek
Collaborator
Collaborator
Accepted solution

Thanks for reply. I hoped for easy acces for this numbers from some object.

Your code is ok, until there are no sheets excluded from count. So I wrote my own functions.

 

Maybe helps someone in future.

'From given sheet object returns its number. When excluded from counting, returns 0
Public Function iSheetNumber(ByVal oSheet As Sheet) As Integer
	Dim oDoc As Document
	Dim oSheetB As Sheet
	Dim sName As String
	Dim i As Integer
	Dim j As Integer
	
	'name of given sheet
	sName = oSheet.Name
	oDoc = oSheet.parent

	j = 0
	'For each sheet in document
	For i = 1 To oDoc.sheets.count
		oSheetB = oDoc.sheets(i)
		'If is NOT excluded from counting
		If oSheetB.excludefromcount = False Then
			'Increase counter by 1
			j = j + 1
		End If
		
		'If it is given sheet
		If oSheetB.name = sName Then
			'Check if is NOT excluded from counting
			If oSheetB.excludefromcount = False Then
				'Not excluded = quit with current counter (j)
				Exit For
			Else
				'Excluded from counting = set counter to 0
				j = 0
				Exit For
			End If 
		End If
	Next i
	
	'Retruns counter
	Return j
End Function

'Return total count of sheets in doc with given sheet
Public Function iSheetsCount(ByVal oSheet As Sheet) As Integer
	Dim oDoc As Document
	Dim oSheetB As Sheet
	Dim i As Integer
	Dim j As Integer
	
	'name of given sheet
	sName = oSheet.Name
	'parent document of given sheet
	oDoc = oSheet.parent

	j = 0
	'For each sheet in document
	For i = 1 To oDoc.sheets.count
		oSheetB = oDoc.sheets(i)
		'If is NOT excluded from counting
		If oSheetB.excludefromcount = False Then
			'Increase counter by 1
			j = j + 1
		End If
	Next i
	
	'Retruns counter
	Return j
End Function


Inventor 2022, Windows 10 Pro
Sorry for bad English.
0 Likes