Results 1 to 5 of 5

Thread: How to make AutoCAD instance only available to my application?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2013
    Posts
    25

    Question 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

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Jan 2013
    Posts
    25

    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.

  3. #3
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,531

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jan 2013
    Posts
    25

    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?

  5. #5
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    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
  •  



Click Here to Expand Forum to Full Width