• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    .NET

    Reply
    Valued Mentor
    Mike.Wohletz
    Posts: 351
    Registered: ‎07-29-2008

    Re: Question: Using AutoCAD 2012 through an external EXE

    03-21-2012 07:00 AM in reply to: vbNinja

    Just curious if this is currently the only version of AutoCAD installed on this machine? If so has it ever had any other version installed on it?

     

    Please use plain text.
    Contributor
    Posts: 21
    Registered: ‎03-18-2012

    Re: Question: Using AutoCAD 2012 through an external EXE

    03-21-2012 07:14 AM in reply to: Mike.Wohletz

    Hi

    No, this the only version that I have ever installed on this machine.

    Please use plain text.
    *Expert Elite*
    chiefbraincloud
    Posts: 736
    Registered: ‎02-13-2008

    Re: Question: Using AutoCAD 2012 through an external EXE

    03-21-2012 01:13 PM in reply to: vbNinja

    I'm not sure.  Is it possible that the invisible AutoCAD session is trying to get user input, like asking the user to select the template file for the new drawing or something?

     

    Would it be possible for you to attach the smallest version of your code that still has the error so that I can try it here?

    Dave O.                                                                 Sig-Logos32.png
    Please use plain text.
    Contributor
    Posts: 21
    Registered: ‎03-18-2012

    Re: Question: Using AutoCAD 2012 through an external EXE

    03-21-2012 01:40 PM in reply to: chiefbraincloud

    Hi

    Actually I don't think it does, anyway I attached the code you asked for, the exception occures at line 63.

    Thanks

    Please use plain text.
    Valued Mentor
    Mike.Wohletz
    Posts: 351
    Registered: ‎07-29-2008

    Re: Question: Using AutoCAD 2012 through an external EXE

    03-21-2012 02:26 PM in reply to: vbNinja

    It is working every time for me, the only thing that I did see that I would change is cleaning up after accessing the Acad Object. I added this to the end of what you have. 

     

      Finally
                    Try
                        acApp.Application.Quit()
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(acApp)
                        GC.Collect()
                        GC.WaitForPendingFinalizers()
                    Catch ex2 As Exception
                        MsgBox(ex2.Message)
                    End Try

     Please note that if this was going to run several times a minute I would not call the garbage collector on it every time. 

     

    Please use plain text.
    Contributor
    Posts: 21
    Registered: ‎03-18-2012

    Re: Question: Using AutoCAD 2012 through an external EXE

    03-21-2012 11:09 PM in reply to: Mike.Wohletz

    Hi

    I don't know what to do. although the sleep function somehow solved this problem too, but I am convinced that this solution is not the best way handle this problem.

     

    Thank you all for your support.

    Please use plain text.
    Contributor
    Posts: 21
    Registered: ‎03-18-2012

    Re: Question: Using AutoCAD 2012 through an external EXE

    03-22-2012 02:01 AM in reply to: vbNinja

    Hi

    I want to provide some information about my system that my be useful.

    I'm Running:

    Windows 7 Home Premium (64-bit edition)

    Microsoft Visual Studio 2010 Ultimate

    AutoCAD 2012 Structural Detailing (64-bit version)

    and I have AutoCAD VBA Enabler installed too

     

    can these information help?

    Please use plain text.
    *Expert Elite*
    chiefbraincloud
    Posts: 736
    Registered: ‎02-13-2008

    Re: Question: Using AutoCAD 2012 through an external EXE

    03-22-2012 12:58 PM in reply to: vbNinja

    Well, I am able to run your code (with my message filter code) without incident.

     

    I am developing on WinXP 32 bit, with AutoCAD 2012, Visual Studio 2010 Professional.

     

    I also built the program (with "Any CPU" as the Target platform) and ran it on a Windows 7 Professional 64 bit, with AutoCAD 2012 64 bit.

     

    Neither my dev machine nor the users machine has the VBA enabler installed, but I can't imagine that being the problem.

     

    Might I suggest you try what I did and see what happens.  To run your code, I had to create a form and stick a button on it, but then I added a ListBox control, and added a line to the ListBox in each of the message filter functions, and as status updates as the code went through your process.  I have attached my modified version.  Try adding a ListBox to your form and running this new code, to see if you get any messages in the ListBox.

    Dave O.                                                                 Sig-Logos32.png
    Please use plain text.
    Contributor
    Posts: 21
    Registered: ‎03-18-2012

    Re: Question: Using AutoCAD 2012 through an external EXE

    03-22-2012 02:12 PM in reply to: chiefbraincloud

    Hi

    Actually your code worked without any error, here is a summarized version of it's output (I replaced the listbox with a textbox in order to be able to copy from it):


    Pending: (336 times)
    AutoCAD Started:18.2s (LMS Tech)
    Pending: (2 times)
    Retry
    Pending: (48 times)
    Circle Drawn
    Pending: (3 times)
    Line Drawn
    Pending: (2 times)
    Doc Closed
    Pending: (5 times)
    Cad Closed

     

    I tested it repeatedly and it worked every time, that is weird because your code is not different from my code.

    I can't concentrate right now, I will test your code thoroughly tomorrow and I'll post any problem that might occur.


    Thank you very much


     

    Please use plain text.