Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Custom File naming syntax (beginner!) help

2 REPLIES 2
Reply
Message 1 of 3
paulZKN98
159 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!!

 

 

 

2 REPLIES 2
Message 2 of 3
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) 

 

Message 3 of 3
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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report