Author Topic: Adding a function…  (Read 1143 times)

0 Members and 1 Guest are viewing this topic.

MeasureUp

  • Bull Frog
  • Posts: 462
Adding a function…
« 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.

hugha

  • Newt
  • Posts: 103
Re: Adding a function…
« Reply #1 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:
« Last Edit: April 21, 2016, 07:36:43 AM by hugha »

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Adding a function…
« Reply #2 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.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

MeasureUp

  • Bull Frog
  • Posts: 462
Re: Adding a function…
« Reply #3 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.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Adding a function…
« Reply #4 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
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

ur_naz

  • Newt
  • Posts: 68
  • Made in Ukraine
Re: Adding a function…
« Reply #5 on: April 27, 2016, 11:36:13 PM »
Take a look on autoload function