Jump to content

pinpointing lisp routine


masterfal

Recommended Posts

Hi,

 

Does anyone know if its possible to pinpoint where a lisp routine is being run from? I've got hundreds of lisp routines set up, majority are called up from 1 lsp file but i have a bunch that run from separate files. My issue is every know and then i run a lisp command i want to change but i can't work out where its being referenced from. I usually just end up setting up a new command but it would be much better if i could just edit the main routine. Possible or not really?

 

Link to comment
Share on other sites

I don't think you can do that.  I hope I'm wrong, I'd like to know.

 

Okay, one thing you can do if you have the time, is start every function by saying who they are and where they're saved.

 

(defun rad2deg (rad)
  (princ "\nfunction rad2deg - mathfunctions.lsp")
  ;; 
  (/  (* rad 180.0) pi) 
)

 

Edit:

Now that I think about it... You could write a lisp function that writes this extra line of code to all other lisp files.  But this is probably not a good idea

 

More edit: don't use princ.  Make a custom funtion that you can turn on and off.

Edited by Emmanuel Delay
Link to comment
Share on other sites

All your lisps should be in one place/folder. are you asking to find the specific file that has the command?

 

quick and easy open them all into notepad++ and run a search across all documents.

image.png.88663313e1673273cf34808731943513.png

 

2 hours ago, masterfal said:

My issue is every know and then i run a lisp command i want to change but i can't work out where its being referenced from. I usually just end up setting up a new command but it would be much better if i could just edit the main routine.

 

I would take the time to clean up your commands and get everything in order. to cut down on redundancy and improve performance. and over all make things simpler.

Link to comment
Share on other sites

Like others if you know command then windows can help, you run command mode, change to the directory where your lsp files are and do Findstr rad2deg *.lsp and it will display all the files with that text. 

 

You can look in your menu files also use CUI or if your lucky can open the .mnu files, also look for mnl files they load lisps as well.

 

If its a big lisp could look for C : using findstr and get all the command defuns.

 

go bottom left in windows type CMD
then for this lisp directory
D:
CD \LISP
D:\LISP>findstr aaa *.lsp
AdvancedPolyOutlineV1-2.lsp:                (and (caaar lst) (caaadr lst)
AdvancedPolyOutlineV1-2.lsp:                            (setq ep1 (f (_endpoints (caaar  lst) (last (caar  lst)))))
AdvancedPolyOutlineV1-2.lsp:                            (setq ep2 (f (_endpoints (caaadr lst) (last (caadr lst)))))
repeat object along line.lsp:; change aaa to soemthing else to suit
repeat object along line.lsp:(defun c:aaa ( / pt1 pt2 pt3 ans oldang oldangdir oldsnap xoff yoff maxspc dia )
repeat object along line.lsp:(alert "Type aaa to run again")
repeat object along line.lsp:(c:aaa)
ss.lsp:(defun c:aaa ( / ss)

D:\LISP>

Similar to Notepad method

  • Like 1
Link to comment
Share on other sites

I really like using "Agent Ransack".  https://www.mythicsoft.com/agentransack/

The free version is just what I need. You enter the folder containing the lisp files you want to search. Then enter the search term. The left side of the resulting window will show all the files containing your search term. If you high-lite, i.e. select, one of the files the right side of the window shows ALL the incidences of the search term in THAT file. The entire line of the file is displayed so you can review whether or not the context is what you are looking for. It is a slick program. Too bad it has such an odd name!

Link to comment
Share on other sites

thanks for the feedback! 

yeh i definitely need to do a bit of housekeeping and tidy up my main lisp folder.. 

i grabbed that agentransack app. that'll come in handy i'm sure. i've never been able to get the windows search function to find all the stuff it should be finding

Link to comment
Share on other sites

You could try this one, command is 'LH' - let me know if it wants something else

 

(it is my 'help' LISP, you can read through it to work out what it does, but for this thread select a LISP in the main list and in the top of the box on the right will tell you the file. You can also search LISPs in a file from the top 2 dialogues. I didn't get chance over the weekend to take stuff out to do just what you wanted, )

 

LISPSHELP.lsp

Link to comment
Share on other sites

Had a play with startapp, shell, and powershell using findstr, pretty sure could get one of them to work passing the command to the windows operating system, so very fast.

 

This worked bat file that you would write with lisp so look for string aaa

c:\\windows\\syswow64\\findstr.exe aaa D:\\lisp\\*.lsp
pause

Lisp code to call the bat file

(startapp "D:\\acadtemp\\test.bat")

 

 

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...