M76 Posted September 14, 2009 Posted September 14, 2009 Hi I'm trying to run a command inside a lisp, that is loaded from a vlx file into autocad. But it gives me an unkown command error. If I simply run it from the command line it works, but not through a lisp. Do I need to do something extra for the command to be avaialable from a lisp? I don't have access to the source of the vlx. Quote
M76 Posted September 15, 2009 Author Posted September 15, 2009 Thanks, now that I see it I remember there was something like this. Quote
M76 Posted April 14, 2010 Author Posted April 14, 2010 I don't get it, how do I pass parameters to the command this way? Quote
Lee Mac Posted April 14, 2010 Posted April 14, 2010 Depending on how it is written, (your_command_here par1 par2 par3 ... parN) Quote
M76 Posted April 14, 2010 Author Posted April 14, 2010 No, I'm using a command from another file. (c:command) works, but that way I can't supply parameters. Quote
Lee Mac Posted April 14, 2010 Posted April 14, 2010 So you are stuck with this construct? [b][color=Blue](defun c:test (/ str) (setq str (getstring "\nEnter a String: ")) (print str) (princ))[/color][/b] (defun CallTest nil [b][color=Red] (c:test)[/color][/b] [b][color=Green](princ)[/color][/b]) This causes a problem as when the 'test' function is called (red), the blue code is evaluated, and the green code is not evaluated until the blue code is completed. Lee Quote
alanjt Posted April 14, 2010 Posted April 14, 2010 You're not giving a lot of information. However, it sounds like the vlx prompts for selection and a few questions. What you could do is create your selection, then feed the selection and other required parameters to the routine through vla-sendcommand (I know I plug this command a lot). eg. ssget (no pickfirst) (defun c:Test (/ ss) (if (setq ss (ssget "_:L")) (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "CommandName !ss Y N 0.5 "))) ssget (with pickfirst available) (defun c:Test (/ ss) (and (setq ss (ssget "_:L")) (sssetfirst nil ss) (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "CommandName Y N 0.5 "))) entsel (defun c:Test (/ e) (if (setq e (car (entsel))) (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "CommandName !e Y N 0.5 "))) Oh yeah, and if in a situation where a space " " will not force the command to continue (ie: (getstring T "\nEnter String: ") ), you can replace the " " with "\n", which will act the same as if the user pressed the Enter key. Quote
Lee Mac Posted April 14, 2010 Posted April 14, 2010 Nice idea Alan I hadn't thought of using that Quote
alanjt Posted April 14, 2010 Posted April 14, 2010 Nice idea Alan I hadn't thought of using that Thanks. I'm not crazy about it, but it's probably the best course. Quote
alanjt Posted April 14, 2010 Posted April 14, 2010 I need to write a little explanation on using vla-sendcommand. I swear I mention/explain it and load/autoload all the time. LOL Quote
M76 Posted April 15, 2010 Author Posted April 15, 2010 Thanks for the tips, I ended up copying the command into the same lsp, and editing it to work as a function. Quote
alanjt Posted April 15, 2010 Posted April 15, 2010 Thanks for the tips, I ended up copying the command into the same lsp, and editing it to work as a function. 'copying the command into the same lsp' ? 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.