create inventor object in VB6

create inventor object in VB6

Anonymous
Not applicable
268 Views
4 Replies
Message 1 of 5

create inventor object in VB6

Anonymous
Not applicable
I want to use VB6 to create an invisible Inventor object with a preloaded assembly. I have a macro that runs over a webpage and having the assembly as well as inventor invisible and preloaded makes a huge speed difference. To do this, I wanted to create the inventor application object in VB6 and load the file like so:

-------------

On Error Resume Next
Set oInvApp = CreateObject("Inventor.Application")
If Err.Number <> 0 Then Exit Sub
Dim ThisDoc As Inventor.Document
oInvApp.Documents.Open "C:\test.iam", True

'Just a test to make sure it opened the documents
MsgBox oInvApp.Documents.Count

Set ThisDoc = Nothing
Set oInvApp = Nothing

-------------

This works great, but as soon as the file loads and the program exits, Inventor dissapears out of the task manager. I was under the impression that the application had started and should have stayed open until someone exited it.

Does anyone know how to keep it open? This would be a huge help to me. Note that I've also tried not setting the objects to nothing afterwords.
0 Likes
269 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
Hi
you have to set the visible property to true before your program exists and especially before you remove your reference to the Application-Object.

if it is invisible and there is no reference to the Application-Object it gets "destroyed".

insert
oInvApp.isible = True
before
Set ThisDoc = Nothing
Set oInvApp = Nothing

hth SVen
0 Likes
Message 3 of 5

Anonymous
Not applicable
Thanks, but I'm well aware of this. The point is that I don't want the application to be visible. It's going to be running on a webserver, generating assemblies automatically, and saving them as STEPs. Having Inventor be visible will just slow it down.
0 Likes
Message 4 of 5

Anonymous
Not applicable
I did some testing and the behavior of Inventor is to shut down if there
aren't any references to it. If it's visible, then it assumes the end-user
is using it and it will stay open. If it's not visible then it's dependent
on live references from an API application. When your program shuts down it
was releasing the references to the Inventor objects and Inventor saw that
no one is using it so it shut itself down. Even if you don't release your
references, when they go out of scope VB will do the release so the effect
is the same. I tried a couple of things that I thought might trick Inventor
but they didn't work.

The only workaround that I can suggest at this point is that just before
your application shuts down is that it makes Inventor visible. When your
application starts up again and connects to Inventor, the first thing it
would do is make it invisible so you save the time of updating the window.
Since it's on a web server I assume no one will even be able to see this
behavior.
--
Brian Ekins
Autodesk Inventor API

wrote in message news:5138786@discussion.autodesk.com...
Thanks, but I'm well aware of this. The point is that I don't want the
application to be visible. It's going to be running on a webserver,
generating assemblies automatically, and saving them as STEPs. Having
Inventor be visible will just slow it down.
0 Likes
Message 5 of 5

Anonymous
Not applicable
Thanks for the info. Maybe in a future release Autodesk can provide a way to keep it open. I've also found that when I have all of the assemblies invisible and I close one, 50% of the time the other ones seem to close with it.

I tired making inventor visible then invisible again, but I lost some speed by doing that. My workaround ended up to just keep the calling app open (then when other calling apps were opened, they ran asyncronously and posted data to the original one with sendmessage).

Hopefully I can get this web app that I'm writing up soon. Luckily, I convinced my company that 3d PartStream was a waste of cash because we'd have to convert everything to SolidWorks, so what I'm creating is my Inventor-based solution.
0 Likes