VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Run lisp command in autocad from VBA

9 REPLIES 9
Reply
Message 1 of 10
anishkt
8250 Views, 9 Replies

Run lisp command in autocad from VBA

I have mada a new command using autolisp. To make the program attractive, I want to run it using VBA. VBA just needs to pass the command to the acad command line to execute it. Is it possible. If yes could you please tell me how to do it.
Anish
9 REPLIES 9
Message 2 of 10
Anonymous
in reply to: anishkt


if you're writing lisp no need for
vba.

just write a defun C:CommandName()

to call the lisp

 

on the contrary to use a vba to call a lisp is
completely backward since you have to write a lisp to call the dvb via
vla-runmacro or vl-vbarun

hth

mark


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
I
have mada a new command using autolisp. To make the program attractive, I want
to run it using VBA. VBA just needs to pass the command to the acad command
line to execute it. Is it possible. If yes could you please tell me how to do
it. Anish
Message 3 of 10
Anonymous
in reply to: anishkt

Hi just an exemple !
Add in acaddoc.lsp

(defun c:vbTPSHN2 () ; Affiche "A propos"
(vl-load-com)
(setvar "cmdecho" 0)
(vl-vbarun "Acad.dvb!zz_Aide_TPS.HelpTPSNum2")
(setvar "cmdecho" 1)
)
Daniel OLIVES
Message 4 of 10
Anonymous
in reply to: anishkt

>>you have to write a lisp to call the dvb via vla-runmacro or vl-vbarun

Thats the most common method, for sure. But you can also use the StartUp Folder, Acad.dvb, or Acad.rx to do much the same. Also, starting your DVB from a lisp file lowers the priority in when it's loaded. Using the alternate methods above gets your .dvb up and running before other apps can get in and cause problems.
Message 5 of 10
Anonymous
in reply to: anishkt

Use the "sendcommand" option !
Message 6 of 10
Anonymous
in reply to: anishkt


I'm not familiar with how to create a command you
can enter at the command line to run a sub in a dvb without either a c: defun or
the horrifying menu trail of tools/macro/macros/scroll list of hundreds of subs
to find the one you want 

 

how do you create a vba command callable at
the command line without lisp by using acad.dvb, startup folder or
acad.rx?

 

thanks

mark


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
>>you
have to write a lisp to call the dvb via vla-runmacro or vl-vbarun Thats the
most common method, for sure. But you can also use the StartUp Folder,
Acad.dvb, or Acad.rx to do much the same. Also, starting your DVB from a lisp
file lowers the priority in when it's loaded. Using the alternate methods
above gets your .dvb up and running before other apps can get in and cause
problems.
Message 7 of 10
Anonymous
in reply to: anishkt

Hi,

Sub LoadAndRunLISP()
ThisDrawing.SendCommand "(load ""C:/Program Files/AutoCAD 2004/Template/ACAD.lsp"") "
ThisDrawing.SendCommand "Di "
End Sub

this is sample code which loads acad.lsp and run command Di from VBA.In similar way we can load and run lsp codes in vba
U can try this.Hope this helps u.

Cheers
Divya
Message 8 of 10
ramd401
in reply to: anishkt

Hi, iam trying to load a lisp from vba but i receave the error in the following image

Error loading vba.JPG

 

Iam using the following code

Sub LoadAndRunLISP()
ThisDrawing.SendCommand "(load""C:\RD\RD 2017\Cartografia\Ricardo\LSP_Ficheiros\Datum_Projeccao.lsp"")" 
ThisDrawing.SendCommand "PRINTCOORDSYS"
End Sub

 

Am i doing something wrong?

RD, Regards

 

Message 9 of 10
Alfred.NESWADBA
in reply to: ramd401

Hi,

 

please don't crosspost, that creates just double work for all of us (and you too to watch and answer all the different threads).

Please continue here >>>click<<<.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 10 of 10
ramd401
in reply to: Alfred.NESWADBA

Ok, @Alfred.NESWADBA

 

RD

Regards

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Customer Advisory Groups


Autodesk Design & Make Report