Open Method Behaviour

Open Method Behaviour

dbrblg
Collaborator Collaborator
516 Views
3 Replies
Message 1 of 4

Open Method Behaviour

dbrblg
Collaborator
Collaborator

 

Hi,
I am writing some code to convert a Parasolid .x_t file to an Inventor .ipt file.
I am using the following simplified code:
Private Sub Command0_Click()
    Dim invApplication As Inventor.Application
    Dim invDoc As Inventor.Document
    
    On Error Resume Next
    
    Set invApplication = GetObject(, "Inventor.Application")
    
    If (Err) Then
        Err.Clear
        Set invApplication = CreateObject("Inventor.Application")
        
        invApplication.Visible = True
        
    End If
    
    Set invDoc = invApplication.Documents.Open("\\a\b\Parasolid Files\A302262A.x_t", True)
    Call invDoc.SaveAs("\\a\b\c\A302262A.ipt", True)
    
    invApplication.Quit
    Set invApplication = Nothing
End Sub
All I get is Inventor giving me an error "Failed to open document" yet when I manually open Inventor > Open and choose this file there are no problems; the file is opened and there are no warnings or errors.
It appears it is a problem with using VBA.
Does anyone have any ideas?
Thanks

 

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

YuhanZhang
Autodesk
Autodesk

Is there more info from the error dialog? And on which Inventor version you see this problem?



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 3 of 4

dbrblg
Collaborator
Collaborator

Hi Rocky,

 

Unfortunately there is no more information, other than that.  

 

The problem is solved however.  It turns out Inventor will not allow the open method on a freshly opened inventor until an amount of time has elapsed.

 

If I put a 5 second delay between opening inventor and running the open method, everything works as it should.  

 

Perhaps in a future version, Inventor can have a 'ready' signal to check after opening in the API as I would imagine the 5 second time will be fine on my PC but not necessarily on others.

 

It is Inventor 2011

 

Kind regards

0 Likes
Message 4 of 4

YuhanZhang
Autodesk
Autodesk

Fine to hear that you have found the point. The Application.Ready should have been there and you can make use of it.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes