Creating a Custom Command in VB

Creating a Custom Command in VB

Anonymous
Not applicable
352 Views
6 Replies
Message 1 of 7

Creating a Custom Command in VB

Anonymous
Not applicable
I was wondering if there is a way to create a AutoCAD command in Visual Basic. My command is currently written in LISP, but I would like to rewrite in VB.

Thanks,

Freeman
0 Likes
353 Views
6 Replies
Replies (6)
Message 2 of 7

Ed__Jobe
Mentor
Mentor
A straight answer to your question would be: As far as acad commands goes, you can pretty much do the same thing in both languages. Of course there are some things you can do in vba that can't be done in lisp and vice versa. -Ed

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 3 of 7

Anonymous
Not applicable
If you can create a command using Visual Basic, How would I go about decalaring the command?
0 Likes
Message 4 of 7

Anonymous
Not applicable
You can't actually create commands in VBA like you can in LISP or ObjectARX.
With VBA you are writing macros which can be run via the command line, a
lisp routine, another macro etc... A macro is nothing more than a public
procedure with no arguments.

Public Sub TryThis()
Msgbox "Hello"
End Sub

You could run this from autocad in several ways, assuming the macro is
loaded you could type -vbarun (enter) trythis (enter) and it will run. You
can call other private procedures from your macro, but you will only be able
to run public procedures with no arguments from autocad.

Regards,
Jacob Dinardi

"Freeman" wrote in message
news:f0d2c8c.1@WebX.maYIadrTaRb...
> If you can create a command using Visual Basic, How would I go about
decalaring the command?
>
0 Likes
Message 5 of 7

Anonymous
Not applicable
You can't.  VBA procedures are macros in
AutoCAD and must be invoked as such.

This can, however, be simulated with a LISP
function in your Acad.lsp that would invoke the

VB code.

 

Brian D.

 


style="BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px">
If
you can create a command using Visual Basic, How would I go about decalaring
the command?
0 Likes
Message 6 of 7

Ed__Jobe
Mentor
Mentor
There might be some confusion as to what you mean by "command". What Jacob and Brian are referring to is the fact that if I write a macro called MyMacro, I can't just type it at the command line and expect it to run the same as if you defined a lisp function as (defun c:MyLisp ()). But if you're talking about what's inside the lisp, what it does, then, to convert, you just need to learn the syntax for vba. -Ed

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 7 of 7

Anonymous
Not applicable
AutoCAD commands cannot be defined in VBA, but you can
define a LISP command function that calls a VBA macro,
which gives you the same effect:

(defun C:MYCOMMAND ()
(vl-vbarun "MyMacro")
(princ)
)

If you would like to define real AutoCAD commands in VBA,
which enjoy a number of advantages over the above method,
then visit www.caddzone.com/acadx/acadx15.htm, and have a
look at the AcadXEditorCommand class. This class allows
you to define real AutoCAD commands in VBA, and offers
all of the same options available to ObjectARX commands.

"Ed_Jobe" wrote in message news:f0d2c8c.0@WebX.maYIadrTaRb...
> A straight answer to your question would be: As far as acad commands goes,
you can pretty much do the same thing in both languages. Of course there are
some things you can do in vba that can't be done in lisp and vice versa. -Ed
>
0 Likes