Auto naming an excel file - Inventor 2025

Auto naming an excel file - Inventor 2025

andregsPGJRY
Explorer Explorer
216 Views
6 Replies
Message 1 of 7

Auto naming an excel file - Inventor 2025

andregsPGJRY
Explorer
Explorer

Hello,

 

I work for a tube manufacturing company, and to reduce the risk of errors caused by incorrectly loaded Excel spreadsheets, I would like to automate the process of displaying the file name on the printed drawing. Specifically, I want to add a line to the drawing showing the name of the loaded file, as shown in the attached image. The file name should update automatically without the need for a drafter to manually enter it.

 

I cannot add the file name directly in the Excel file because I use the same file to load coordinates into my measurement software, and the software wouldn't recognize this text.

 

Edit: I'm using Inventor 2025

 

Thanks in advance for your help.

@andregsPGJRY - I have modified the post title to add the product and version - thank you for sharing it!  CGBenner

0 Likes
217 Views
6 Replies
Replies (6)
Message 2 of 7

CGBenner
Community Manager
Community Manager

@andregsPGJRY 

Hello, and welcome!  Can you share what version of Inventor you are working with?  

I wonder if this is something that would require some programming, but I will wait to see what the forums experts say.

Did you find a post helpful? Then feel free to give likes to these posts!
Did your question get successfully answered? Then just click on the 'Accept solution' button.  Thanks and Enjoy!


Chris Benner
Community Manager

0 Likes
Message 3 of 7

andregsPGJRY
Explorer
Explorer

Hello @CGBenner ! I'm using inventor 2025!

Message 4 of 7

johnsonshiue
Community Manager
Community Manager

Hi! I suspect this can be automated by using an iLogic rule. Let me move the thread to Inventor Programming forum.

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
0 Likes
Message 5 of 7

A.Acheson
Mentor
Mentor

Hi @andregsPGJRY 

Can you explain the objects your using in inventor? Some objects are harder to gain access to especially if there linked to an excel sheet. Your image shows a cell under a custom table perhaps place by the embedded excel file? Would it be easier to display the information in the excel doc and then bring it into the drawing that way? If you could explain the shortest path you could do this manually then we can help you automate this method. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 6 of 7

jake_egley
Advocate
Advocate

Hi @andregsPGJRY  I've copied the code I use that will place the part number and description from the model into the top left corner of the drawing. It will also rename the sheet with the part number.This may be a starting point for you. This is iLogic code. 

Dim oDrawDoc As DrawingDocument
Dim oSheet As Sheet
Dim oDrawingView As DrawingView
Dim oDrawingViewComponent As PartDocument
Dim oDrawingViewComponentAsm As AssemblyDocument
Dim oDrawingViewComponentPres As PresentationDocument
Dim oPartDesc As GeneralNote
Dim oTextBoxes As GeneralNotes

If ThisApplication.ActiveDocument.DocumentType <> kDrawingDocumentObject Then
	MessageBox.Show ("Please run this rule on a drawing", "Autodesk Inventor", MessageBoxButtons.OK, MessageBoxIcon.Error)
	Exit Sub
End If
	
oDrawDoc = ThisApplication.ActiveDocument

' Set a reference to the active sheet
oSheet = oDrawDoc.ActiveSheet

' Set a reference to general notes
oTextBoxes = oSheet.DrawingNotes.GeneralNotes
Try
If oSheet.DrawingViews(1).ReferencedDocumentDescriptor.ReferencedDocumentType = kPartDocumentObject Then
	oDrawingViewComponent = oSheet.DrawingViews(1).ReferencedDocumentDescriptor.ReferencedDocument  
	oSheet.Name = oDrawingViewComponent.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value
Else If oSheet.DrawingViews(1).ReferencedDocumentDescriptor.ReferencedDocumentType = kAssemblyDocumentObject Then
	oDrawingViewComponentAsm = oSheet.DrawingViews(1).ReferencedDocumentDescriptor.ReferencedDocument
	oSheet.Name = oDrawingViewComponentAsm.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value
Else If oSheet.DrawingViews(1).ReferencedDocumentDescriptor.ReferencedDocumentType = kPresentationDocumentObject Then
	oDrawingViewComponentPres = oSheet.DrawingViews(1).ReferencedDocumentDescriptor.ReferencedDocument
	oDrawingViewComponentAsm = oDrawingViewComponentPres.referencedfiles.item(1)
	oSheet.Name = oDrawingViewComponentAsm.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value	
End If
Catch ex As Exception 
	MessageBox.Show("Please run the rule after placing a view", "Autodesk Inventor", MessageBoxButtons.OK, MessageBoxIcon.Error)
	Exit Sub
End Try	

sText = "<StyleOverride FontSize='0.6096'><Property Document='model' PropertySet='Design Tracking Properties' Property='Part Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='5'>PART NUMBER</Property></StyleOverride><Br/><StyleOverride FontSize='0.254'><Property Document='model' PropertySet='Design Tracking Properties' Property='Description' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='29'>DESCRIPTION</Property></StyleOverride>"                
oTG = ThisApplication.TransientGeometry
oTextBox2 = oSheet.DrawingNotes.GeneralNotes.AddFitted(oTG.CreatePoint2d(0.4, 20.6), sText)

 

Jake Egley
Inventor 2022
0 Likes
Message 7 of 7

CGBenner
Community Manager
Community Manager

@andregsPGJRY 

 

Hello, do you still need help with this question?

Did you find a post helpful? Then feel free to give likes to these posts!
Did your question get successfully answered? Then just click on the 'Accept solution' button.  Thanks and Enjoy!


Chris Benner
Community Manager

0 Likes