Error when save a file

Error when save a file

SandmanINV
Advocate Advocate
975 Views
3 Replies
Message 1 of 4

Error when save a file

SandmanINV
Advocate
Advocate

Hi, 

At the end of part, i often use "oinv.activedocument.save(.......,False)" to saving a file (ipt or iam).

oinv is a variable of inventor.application.

It often save successfully, but, sometime, my programe meet error when debug to this line.

If i try turn off inventor and start again, it save successfully.

So I dont know what wrong with them, how to fix this ?

Please give me some advices ?

Thank you, 

 

0 Likes
Accepted solutions (1)
976 Views
3 Replies
Replies (3)
Message 2 of 4

Sergio.D.Suárez
Mentor
Mentor

Hi, I would try thisDoc, to set the document, not ActiveDocument, sometimes it creates conflicts when you are in a document and the rule should save another document, but the active document is the first one, instead thisDoc specifies that it is that document in particular where the rule is located

Dim doc = ThisDoc.Document
doc.Save

 


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

Message 3 of 4

SandmanINV
Advocate
Advocate

Thank you for your advice, I am using vb.net. So i dont find "Thisdocument" in VB.net.

So I using this code flollow your advice.

        Dim osave_file As Document
        osave_file.SaveAs(ofilename_asm_xuongdam, False)

But it still error. Maybe I still wrong some where...

0 Likes
Message 4 of 4

GeorgK
Advisor
Advisor
Accepted solution
Dim m_inventorApplication As Inventor.Application = Nothing
m_inventorApplication = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application")
Dim oDoc As Document
oDoc = m_inventorApplication.ActiveDocument
oDoc.SaveAs("C:\Temp\TestFile.ipt", True)

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

0 Likes