iLogic to change sheet name to equal Part Number.

iLogic to change sheet name to equal Part Number.

dbowerU62F5
Explorer Explorer
859 Views
1 Reply
Message 1 of 2

iLogic to change sheet name to equal Part Number.

dbowerU62F5
Explorer
Explorer

Hi All,

 

I am a total newcomer to using iLogic. For  my new job and the way I am using Inventor using this function would greatly save time in the design office.

 

Would someone be able to walk me through step-by-step how to implement the code and function that will automatically set the sheet name to the iProperty Part Number of the part that is first placed in the base view of the drawing sheet as I have seen has been discussed in the forum in the recent past. I would appreciate any advice with this.

 

Many thanks in advance

 

 

0 Likes
860 Views
1 Reply
Reply (1)
Message 2 of 2

Owner2229
Advisor
Advisor

Very well, here you go:

In attachment I'm sending you the complete list of iProperties (and Property sets) for Inventor 2017.

 

'Get the active document
Dim oDoc As Document = ThisApplication.ActiveDocument
'Check if the document is drawing, exit if not
If oDoc.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then Exit Sub
'List througth each drawing sheet
For Each oSheet As Inventor.Sheet In oDoc.Sheets
	'Check if the sheet has any drawing views, skip if not
	If oSheet.DrawingViews.Count = 0 Then Continue For
	'Get the first drawing view
	Dim oView As DrawingView = oSheet.DrawingViews(1)
	'Get the referenced document
	Dim oModel As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument
	'Get the ref. document's design property set
	Dim oPropSet As PropertySet = oDoc.PropertySets.Item("Design Tracking Properties")
	'Get the part number
	Dim oPartNumber As String = oPropSet.Item("Part Number").Value
	'Change the sheet's name
	oSheet.Name = oPartNumber
Next
Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods