Author Topic: How to control an external application, do something with it & return to AutoCAD  (Read 2220 times)

0 Members and 1 Guest are viewing this topic.

vegbruiser

  • Guest
Harking back to my previous post 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.

BlackBox

  • King Gator
  • Posts: 3770
To work with an instance of Excel.Application Object, explore Visual LISP's vlax-get-or-create-object 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!
"How we think determines what we do, and what we do determines what we get."

vegbruiser

  • Guest
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:

  • run a command in AutoCAD that collects a bunch of data (block count & group lengths).
  • Open Excel and populate a sheet with the data.
  • Allow the user to run an addin in Excel.
  • Wait for the user to click a "finish" button in Excel.
  • Populate an AutoCAD table with data from Excel and close/release the instance of Excel.
Is that a bit clearer?

dgorsman

  • Water Moccasin
  • Posts: 2437
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.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

LE3

  • Guest
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!

vegbruiser

  • Guest
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 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 and I'm done. :)