-
Mar 8th, 2013, 03:50 PM
#1
Thread Starter
Junior Member
How to make AutoCAD instance only available to my application?
Hey all,
I've been working with integrating AutoCAD into my VB6 Projects. I imagine that my question is not specific to AutoCAD, but that just happens to be what I'm using.
So, when I start my program, I create an instance of AutoCAD that can be accessed throughout my entire code. When the program finished, it terminates this instance.
Now, while the program is running, if I start up AutoCAD manually by opening a drawing file, it chooses the instance my VB6 Project created and makes it visible.
When I start up AutoCAD manually by double-clicking the exe, then a second (and independent) instance is generated (this is the behavior I desire!).
So... my question is this:
Is there a way my VB6 Project can hold an instance of AutoCAD that NO OTHER application can access? In other words, make the instance private to my application only?
The reason I wish to do this is because when I do open a AutoCAD drawing manually, and then close it manually, it ends the instance my VB6 Project created! Not good!
This will always make the program crash since it is referencing this terminated instance of AutoCAD. I know there are ways to check if the instance is valid, then re-create if it's not, but this puts more delay on the program (rather than loading it once and keeping it). Doing this requires error checking for each time I need to start using AutoCAD again in my application.
I know that it's probably a good idea to error-check anyways, and that the user can still terminate this instance by going to Task Manager; however, if that happens I'd rather let the program crash (this application is only going to be used internally).
I appreciate all of your help!
God Bless,
-Nick
-
Mar 11th, 2013, 12:18 PM
#2
Thread Starter
Junior Member
Re: How to make AutoCAD instance only available to my application?
I probably should've mentioned this before, but even if you don't know exactly how to fix this, I still appreciate feedback/comments. If you guys know of anything that could be helpful towards finding the solution, please post!
I'd rather see some information on this rather than the thread going dead; that way, I'll know where to start looking.
-
Mar 11th, 2013, 01:37 PM
#3
Re: How to make AutoCAD instance only available to my application?
It partly depends on how you're starting your instance... it also depends on the application... if the application has been designed to be a single instance then that's all that's ever going to run and there's not much you can do about it.
-tg
-
Mar 11th, 2013, 03:43 PM
#4
Thread Starter
Junior Member
Re: How to make AutoCAD instance only available to my application?
Thanks for the reply techgnome,
Regarding the instancing of AutoCAD.... it's just like the instancing for Microsoft Excel:
Code:
Public acadApp As New AcadApplication
Public Sub Main()
Dim doc As AcadDocument
Set doc = acadApp.Documents.Open("C:\Drawing1.dwg")
End Sub
Also, I can confirm that AutoCAD allows multiple instances.
And... I found another page that discusses the same problem (just with Microsoft Excel instead):
Can I create an instance of Excel that can only be accessed by my VBA project?
-
Mar 11th, 2013, 05:09 PM
#5
Re: How to make AutoCAD instance only available to my application?
The only way i see doing this is have a timer constantly check for new autoCAD instance and close them just keep track of "your" handle and dont close that one.
Also, not sure if this could work but you could use set parent to put the instance of autoCAD in your program and use my first method to clise any kther instance opened
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|