TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: MeasureUp on April 21, 2016, 12:05:39 AM

Title: Adding a function…
Post by: MeasureUp on April 21, 2016, 12:05:39 AM
Suppose I have several "vlx" files in my usb drive "J". I now would like to add a specified function (e.g. "ABC") when any of my commands is executed.

I don't want to rewrite my codes by adding (ABC) to the end of each my routine.
I prefer to write a separate lisp file and autoload it when AutoCAD starts.

Code: [Select]
(if (any of my commands is executed)
(load the specified function "ABC")
); end of if

Can it be done?
Your helps are much appreciated.
Title: Re: Adding a function…
Post by: hugha on April 21, 2016, 12:35:09 AM
Been a while, but perhaps ...


(if (any of my commands is executed)
(load strcat(the specified function "ABC"))
); end of if

Ok, I completely misread OP's intention. :nerdyembarassed:
Title: Re: Adding a function…
Post by: T.Willey on April 21, 2016, 01:19:46 AM
It depends what your function ABC has within it, but there is a lisp reactor.  Maybe you can use that, and if the name is something you recognize, then run your function afterwards.  It seems like there are examples of lisp reactors here.  Just search for vlr-lisp-reactor.
Title: Re: Adding a function…
Post by: MeasureUp on April 22, 2016, 02:03:30 AM
Thanks Tim.
I found a thread commented by Lee:
https://www.theswamp.org/index.php?topic=41760.msg468782#msg468782

Sorry, I know nothing about "reactor". Can you explain it for my case? Thanks.

BTW with my question the function which I would like to load can be simplified as
Code: [Select]
(prompt "\n\nTask has been completed.")(princ)I don't want to get you confused now.
Title: Re: Adding a function…
Post by: T.Willey on April 23, 2016, 08:14:10 AM
Reactors take a lot of time and understanding to explain, and I do not have the time right now and maybe not the knowledge to explain it well.  It has been a long time since I look into reactors.

Here is a file I wrote a long time ago that shows a Lisp reactor.  It is a counting reactor for Lisps called during a session of AutoCAD.  Hopefully it can help you.

Sorry.  Maybe someone with more skills with reactors can help.

Here is a link to the thread that the code was posted before.  Not a lot of explaining in it though.  I added the missing sub talked about in the thread link, so the file should work fine now.  Untested though.
http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-usage-tracking/td-p/1383527/highlight/true
Title: Re: Adding a function…
Post by: ur_naz on April 27, 2016, 11:36:13 PM
Take a look on autoload function