Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
paulZKN98
175 Views, 2 Replies

Custom File naming syntax (beginner!) help

Hi everyone, I am a beginner to ilogic and have thus far only copy and pasted code from others.  I'm trying to write my own code to perform the following function: I would like a default filename scheme for drawings as "partnumber"-"description".idw.  upon the first save.  Example 1234-1234-Bottom Bracket.idw

Here is what my code looks like, if anyone can provide guidance I would be much appreciated. 

 

"ThisDoc.FileName(False) 'without extension" = (iProperties.Value("Project", "Part Number"))(iProperties.Value("Project", "Description"))

I am very excited to be getting into this, I've wanted to branch out into ilogic for some time now but but time hasn't allowed it.  Many many thanks!!

 

 

 

Zach.Stauffer
in reply to: paulZKN98

ThisDoc.FileName is a read-only property, you can't set it from code. If you are creating a drawing from scratch then you need to make your filename first as a string and have Inventor create the drawing for you.

 

The correct syntax to create the filename would look something like this:

Dim filename = iProperties.Value("Project", "Part Number") & "-" & iProperties.Value("Project", "Description") & ".idw"

 

To create a new drawing you use the ThisApplication object.

Dim drawing as DrawingDocument = ThisApplication.Documents.Add(kDrawingDocumentObject)

drawing.SaveAs(filename, False) 

 

yan.gauthier
in reply to: paulZKN98

Hi,

 

Ilogic uses VB.Net, what you are trying to do is called contatenation. It the process of combining several strings into one.

 

VB.Net uses "&" as its concatenation operator: 

filename = iProperties.Value("Project", "Part Number") & " - " & iProperties.Value("Project", "Description")

Also, You cannot change a file name on the fly. It's only upon creating it that you can set its name. If it was possible, we would need a way to update every files that refers to this filename.