TheSwamp

Code Red => .NET => Topic started by: vegbruiser on February 16, 2012, 11:55:44 AM

Title: How to control an external application, do something with it & return to AutoCAD
Post by: vegbruiser on February 16, 2012, 11:55:44 AM
Harking back to my previous post (http://www.theswamp.org/index.php?topic=36105.0) on linking Excel to AutoCAD, I thought I'd ask if anyone has an example of how to (from within AutoCAD) open Excel, wait for the user to click a Ribbonbar button in Excel, and then return a table of data back to AutoCAD.

Failing that, does anyone know the correct terminology I should use to look for an answer myself?

Thanks,

Alex.
Title: Re: How to control an external application, do something with it & return to AutoCAD
Post by: BlackBox on February 16, 2012, 07:11:06 PM
To work with an instance of Excel.Application Object, explore Visual LISP's vlax-get-or-create-object (http://exchange.autodesk.com/autocad/enu/online-help/browse#WS1a9193826455f5ff1a32d8d10ebc6b7ccc-681e.htm) Method.

From there you can manipulate the Excel.Application Object as needed, set the Application Window Current, Open a file, populate cells with data, format cells, etc.

However, to monitor a random Button_Click Event once the user is interacting with the Ribbon is frankly above my limited .NET pay grade. Good luck!
Title: Re: How to control an external application, do something with it & return to AutoCAD
Post by: vegbruiser on February 22, 2012, 07:14:55 AM
I'm still struggling to find the correct terminology to describe what I want to do, so I thought I'd list the steps I need to take:

Is that a bit clearer?
Title: Re: How to control an external application, do something with it & return to AutoCAD
Post by: dgorsman on February 22, 2012, 10:21:41 AM
Above my pay grade as well.  Its very difficult to do the wait-and-see thing with other applications which can wait for a variety of user input.  My thinking is by the time you code that, you could have coded the auto-whatsit calculator into a non-Excel data processor running inside your DLL.
Title: Re: How to control an external application, do something with it & return to AutoCAD
Post by: LE3 on February 22, 2012, 02:45:42 PM
I don't know, have been out of the cad world for a year now, but i worked on some of the tools here:
http://www.cadsitetools.com/cadsite_reports.html

That might give you an idea or maybe it is closed of what you are trying to accomplish (and yes not an easy task et-al), give it a try!.

Good luck!
Title: Re: How to control an external application, do something with it & return to AutoCAD
Post by: vegbruiser on February 29, 2012, 10:26:17 AM
I'm pretty sure I've got a working implementation of what I wanted to achieve.

Using the attached source, the application gets netloaded into AutoCAD and registered for demandloading (props to Kean (http://through-the-interface.typepad.com/through_the_interface/2010/03/creating-demand-loading-entries-automatically-for-your-autocad-application-using-c-f-or-vbnet.html) for that)

then it's simply a case of typing "test" at the command prompt.

Excel will open and the Addin will display on the "TabAddIns" RibbonTab in the RibbonBar.

You then click "button1" and Excel returns control to AutoCAD.

What I need to do now is bolt on the tools created in this thread (http://www.theswamp.org/index.php?topic=31867.msg461447#msg461447) and I'm done. :)