Author Topic: User Defined Variable in Excel VBA  (Read 9617 times)

0 Members and 1 Guest are viewing this topic.

mailmaverick

  • Bull Frog
  • Posts: 494
User Defined Variable in Excel VBA
« on: July 17, 2020, 08:16:52 PM »
Hi,

I have a variable "dist" in autocad having value equal to 30
(setq dist 30)

How to get this value in Excel VBA ?
I am able to get objDoc object but don't know how to read this value.

n.yuan

  • Bull Frog
  • Posts: 348
Re: User Defined Variable in Excel VBA
« Reply #1 on: July 20, 2020, 09:21:21 AM »
The said "variable" is only meaningful to the running Lisp routine. If you want other code. be it AutoCAD VBA, or external app (Excel, which communicates with AutoCAD via AutoCAD COM API), to know what the Lisp code has done, that value has to be accessible via a way that AutoCAD allows "outsider" (user, or other app) to know.

My guess is that before your Excel VBA code connects to AutoCAD, you have some Lisp code runs, which obtains certain value that you want to be used in Excel VBA code. The ideal solution would be write VBA code that does the same thing as the LISP code, so that the VBA code does not need to reply on the run of that LISP code being run first. The other often used approach is to let the Lisp code store the value in AutoCAD's "User Variable". In your case, since it is distance (Double type), you can use one of the "USERR1[2/3/4/5]". Then in VBA code, you can use AcadDocument.GetVaraible("USER1") to access its value.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18