jyoung98 Posted July 30, 2021 Share Posted July 30, 2021 Hi, I'm working on a LISP that in part needs to grab the filename (without extension) for a command - I managed to do this using 'vl-filename-base' but since it needs to run in acoreconsole it can't use anything from the VL Library. Is there any way to either remove ".dwg" or remove the last 4 characters from a string in only vanilla LISP? Here's what I've got so far (defun C:PlotToLocation (/ filename) (vl-load-com) (setvar "cmdecho" 0) (setq filename (vl-filename-base (getvar 'dwgname))) (setq filename (strcat "A:\\X\\Y\\" (vl-filename-base (getvar 'dwgname))".pdf")) This sets the filename to "A:\X\Y\filename.pdf" I can currently get "A:\X\Y\filename.dwg.pdf" but since the PDFs have to follow a naming standard, I need a way to remove the ".dwg". Quote Link to comment Share on other sites More sharing options...
BIGAL Posted August 2, 2021 Share Posted August 2, 2021 (edited) Look into Strlen and Substr with those 2 lisp commands can do what you want. (setq dwgn (getvar 'dwgname)) (setq len (strlen dwgn)) your turn substr https://www.afralisp.net/reference/autolisp-functions.php Edited August 2, 2021 by BIGAL 1 Quote Link to comment Share on other sites More sharing options...
rlx Posted August 2, 2021 Share Posted August 2, 2021 (cadr (fnsplitl (getvar 'dwgname))) Quote Link to comment Share on other sites More sharing options...
ronjonp Posted August 2, 2021 Share Posted August 2, 2021 50 minutes ago, rlx said: (cadr (fnsplitl (getvar 'dwgname))) HAHAHA ... cross posted at Adesk forum last Friday. 1 Quote Link to comment Share on other sites More sharing options...
rlx Posted August 2, 2021 Share Posted August 2, 2021 , 2 , 1 (haha , 2 brains , 1 thought) 2 Quote Link to comment Share on other sites More sharing options...
jyoung98 Posted August 5, 2021 Author Share Posted August 5, 2021 Awesome, thanks everyone. Ended up going with (substr (getvar 'dwgname) 1 (- (strlen (getvar 'dwgname)) 4)) Quote Link to comment Share on other sites More sharing options...
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.