Document Save As error messages

Document Save As error messages

Thomas.Long
Advocate Advocate
635 Views
3 Replies
Message 1 of 4

Document Save As error messages

Thomas.Long
Advocate
Advocate

So I've been perusing the forums for a while and I'm having difficulty with a particular program of mine and its generating error messages, though inconsistently. 

 

SyntaxEditor Code Snippet

ThisDoc.Save

Dim FileName As String

If Length > 100

    FileName = "N:\Mechpart\TLONG\Reference Materials\" & CStr(PartNumber & Floor(Length) & Length_Frac & ".ipt")
    ThisDoc.Document.SaveAs(FileName, True)
    

Else

    FileName = "N:\Mechpart\TLONG\Reference Materials\" & CStr(PartNumber & "0" & Floor(Length) & Length_Frac & ".ipt")
    ThisDoc.Document.SaveAs(FileName, True)
    


End If 

 

The basic idea is that a larger assembly is using this dynamic part and inputting it into the larger assembly when the correct version of it can't be located. Its then feeding into the dynamic part from the assembly the appropriate geometry for the part and doing a save as on the part, and then replacing the part in the assembly with the newly created version of the part.

 

I've narrowed it down to this rule, because I've gone into the component itself and just ran this rule individually and it gives this error alone. Most of the time it gives this error

Error in rule: Save As, in document: C15.ipt

Object of type 'System.UInt32' cannot be converted to type 'Inventor.CommandTypesEnum'.

 

The funny thing is the rule still actually works even though it won't let me "ok" out of the rule. I also occasionally get

 

Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))

 

Though that is much more rare. The final one I get, also rare, is

 

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

 

All of them seem to indicate to me that the program thinks it is an integer I'm trying to pass it (though I'm honestly quite new at this so I could be misreading it) and despite all attempts every now and again it will work for about 3 times straight and then break again. Any help provided would be most useful. Thank you!

0 Likes
636 Views
3 Replies
Replies (3)
Message 2 of 4

arrakisman
Enthusiast
Enthusiast

If your variable "ThisDoc" is set as a PartDocument then you should not need the .document.

 

Dim ThisDoc As PartDocument

Dim FileName As String

If Length > 100

    FileName = "N:\Mechpart\TLONG\Reference Materials\" & CStr(PartNumber & Floor(Length) & Length_Frac & ".ipt")
    ThisDoc.SaveAs(FileName, True)
    

Else

    FileName = "N:\Mechpart\TLONG\Reference Materials\" & CStr(PartNumber & "0" & Floor(Length) & Length_Frac & ".ipt")
    ThisDoc.SaveAs(FileName, True)
    


End If 

 

 

0 Likes
Message 3 of 4

Thomas.Long
Advocate
Advocate

Apologies for the very late reply.

I did not set the variable in inventor, rather I'm just using the basic functions provided by iLogic. When I tried removing the .Document it ended up passing me the error

 

Rule Compile Errors in Save As, in C15.ipt

Error on Line 9 : 'SaveAs' is not a member of 'Autodesk.iLogic.Interfaces.ICadDoc'.
Error on Line 15 : 'SaveAs' is not a member of 'Autodesk.iLogic.Interfaces.ICadDoc'.

 

If I can declare it, would it fix my issue?

 

Thank you again.

0 Likes
Message 4 of 4

Thomas.Long
Advocate
Advocate

Update:

 

So I've done more testing with it. The program seems to run fine whenever I simply enter a text string for it to save as. The error seems to occur when I attempt to use a variable in the save as function, even if I specifically use the cStr conversion on any numbers involved. I'm not certain why it fails to work specifically when a variable is involved.

 

Thank you again

0 Likes