waders Posted June 29, 2012 Posted June 29, 2012 I have a hopfully easy question. I have a simple lisp that catch the current drawing name then strips out all but the last two characters. Which is the way are database is setup the last to character reprensent a discipline (example Xx01a1 is architectural first floor plan, Xx01e1 would be Lighing plan etc...) and we have a custom commands (A1, A2, E1, E2....) so when we re-file building floor back into are main database they all setup the same. My lisp works until I try call up the setq as a command it says "unknown command" "A1". Which if I type A1 into the command prompt it will run A1. Hopfully this makes sence. (defun c:test () (setq names (vl-filename-base (getvar "dwgname"))) ;returns just name (setq name (substr names 5)) ;returns just the last 2 characters of drawing name (command name)) Thanks Quote
MSasu Posted June 29, 2012 Posted June 29, 2012 Those commands are AutoLISP routines? If affirmative, then you should call them as: (c:a1) Therefore your code become: (eval (read (strcat "(c:" name ")"))) Quote
waders Posted June 29, 2012 Author Posted June 29, 2012 Hey MSasu, Thank you very much. That did it. Thanks again Quote
MSasu Posted June 29, 2012 Posted June 29, 2012 You're welcome! Another comment, you can extract the type in a much flexible way: (setq names (vl-filename-base (getvar "DWGNAME"))) (setq name (substr names (1- (strlen names)))) Quote
MSasu Posted July 2, 2012 Posted July 2, 2012 That will retrive the last two characters from file's name, no matter how long is that name. Quote
pBe Posted July 2, 2012 Posted July 2, 2012 Another crazy way of doing that, for the fun of it. (setq names (vl-filename-base (substr (setq names (getvar "DWGNAME")) (1- (vl-string-position 46 names nil t))))) Edited for filenames with "." 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.