TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Rustabout on January 26, 2020, 11:36:57 PM

Title: Is it possible to Write a new LISP routine with LISP?
Post by: Rustabout on January 26, 2020, 11:36:57 PM
I know that you can write to a text file. I never experimented with renaming the file with a different extension though. Has anyone ever tried this?
Title: Re: Is it possible to Write a new LISP routine with LISP?
Post by: HasanCAD on January 27, 2020, 07:51:21 AM
Give  this a try
http://www.theswamp.org/index.php?topic=46900.msg519247#msg519247
Title: Re: Is it possible to Write a new LISP routine with LISP?
Post by: JohnK on January 27, 2020, 07:51:36 AM
yes, I have and it was fun (but a very long time ago; sorry I don't have an example to share anymore). If your lisp file never has to change it's quite simple--just do as you say-. But if you need to rewrite the code based on differing condictions you may want to employ the preprocessor I wrote to save you time and effort. You can call that tool from AutoLisp.

Install version 1.7 and if you'd like you can replace the exe with the version found in the 2.0.2 archive.
https://www.theswamp.org/index.php?topic=37700.0
Title: Re: Is it possible to Write a new LISP routine with LISP?
Post by: Rustabout on January 27, 2020, 02:16:20 PM
Look's like I'm in business, thanks guys!!

My idea was to great a routine incorporating dialog boxes, that would "set-up" basic routines for inserting blocks... Basically the user would simply fill-out dialog box entries to create a custom routine to insert the block on a specific layer, and manipulate any custom properties that block might have (example: a stretch action).

I think I can actually do that! It's much easier to know it's possible before exploring it on my own and reaching a dead end.

Thanks again!
Title: Re: Is it possible to Write a new LISP routine with LISP?
Post by: It's Alive! on January 27, 2020, 11:15:47 PM
AI, Skynet can modify its own source code
Title: Re: Is it possible to Write a new LISP routine with LISP?
Post by: BIGAL on January 30, 2020, 03:02:22 AM
You can certainly get lisp to write a lisp the only thing though is once you do (load "newlisp") your current lisp is abandoned.

Have a look at my Multi getvals.lsp over at Cadtutor -> Downloads may save you some time writing individual dcls. Only requires 1 line of code to create and  run a dcl.
Title: Re: Is it possible to Write a new LISP routine with LISP?
Post by: Lee Mac on January 30, 2020, 08:13:37 AM
...the only thing though is once you do (load "newlisp") your current lisp is abandoned.

How so? The load expression will be evaluated like any other AutoLISP expression, and the program will then continue to evaluate any expressions which follow.
Title: Re: Is it possible to Write a new LISP routine with LISP?
Post by: BIGAL on January 31, 2020, 09:36:50 PM
Your right Lee should have explained more if the new lisp just runs say no defuns it will stop execution of the 1st lisp. More a daisy chain method rather than going sideways for a moment.

Code: [Select]
; BUTT.lsp
(defun but ()
(alert "but is ok now")
)

running code
 (if (not but)(Load "BUTT.lsp"))
(But)
next step in code

Code: [Select]
; BUTT2.lsp
(alert "but is not now")

running code
(Load "BUTT2.lsp")
execution stops at alert