TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: ML on March 05, 2007, 10:49:16 AM

Title: Coverting LISP Code to Visual Lisp
Post by: ML on March 05, 2007, 10:49:16 AM

Does anyone happen to know how to cleanly and simply convert LISP routines into Visual LISP without re wriiting all the code?
Is there a clean coversion method?

Also, it would be great if I could convert LISP to VBA but I don't think that is possible; may be someone can proove me wrong?

Thank you

Mark
Title: Re: Coverting LISP Code to Visual Lisp
Post by: Tramber on March 05, 2007, 12:20:32 PM
There is no more convertion tool between Kant philosophy and Pascals than between Autolisp and Vlisp.  :roll:

You need to know them both in order to re-write a code.
Unless you use ENT... functions, Autolisp sends commands to AutoCAD while Vlisp transforms entities through their properties.
The grammar is not the same.
Title: Re: Coverting LISP Code to Visual Lisp
Post by: JohnK on March 05, 2007, 12:53:35 PM
*click*
I found this one in my doc's. Although its a conversion from lisp -> c it might help.
Code: [Select]
(defun convert2C (/ fname nfile fn nf char)
  (cond ((setq fname (getfiled "Convert file" "" "lsp" 0))
         (setq nfile (strcat (vl-filename-directory fname)
                             "\\"
                             (vl-filename-base fname)
                             ".cpp"))
         (cond ((and (setq nf (open nfile "w"))
                     (setq fn (open fname "r"))
                )
                (while (setq char (read-char fn))
                  (cond ((= char 10)
                         (princ (chr char) nf)
                        )
                        (T (princ "C" nf))
                  )
                )
                (princ (strcat "\nNew file: " nfile))
                (close nf)
                (close fn)
               ))
        )
  )
  (princ)
)

*Se8en: sits back to watch the show*
Title: Re: Coverting LISP Code to Visual Lisp
Post by: ML on March 05, 2007, 12:54:06 PM
Thanks man; well it was worth a try  :-)
Title: Re: Coverting LISP Code to Visual Lisp
Post by: ML on March 05, 2007, 12:55:20 PM

Thanks Seven

I will take a look

Mark   :?
Title: Re: Coverting LISP Code to Visual Lisp
Post by: Kerry on March 05, 2007, 03:55:52 PM

........ how to cleanly and simply convert LISP routines into Visual LISP without re wriiting all the code?
Is there a clean coversion method?


Mark, what do you see that needs converting ?
Title: Re: Coverting LISP Code to Visual Lisp
Post by: Kerry on March 05, 2007, 05:09:09 PM
Just to clarify something ..

Do you mean convert AutoLisp  or one of the mainline Lisp dialects ?? 

You do know that Autolisp code written before VisualLisp inception will still run in VisualLisp ? yes ?
Title: Re: Coverting LISP Code to Visual Lisp
Post by: daron on March 05, 2007, 05:22:34 PM
Mark, there isn't too much to converting from one language to another and as Kerry is inquiring, if the code works, there's no need to convert from autolisp to visualisp. In many cases we've run test earlier on in the beginnings of this forum where we found that some of the autolisp functions worked better than their newer counterparts.

I get the impression that you are still of the mindset that lisp is nothing more than a scripting language and doesn't even have an if/then/else function. Well, if it ever didn't have it, it has had it for a long time.
Title: Re: Coverting LISP Code to Visual Lisp
Post by: ML on March 05, 2007, 10:50:37 PM
Hey Kerry

I didn't know that, that is interesting. Actually I prefer program in VBA because it is basically what got me into programming and I saw the obvious benefits of VBA over LISP, however, it is also obvious to me that there seems to be so much more coding to necessary in VBA to get the same results you would get from LISP. Having said that, my boss has done amazing things with LISP, thing I never knew were possible with LISP but I just thought it would be cool if we could modernize his routines a bit by using VLISP.

I am not sure what I need to do to run an asci file LISP routine in VLISP but may be you could give me a brief explanation? I would really appreciate it

Mark
Title: Re: Coverting LISP Code to Visual Lisp
Post by: Kerry on March 05, 2007, 11:12:25 PM
...  saw the obvious benefits of VBA over LISP....


Really ?



... I am not sure what I need to do to run an asci file LISP routine in VLISP but may be you could give me a brief explanation? I would really appreciate it



Type APPLOAD at the command line.


Title: Re: Coverting LISP Code to Visual Lisp
Post by: ML on March 06, 2007, 08:14:34 PM


Kerry

You sound surprised about VBA    :lol:
They both serve a valuble purpose however VBA is built into all Microsoft products which is major benefit right there. I don't know very much about LISP but can you get ACAD to work with Excel using LISP? Also can you access type libraries of other programs using LISP?

Mark
Title: Re: Coverting LISP Code to Visual Lisp
Post by: Kerry on March 06, 2007, 08:25:54 PM
don't get into a pissing contest you can't win.

did you get the lisp loaded ?
Title: Re: Coverting LISP Code to Visual Lisp
Post by: ML on March 06, 2007, 08:32:11 PM

Yeah you're right; who really cares. As long as the results are the same.
No I didn't try it yet but my boss said you can run you can copy an older LISP routine into VLISP no problem.
May be I will try it tomorrow. The extent of my LISP usag is maybe a few commandsin a menu macro; that is a definite benefit with LISP.
Title: Re: Coverting LISP Code to Visual Lisp
Post by: Jeff_M on March 06, 2007, 08:43:10 PM
I don't know very much about LISP but can you get ACAD to work with Excel using LISP? Also can you access type libraries of other programs using LISP?
No, you can't use lisp from Excel....but you CAN use lisp to work within Excel FROM Acad.

Yes, you can access most any ActiveX library wth lisp. I have lisp routines I wrote back in AcadR9 that I still use today in R2007.
Title: Re: Coverting LISP Code to Visual Lisp
Post by: JohnK on March 06, 2007, 08:52:23 PM
VisualLisp has an IDE (Just like VBA has an IDE) Its called the VLIDE. I think that is what he means; You cant ``copy an older LISP routine into VLISP'' (That just doesn't make sense.) but you can copy--open--a lisp in the VLIDE (which isnt ``VLISP'').

Dont worry, we will have you Lisp-ing soon enough. (We can get the terms down later).
Title: Re: Coverting LISP Code to Visual Lisp
Post by: Kerry on March 16, 2007, 05:28:09 PM
*bump*
How'd you go ??
Title: Re: Coverting LISP Code to Visual Lisp
Post by: boesiii on March 21, 2007, 09:38:46 PM
Can someone explain the difference between autolisp and vlisp.  I thought they were both the same.
Title: Re: Coverting LISP Code to Visual Lisp
Post by: Keith™ on March 21, 2007, 10:22:38 PM
AutoLISP is the AutoCAD incarnation of the lisp language developed as an intelligence language for robotics. It has been around for as long as I can remember.. I have been using AutoCAD since R10 ...

Vlisp aka Visual Lisp, is a recent addition to the lisp language structure for AutoCAD. Visual lisp has the added advantage of being able to include the type libraries of other programs and being able to interact seamlessly with programs that have type libraries. The Vlisp commands you will find hidden in AutoCAD (since R2000) are essentially the VBA commands exposed to the lisp environment, plus a few extras for good measure. Programmers often refer to the interfaces as ActiveX or COM. The neat thing is that just about anything you can code in VBA, you can code in Vlisp and operate on the programming using concepts such as objects, properties and methods.

For programming that does not support VBA, you may still be able to interact with them by importing functions exposed in their dlls. This can be a very tricky proposition, but it works beautifully once you understand the structure of the objects, methods, and properties.

I hope this gives you a little insight into the differences and if we can help, feel free to ask.
Title: Re: Coverting LISP Code to Visual Lisp
Post by: Kerry on March 22, 2007, 05:55:09 AM
............. The Vlisp commands you will find hidden in AutoCAD (since R2000) are essentially the VBA commands exposed to the lisp environment, plus a few extras for good measure.

.. actually, not VBA commands ..

VisualLisp has access to the methods properties and events exposed from the COM model through the ActiveX Automation interface, as does VB and VBA.
Title: Re: Coverting LISP Code to Visual Lisp
Post by: Kerry on March 22, 2007, 05:58:12 AM
This picccy may help ...

Title: Re: Coverting LISP Code to Visual Lisp
Post by: Keith™ on March 22, 2007, 08:14:52 AM
............. The Vlisp commands you will find hidden in AutoCAD (since R2000) are essentially the VBA commands exposed to the lisp environment, plus a few extras for good measure.

.. actually, not VBA commands ..

VisualLisp has access to the methods properties and events exposed from the COM model through the ActiveX Automation interface, as does VB and VBA.
I prefered not to obfuscate. It may be easier for the virtual noob to understand that the vlisp commands are "essentially" the same as VBA commands, except they are exposed to lisp than to tell them that some as of yet undiscovered (to them) COM interface is the same in both instances. I know that when I first started learning vlisp, I had the hardest time understanding it until I understood the correlation between VBA and VLisp (i.e. the COM interface exposed to each environment).

Just trying to be helpul ...
Title: Re: Coverting LISP Code to Visual Lisp
Post by: Kerry on March 22, 2007, 10:08:04 PM
... I prefered not to obfuscate. .... 

.. and I do ?
:lmao:


Title: Re: Coverting LISP Code to Visual Lisp
Post by: Keith™ on March 23, 2007, 08:10:48 AM
... I prefered not to obfuscate. .... 

.. and I do ?
:lmao:



evidently
Title: Re: Coverting LISP Code to Visual Lisp
Post by: Keith™ on March 23, 2007, 09:14:24 AM
ob·fus·cate      [ob-fuh-skeyt, ob-fuhs-keyt]
–verb (used with object), -cat·ed, -cat·ing.
1. to confuse, bewilder, or stupefy. 
2. to make obscure or unclear: to obfuscate a problem with extraneous information. 
3. to darken.
Title: Re: Coverting LISP Code to Visual Lisp
Post by: Kerry on March 23, 2007, 10:11:22 AM
Keith I understand what obfuscate means.

Your post will leave anyone who reads it with the impression that VisualLisp functions are based on VB or are VB command wrapped to make them accessable.

This is blatently incorrect, and the situation that you defend your post by assuming that the original poster is incapable of understanding the facts, and then attempting to ridicule me leaves me amazed.
Title: Re: Coverting LISP Code to Visual Lisp
Post by: Keith™ on March 23, 2007, 10:25:02 AM
Keith I understand what obfuscate means.

Your post will leave anyone who reads it with the impression that VisualLisp functions are based on VB or are VB command wrapped to make them accessable.

This is blatently incorrect, and the situation that you defend your post by assuming that the original poster is incapable of understanding the facts, and then attempting to ridicule me leaves me amazed.

I fail to see where I have ridiculed you or posted blatent incorrect information. I have already stated that the information you posted was correct and that I posted the information I did, in the way I did, so as to not confuse the situation.
Yes, perhaps I did assume that the poster would not understand the COM/ActiveX Automation .. and likely they don't and it only served to create more questions than it resolved .. I didn't state they were the same thing .. I meant that they operated in basically the same way .. i.e. things you can do in VBA (modify properties and invoke methods), you can do in VLisp as well. The reader is likely to understand that a whole lot easier. It was not meant as a commentary on how the programming language is implemented.
Title: Re: Coverting LISP Code to Visual Lisp
Post by: Kerry on March 23, 2007, 10:29:49 AM
So your assertion that I was attempting to obfuscate the situation was another of your belittling jokes. ?
Title: Re: Coverting LISP Code to Visual Lisp
Post by: Keith™ on March 23, 2007, 10:38:54 AM
So your assertion that I was attempting to obfuscate the situation was another of your belittling jokes. ?
Sorry .. I don't see it. Maybe your post prior to that was meant as a belittling joke .. I dunno .. Like I said .. I don't see it ..