iLogic code to Save File

iLogic code to Save File

Anonymous
Not applicable
5,384 Views
6 Replies
Message 1 of 7

iLogic code to Save File

Anonymous
Not applicable

Hey All,

I'm trying to save a file as "PartNumber-SequenceNumber" with iLogic code. For example, 12345678-0001.ipt is how a file would be saved.

 

So far, what I've got is this:

 

Dim PartNumber As String
Dim SequenceNumber As String

PartNumber = iProperties.Value("Project", "Part Number")
SequenceNumber = iProperties.Value("Custom", "Sequence Number")

ThisDoc.Document.SaveAs("PartNumber""-""SequenceNumber", False)

 

How can I do this better? Right now, I'm getting the following error code:

 

The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

 

Thanks!

 

  -Luke

 

 

0 Likes
Accepted solutions (1)
5,385 Views
6 Replies
Replies (6)
Message 2 of 7

Curtis_Waguespack
Consultant
Consultant

 

Hi nealon.luke,

 

 Something like this should work, although I didn't test it.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

Dim PartNumber As String
Dim SequenceNumber As String

PartNumber = iProperties.Value("Project", "Part Number")
SequenceNumber = iProperties.Value("Custom", "Sequence Number")

ThisDoc.Document.SaveAs(PartNumber & "-" & SequenceNumber, False)

EESignature

Message 3 of 7

Anonymous
Not applicable

Still getting this error even with that fix...

 

 

The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

0 Likes
Message 4 of 7

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi nealon.luke,

 

We need a path and file extension too. Also, I think you'll get an error if the file already exists, so you'd want to check for that as well.

 

Also just as a tip, you can search and ask programming questions of this type on the Inventor Customization forum too:
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

Dim PartNumber As String
Dim SequenceNumber As String

PartNumber = iProperties.Value("Project", "Part Number")
SequenceNumber = iProperties.Value("Custom", "Sequence Number")
oPath = "C:\TEMP\"
ThisDoc.Document.SaveAs(oPath & PartNumber & "-" & SequenceNumber & ".ipt", False)

 

 


 

EESignature

Message 5 of 7

Anonymous
Not applicable
Great, thanks Curtis
0 Likes
Message 6 of 7

mcgyvr
Consultant
Consultant

Autodesk should update the code snippit then.. The snippit just says 

ThisDoc.Document.SaveAs(NewFileNameAndExtension , True)

Should be this

ThisDoc.Document.SaveAs(PathAndNewFileNameAndExtension , True)


-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
Message 7 of 7

Curtis_Waguespack
Consultant
Consultant

Hi mcgyvr,

 

You're not wrong.

 

There are several areas in the iLogic tools and documentation that need:

  • ommisions added
  • incorrect information corrected
  • unclear or misleading information revised
  • working examples included

Overall some attention is needed to bridge the communication gap between the Autodesk iLogic developers who create and document the iLogic tools and the iLogic users, particularly new iLogic users.

 

In the past it seemed to me that much of the documentation, certification material, etc. was handed from software engineers who had never used the tools in a real world situation, to technical writers who had never used the tools in a real world situation. Resulting in vague and ambiguous documentation. The iLogic documentation has that feel about it.

 

To be fair though, I think iLogic has been used above and beyond what the Autodesk iLogic developers had in mind originally, as Inventor users have bent it to our will. In any case, it needs and deserves a bit of attention at this point, IMHO.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

EESignature

0 Likes