Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic code to Save File

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
Anonymous
4694 Views, 6 Replies

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

iLogic code to Save File

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

 

 

Tags (2)
6 REPLIES 6
Message 2 of 7
Curtis_Waguespack
in reply to: Anonymous

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)

 

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)
Message 3 of 7
Anonymous
in reply to: Curtis_Waguespack

Anonymous
Not applicable

Still getting this error even with that fix...

 

 

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

0 Likes

Still getting this error even with that fix...

 

 

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

Message 4 of 7
Curtis_Waguespack
in reply to: Anonymous

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)

 

 


 

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)

 

 


 

Message 5 of 7
Anonymous
in reply to: Curtis_Waguespack

Anonymous
Not applicable
Great, thanks Curtis
0 Likes

Great, thanks Curtis
Message 6 of 7
mcgyvr
in reply to: Curtis_Waguespack

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

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
in reply to: mcgyvr

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

0 Likes

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

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

Post to forums  

Autodesk Design & Make Report