iLogic saveas invalid argument

iLogic saveas invalid argument

Anonymous
Not applicable
1,149 Views
9 Replies
Message 1 of 10

iLogic saveas invalid argument

Anonymous
Not applicable

Hey all!

 

I'm having some trouble narrowing down the issues with this rule. I want to be able to save whatever document is open to a certain location, with the specified filename. I havent gotten as far as to tell it where to save, but that will be next after this snag.

 

The problem is I keep getting this same error after rewriting the code several times. I can get it to save, but not to save as. Ive browsed through seveal forum posts and online about this and cant seem to find what is different in my code than the ones that seem to work. currently this is in a dwg file. i know dwgFName is fine because I can get it to show me the string just fine if I comment out the saveas line.

 

Attached is the error message,

 

"Error in rule: Save As PN, in document: Cube.idw.

 

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

 

Here is my code - 

 

'get model filename
Dim fname As String
oViewModelName = ThisApplication.ActiveDocument.ActiveSheet.DrawingViews.Item(1).ReferencedDocumentDescriptor.ReferencedFileDescriptor.FullFileName
fname = System.IO.Path.GetFileName(oViewModelName)

'set dwg no
PN = iProperties.Value(fname, "Project", "part number")
Rev = iProperties.Value("Project", "Revision Number")
iProperties.Value("Project", "part number") = PN + "-MFG " + Rev
Dim dwgFName As String
dwgFName = iProperties.Value("Project", "part number")

ThisApplication.ActiveDocument.SaveAs(dwgFName & ".ipt", True)
'ThisDoc.Document.SaveAs("test", True)

MessageBox.Show(dwgFName)

 

Any and all input would be much appreciated!

Thanks for your time,

D

0 Likes
1,150 Views
9 Replies
Replies (9)
Message 2 of 10

bradeneuropeArthur
Mentor
Mentor

You try to save the active document "drawing" as an .ipt!!!

you are getting properties from an occurrence. a drawing has no occurrences.

 

try to explain what you want to do.

 

do you want try to save the drawing equal to the ipt?

this is already automatically done by inventor.

 

please explain further, because the code is a mix of something but not clear to me....

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 10

chandra.shekar.g
Autodesk Support
Autodesk Support

@Anonymous,

 

ThisApplication.ActiveDocument.SaveAs(dwgFName & ".ipt", True)

The above iLogic code indicates that path is not defined properly in "dwgFName" variable. So, this could be root cause for error.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 4 of 10

Anonymous
Not applicable

@bradeneuropeArthur

Derp. haha yea I just noticed that; I was trying to see what the problem was and that was just to help narrow it down. the issue occurs with idw extension as well. I'm not sure what you mean by occurrence.. I can pull the iProperties just fine, I just can't save.

 

I dont like having to enter the same data more than once, so I wanted to have Inventor default the new filename as the part number from the ipt that is loaded, plus some other iProperties. This is what dwgFName does, and after a few edits it gives me the string I want. I just cant save it using this string as a filename. 

0 Likes
Message 5 of 10

Anonymous
Not applicable

@chandra.shekar.g

Do you mean that inventor doesnt know where to put the file? 

0 Likes
Message 6 of 10

chandra.shekar.g
Autodesk Support
Autodesk Support

@Anonymous,

 

"SaveAs"  Inventor API accepts valid path and name of file to save the document into.

 

Thanks and regards,

 


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 7 of 10

Anonymous
Not applicable

@chandra.shekar.g

 

Can you show me how to pull the path from the loaded model?

I'm trying to use workspacepath() to pull the location of the ipt file, but I'm not sure how to do that for the referenced file.

 

Here is what I have that works

 

Dim oPath As String = ThisDoc.workspacepath()

but that returns the path of the dwg file, not the ipt file. i want to save the dwg in the same folder as the ipt file. 

When I use "oViewModelName" as the argument for workspacepath, I get an error message

 

"conversion from string to "\\locationstuff\dummytext\otherstuff\" to type 'integer' is not valid"

 

I dont understand why it keeps trying to convert to an integer.

0 Likes
Message 8 of 10

chandra.shekar.g
Autodesk Support
Autodesk Support

@Anonymous,

 

After updating iProperties, try below iLogic code to save drawing document at model document location.

 

modelPath = IO.Path.GetDirectoryName(ThisDrawing.ModelDocument.FullFileName)
ThisApplication.ActiveDocument.SaveAs(modelPath & "\"& dwgFName & ".idw", True)

Please feel free to contact if there is any queries.

 

If solves problem, click on "Accept as solution" / give a "Like".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 9 of 10

Anonymous
Not applicable

Nice @chandra.shekar.g that works!

 

Now.. when we save for the first time on a new dwg, the new document that was created is now the active document on the screen. when I run this code, A copy will be saved in the background and I have to close the current dwg and then go find the other document that was saved and open it. 

 

How can I set this up so that the new saved document becomes the active document on the screen after I run the rule?

0 Likes
Message 10 of 10

chandra.shekar.g
Autodesk Support
Autodesk Support

@Anonymous,

 

Below blog article explains difference between SaveAs and SaveCopyAs. I think, this answers your question.

 

http://adndevblog.typepad.com/manufacturing/2012/12/saveas-with-savecopyas-false.html

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes