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!!
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)
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.