Did you know that VBA is being removed from AutoCAD ?
Registered forum members do not see this ad.
I try to write a program in VBA, but I see now that I could use some routines I wrote previously in AutoLisp.
First question: Is there a way to start a Lisp routine from VBA?
Second: Is there a way to start a Lisp from VBA and after the Lisp finishes, to return to VBA?
Third: How to start a Lisp from VBA and the lisp returns a real number in VBA that is used in calculations.
Or maybe I should rewrite all the Lisp code to have everything in VBA?
It's nice to be nice, but sometimes is nicer to be evil!.
![]()
Tip: Please do not PM or email me with CAD questions - use the forums, you'll get an answer sooner.
Did you know that VBA is being removed from AutoCAD ?
Perfection is not optional.
another Swamper
That is not a problem for me! I still use AutoCAD 2006 and from what I can see, "they" will not upgrade us during this life time. We use Catia now and AutoCAD is kept just for maintaining the old projects. I write programs just for my own pleasure -and to help myself and my colleagues in the daily routines.
Thank you for answering me!
It's nice to be nice, but sometimes is nicer to be evil!.
![]()
Tip: Please do not PM or email me with CAD questions - use the forums, you'll get an answer sooner.
Can anybody help me with this?
It's nice to be nice, but sometimes is nicer to be evil!.
![]()
Tip: Please do not PM or email me with CAD questions - use the forums, you'll get an answer sooner.
To call an AutoLISP routine in VBA will have to use the SendCommand statement (don’t forget to add a final space = <ENTER>):
Code:ThisDrawing.SendCommand "(load " & chr(34) & "MyLispFile" & chr(34) & ")(MyRoutine) "
Unfortunately there is no way (or at least I wasn’t able to find one) to see from VBA when the AutoLISP interpreter is done, so the VBA code is not waiting for that processing to get done.
I was tempted in the past to use your proposed approach but finally got to translate my AutoLISP to VBA.
Regards,
The first solution to communicate between AutoLISP and VBA is to use the USER*1-5 system variables:
Code:(setvar "USERS1" "Hello World!") thisDrawing.GetVariable "USERS1"
Second, may use a temporarily file to communicate between languages.
Third, may check the solution proposed here.
Regards,
Many thanks msasu!
I will try it these days. The Userr1 sounds good to me. Also I think to clear the Users1, start the lisp routine and wait in a loop until Users1 changes. After that the vba code may continue to run.
Thanks again!
It's nice to be nice, but sometimes is nicer to be evil!.
![]()
Tip: Please do not PM or email me with CAD questions - use the forums, you'll get an answer sooner.
Since just found that this may be interesting for other too, I want to confirm that the above proposed validation solution works.
Regards,
Mircea
AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3
Registered forum members do not see this ad.
A project I'm working on starts out with VBA and then launches AutoCAD and runs a LISP program. The easiest way I have found to get data between the two languages is to use temporary text files. I use them profusely and the process works well.
It's deja vu, all over again.
Bookmarks