Use SendCommand() as lisp's 'command

Use SendCommand() as lisp's 'command

Anonymous
Not applicable
809 Views
8 Replies
Message 1 of 9

Use SendCommand() as lisp's 'command

Anonymous
Not applicable
Hi

How can I use VBA's SendCommand the same way I use lisp's 'command?

I want to be able to do something like:
SendCommand("circle")
SendCommand("2,3")
SendCommand("100")

And have it draw a circle. The problem is, when I try the second command, I get an exception with the HRESULT 0x80010001 (RPC_E_CALL_REJECTED)

I also can't just do a front-end and keep accumulating the strings until a "" because it won't work.

Also, how can I pass an acadpoint as a parameter to command?
For example:
Dim p1 as AcadPoint = ThisDrawing.AddPoint(new Double() {2, 3, 0})

SendCommand("circle")
SendCommand(p1) ' ???
SendCommand("100")

Thanks for the help

- Filipe Cabecinhas
0 Likes
810 Views
8 Replies
Replies (8)
Message 2 of 9

Anonymous
Not applicable
Hi

I forgot to mention why I'm using SendCommand().

I'm porting a huge lisp codebase to VB and would like to have it working with a minimum fuss. After that, we would clean it up.

Thanks for the help,

- Filipe Cabecinhas
0 Likes
Message 3 of 9

Anonymous
Not applicable
Hi Filipe,

It will take you longer and cost you far more to attempt to do this than it
will to do it properly in the first place.

Look at the concept of doing it in small quantities of code at a time.

Try copying the lisp code into the VBA Editor and some "search and replace"
items will be come obvious.

eg
replace "(defun" with "Sub"
replace "(If" with "If"

Work on Single Subs and Functions one at time till they are working.


--


Regards

Laurie Comerford


wrote in message news:5925445@discussion.autodesk.com...
Hi

I forgot to mention why I'm using SendCommand().

I'm porting a huge lisp codebase to VB and would like to have it working
with a minimum fuss. After that, we would clean it up.

Thanks for the help,

- Filipe Cabecinhas
0 Likes
Message 4 of 9

Anonymous
Not applicable
My advice would be to disregard the other really bad advice you're getting from Laurie, and consider making the jump to VB.NET.

With VB.NET, you can use the command line in the same way you do from LISP. Because of that, it also becomes much easier to port LISP applications to VB.NET.

You can find a counterpart to the LISP (command) function available here:

http://www.caddzone.com/CommandLine.vb

In VB.NET with the above code, you can do this:

CommandLine.Command( "._LINE", new Point3d(2,3,0), 100.0 )

And the result is exactly the same as this LISP:

(command "LINE" (list 2.0 3.0 0.0) 100.0)

With regards to .NET and VB.NET, there are some initial hurdles that you have to get past in learning the language differences and the .NET framework, but once you've done that, you will never regret it, and will never look back.

In fact, I'd be willing to wager that any 'pain' you experience learning VB.NET is nothing compared to the massive headaches you will have trying to port your command line-intensive LISP code to VBA.

Because there is no future for VBA, making major investments in it is not a wise strategy. Autodesk is going .NET completely, and VBA/ActiveX will only be maintained for compatibility with legacy applications and for verticals like Civil3D, whose product designers seem to lack the wisdom needed to see the disadvantages of a programming model that is rooted in obsolete ActiveX technology.

Oh BTW, on 64 bit platforms, VBA applications run 5-20X slower than they do on 32 bit platfoms.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

wrote in message news:5925445@discussion.autodesk.com...
Hi

I forgot to mention why I'm using SendCommand().

I'm porting a huge lisp codebase to VB and would like to have it working with a minimum fuss. After that, we would clean it up.

Thanks for the help,

- Filipe Cabecinhas
0 Likes
Message 5 of 9

Anonymous
Not applicable
Hi,

You may also care to read some of Tony's posts of the difficulty of using
.NET with AutoCAD before making your decision..

As always, deciding on the best route to take is more complex than simply
reading advice from here.

There is no doubt that .NET is seen by Autodesk as the way to go, but they
have done almost nothing to make it easy for you to do so and if you don't
have access to knowledge of .NET programming, then you may find the program
up and running in VBA months before you have sufficient skills to do it in
.NET.


--


Regards

Laurie Comerford
wrote in message news:5925445@discussion.autodesk.com...
Hi

I forgot to mention why I'm using SendCommand().

I'm porting a huge lisp codebase to VB and would like to have it working
with a minimum fuss. After that, we would clean it up.

Thanks for the help,

- Filipe Cabecinhas
0 Likes
Message 6 of 9

Anonymous
Not applicable
Hi Tony,

Dyslexic as always.

Could you read the question from the OP? He asked for advice specfic to
VBA.

--


Regards

Laurie Comerford


"Tony Tanzillo" wrote in message
news:5925526@discussion.autodesk.com...
My advice would be to disregard the other really bad advice you're getting
from Laurie, and consider making the jump to VB.NET.

With VB.NET, you can use the command line in the same way you do from LISP.
Because of that, it also becomes much easier to port LISP applications to
VB.NET.

You can find a counterpart to the LISP (command) function available here:

http://www.caddzone.com/CommandLine.vb

In VB.NET with the above code, you can do this:

CommandLine.Command( "._LINE", new Point3d(2,3,0), 100.0 )

And the result is exactly the same as this LISP:

(command "LINE" (list 2.0 3.0 0.0) 100.0)

With regards to .NET and VB.NET, there are some initial hurdles that you
have to get past in learning the language differences and the .NET
framework, but once you've done that, you will never regret it, and will
never look back.

In fact, I'd be willing to wager that any 'pain' you experience learning
VB.NET is nothing compared to the massive headaches you will have trying to
port your command line-intensive LISP code to VBA.

Because there is no future for VBA, making major investments in it is not a
wise strategy. Autodesk is going .NET completely, and VBA/ActiveX will only
be maintained for compatibility with legacy applications and for verticals
like Civil3D, whose product designers seem to lack the wisdom needed to see
the disadvantages of a programming model that is rooted in obsolete ActiveX
technology.

Oh BTW, on 64 bit platforms, VBA applications run 5-20X slower than they do
on 32 bit platfoms.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

wrote in message news:5925445@discussion.autodesk.com...
Hi

I forgot to mention why I'm using SendCommand().

I'm porting a huge lisp codebase to VB and would like to have it working
with a minimum fuss. After that, we would clean it up.

Thanks for the help,

- Filipe Cabecinhas
0 Likes
Message 7 of 9

Anonymous
Not applicable
"Laurie Comerford" wrote

>> There is no doubt that .NET is seen by Autodesk as the way to go, but they have done almost nothing to make it easy for you to do so <<

There is nothing Autodesk can do to compensate for any one person's basic lack of programming skills.

What you are mislabeling as Autodesk's failure, is really little more than your own personal lack of skills, and nothing more. No one reading this should assume that everyone who posts here also has the same problem you have.

.NET is a far more powerful programming model, and that power comes at a price (ease of use). Either you get off your duff and make the personal effort needed to learn to use the tools, or shut h*ll up.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm
0 Likes
Message 8 of 9

Anonymous
Not applicable
Laurie - I completely understand your malicious desire to discouarge others from going where you cannot go.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

"Laurie Comerford" wrote in message news:5925600@discussion.autodesk.com...
Hi Tony,

Dyslexic as always.

Could you read the question from the OP? He asked for advice specfic to
VBA.

--


Regards

Laurie Comerford


"Tony Tanzillo" wrote in message
news:5925526@discussion.autodesk.com...
My advice would be to disregard the other really bad advice you're getting
from Laurie, and consider making the jump to VB.NET.

With VB.NET, you can use the command line in the same way you do from LISP.
Because of that, it also becomes much easier to port LISP applications to
VB.NET.

You can find a counterpart to the LISP (command) function available here:

http://www.caddzone.com/CommandLine.vb

In VB.NET with the above code, you can do this:

CommandLine.Command( "._LINE", new Point3d(2,3,0), 100.0 )

And the result is exactly the same as this LISP:

(command "LINE" (list 2.0 3.0 0.0) 100.0)

With regards to .NET and VB.NET, there are some initial hurdles that you
have to get past in learning the language differences and the .NET
framework, but once you've done that, you will never regret it, and will
never look back.

In fact, I'd be willing to wager that any 'pain' you experience learning
VB.NET is nothing compared to the massive headaches you will have trying to
port your command line-intensive LISP code to VBA.

Because there is no future for VBA, making major investments in it is not a
wise strategy. Autodesk is going .NET completely, and VBA/ActiveX will only
be maintained for compatibility with legacy applications and for verticals
like Civil3D, whose product designers seem to lack the wisdom needed to see
the disadvantages of a programming model that is rooted in obsolete ActiveX
technology.

Oh BTW, on 64 bit platforms, VBA applications run 5-20X slower than they do
on 32 bit platfoms.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

wrote in message news:5925445@discussion.autodesk.com...
Hi

I forgot to mention why I'm using SendCommand().

I'm porting a huge lisp codebase to VB and would like to have it working
with a minimum fuss. After that, we would clean it up.

Thanks for the help,

- Filipe Cabecinhas
0 Likes
Message 9 of 9

Anonymous
Not applicable
>>You may also care to read some of Tony's posts of the difficulty of using
.NET with AutoCAD before making your decision..

If you use the API methods it is. In this case of just pushing commands to the commandline it would be easier than VBA.
0 Likes