garnerd Posted December 4, 2012 Posted December 4, 2012 Anyone know how to trace a lisp routine? I was hired as a CAD Manager for a company that already has multiple lisp programs in multiple files. When there are issues with one I have to search through all the lisp files to find that specific routine to make any adjustments. Is there a way to extract a file path and/or file name for a specific routine? Quote
BlackBox Posted December 4, 2012 Posted December 4, 2012 (edited) Welcome to CADTutor! Consider a simple routine using the vlr-Lisp-Reactor function: (vl-load-com) (defun c:LispWatch () (princ "\rLISPWATCH = ") (if *Reactor_LispWatch* (progn ; Turn off (vlr-remove *Reactor_LispWatch*) (setq *Reactor_LispWatch* nil) (setq Callback:LispCancelled nil) (setq Callback:LispEnded nil) (setq Callback:LispWillStart nil) (princ "OFF ") ) (progn ; Turn on (or *Reactor_LispWatch* (setq *Reactor_LispWatch* (vlr-lisp-reactor "LispWatch" '( (:vlr-lispcancelled . Callback:LispCancelled) (:vlr-lispended . Callback:LispEnded) (:vlr-lispwillstart . Callback:LispWillStart) ) ) ) ) (defun Callback:LispCancelled (rea lsp) (prompt "\n[LispWatch] : Lisp Cancelled ") ) (defun Callback:LispEnded (rea lsp) (prompt "\n[LispWatch] : Lisp Ended ") ) (defun Callback:LispWillStart (rea lsp) (prompt (strcat "\n[LispWatch] : Lisp Will Start \t\t : " (car lsp) ) ) ) (princ "ON ") ) ) (princ) ) (princ) ** Note - I know of no way to determine which file (.LSP) was used to load the routine via LISP. Perhaps the .NET API will provide a means for this, if not then you're relegated to ObjectARX (C++ for AutoCAD). HTH Edited December 4, 2012 by BlackBox Added LispCancelled, and LispEnded Callbacks Quote
BlackBox Posted December 4, 2012 Posted December 4, 2012 Also worthy of note, especially if/when you delve into the .NET API, MdgDbg offers similar functionality (which the Prompt above was intended to resemble) via enabling Document Events reporting. Quote
garnerd Posted December 4, 2012 Author Posted December 4, 2012 Thanks for the response. It looks useful, but not what I need as you noted. I have yet to get into .NET API. baby steps at this point. I've gotten my feet wet with LISP, but still have a lot to learn. Maybe someone else can chime in on this one, it seems like it may be a long shot, but figured I'd throw it out there. Quote
BlackBox Posted December 4, 2012 Posted December 4, 2012 ... This routine will successfully identify any defined LISP function used... Simply read the symbol name from the command line, and search via Windows Explorer. Unfortunately, LISP does not offer the same LOD (Level of Detail), as compiled .NET assemblies, in that they lack .NET's ability to tap into System Namespaces/Classes to determine to current executing code, etc.. Quote
garnerd Posted December 4, 2012 Author Posted December 4, 2012 This is what I get: Command: r3f [LispWatch] : Lisp Will Start : (C:R3F)undo Current settings: Auto = On, Control = All, Combine = Yes, Layer = Yes Enter the number of operations to undo or [Auto/Control/BEgin/End/Mark/Back] <1>: m Command: Flips oject 180 degrees around chosen axis. Select objects: 1 found Select objects: Select first point on rotation axis: rotate3d Current positive angle: ANGDIR=counterclockwise ANGBASE=0.000 Select objects: 1 found Select objects: Specify first point on axis or define axis by [Object/Last/View/Xaxis/Yaxis/Zaxis/2points]: Specify second point on axis: Specify rotation angle or [Reference]: 180 Command: Command: [LispWatch] : Lisp Ended The lisp name is "R3F" I knew that cause I input it in the command line. The .LSP file is named "R3" I have a few lisp routines (that relate to the rotate3d command) in that .LSP file. I'm guessing the intent of the Lispwatch routine is to find the command name for any lisp routines that are coded in buttons and such. Is that correct? Or am I missing something? Thanks for the help and please excuse any ignorance on my part if I'm missing the mark here. Quote
BlackBox Posted December 4, 2012 Posted December 4, 2012 No worries; the intent here is to identify what LISP routine has been called, at the time of invocation. The Reactor's LispWillStart Event is raised for any LISP that is called, regardless of Button, or keyboard entry, etc.. Within your "R3.lsp" file, the function is defined as "C:R3F", as the C: prefix allows for the function to be called as a command like so "R3F", rather than wrapped in parens like so "(R3F)". Quote
garnerd Posted December 4, 2012 Author Posted December 4, 2012 I figured out a solution. I had to change my windows indexing and search options. Now I can just search for "c:r3f" in windows explorer. It wasn't set to search contents before. Thanks for the help. Quote
Lee Mac Posted December 5, 2012 Posted December 5, 2012 I figured out a solution. I had to change my windows indexing and search options. Now I can just search for "c:r3f" in windows explorer. It wasn't set to search contents before. Thanks for the help. Good move - I also use this indexing functionality of the Windows search when searching my function library. For those who don't know how to enable content indexing for a text format filetype, see this old post of mine from AUGI: http://forums.augi.com/showthread.php?135359-Search-lisp-folders-for-text-strings-in-Windows-7&p=1152176#post1152176 Quote
Recommended Posts
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.