Author Topic: VBA or LSP?  (Read 7508 times)

0 Members and 1 Guest are viewing this topic.

daron

  • Guest
VBA or LSP?
« Reply #15 on: February 13, 2004, 09:41:03 AM »
Yup. It does.

TR

  • Guest
VBA or LSP?
« Reply #16 on: February 17, 2004, 07:01:46 PM »
Quote from: Keith
In fact, many lisp programs can be written in just a few lines of code, while the same thing in VLisp or VBA requires up to 4 times the amount of coding.

For example..
Draw a line from 0,0,0 to 0,12,0 in lisp
Code: [Select]

(defun C:LINE12()
 (command "_.line" "0,0,0" "0,12,0" "")
)


Draw the same line in VBA
Code: [Select]

Sub line12()
 Dim stpnt(2) As Double
 Dim endpnt(2) As Double
 stpnt(0) = 0#: stpnt(1) = 0#: stpnt(2) = 0#
 endpnt(0) = 0#: endpnt(1) = 12#: endpnt(2) = 0#
 ThisDrawing.ModelSpace.AddLine stpnt, endpnt
End Sub


Now there are 7 lines of code compared to 3...
notwithstanding, you ALSO must either select the VBA command from the macro window or type:
Command: -vbarun
Macro name: ThisDrawing.line12

While in the lisp version you type:
Command: line12


Sorry, but that's not correct. Your lisp code could be duplicated in VBA with exactly three lines. If you're doing something simple in VBA (like drawing a single line with constant values) there isn't a need to use variables.
Code: [Select]

Public Sub line12()
  Thisdrawing.Utility.SendCommand("line 0,0,0 0,12,0 ")
End Sub


And you could use simple lisp to add the VBA program as a command. That's pretty much all i use lisp for.
Code: [Select]

(defun C:LINE12()
 (command "-vbarun" "c:/pathtodvb/filename.dvb!modulename.line12")
)

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
VBA or LSP?
« Reply #17 on: February 18, 2004, 10:48:44 PM »
Quote from: Tim Riley
Sorry, but that's not correct. Your lisp code could be duplicated in VBA with exactly three lines. If you're doing something simple in VBA (like drawing a single line with constant values) there isn't a need to use variables.
Code: [Select]

Public Sub line12()
  Thisdrawing.Utility.SendCommand("line 0,0,0 0,12,0 ")
End Sub



I suppose you are correct, but alas, I was refering to the ActiveX methods as opposed to a command sent to the AutoCAD command line. Also SendCommand is not available in R14 VBA,  plus you always get that ugly command line echoing....bleeaaccchhhh

Quote from: Tim Riley
And you could use simple lisp to add the VBA program as a command. That's pretty much all i use lisp for.
Code: [Select]

(defun C:LINE12()
 (command "-vbarun" "c:/pathtodvb/filename.dvb!modulename.line12")
)


You absolutely can and I regularly do where required, but here again, I was refering to the strictly ActiveX VBA comparison to Lisp.

This was intended to be a simple program example not a full fledged code compaction example. If you look at most code there are many ways that you can shorten the length of the code, but most do not because of a lack of understanding of the programming language.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

SMadsen

  • Guest
VBA or LSP?
« Reply #18 on: February 19, 2004, 06:02:36 AM »
I always used to say, what good is a language that needs another language to run it? I know that is not exactly true, either, but it does turn out that many people are using lisp to run their macro's (man, alone the words 'macro' and 'module' send shivers down my spine (that's a personal grudge/mental block, though)).

I'll agree with Tim that it was a poor example - both languages use the command pipeline without much difference. They are both talking to the same server.

But the only thing that would keep me from translating a survey file of points to a bunch of lines with a simple expression like (defun line (p1 p2) (entmake (list '(0 . "LINE")(cons 10 p1)(cons 11 p2)))) - as opposed to the "split-points-into-arrays-and-go-through-several-objects-type-of-vba-thing" - would be if AutoLISP were non-existent.
Heck, I could import a 5 Mb survey file at the command line with a few parantheses if I wanted. The guy who proposed to bring XLISP into AutoCAD was a brilliant guy in my eyes :)