Kenter Posted August 3, 2010 Share Posted August 3, 2010 Is there a way to grab the name of the file you are working on, and store it as a variable?? eg. You open a file called 'square', and you want to take the drawing name and store it as variable 'name'..... Not sure if this can be done, but if it is possible, the answer would be found on this forum for sure. Kenter Quote Link to comment Share on other sites More sharing options...
Hippe013 Posted August 3, 2010 Share Posted August 3, 2010 It can certainly be done. Type the following code into the command line. (setq name (getvar "DWGNAME")) Afterwhich type: !name on the command line. Quote Link to comment Share on other sites More sharing options...
alanjt Posted August 3, 2010 Share Posted August 3, 2010 Also, (getvar 'dwgprefix) will give you the location. Quote Link to comment Share on other sites More sharing options...
Kenter Posted August 3, 2010 Author Share Posted August 3, 2010 Thank you both. I used: (setq name (substr (getvar 'dwgname) 1 (- (strlen (getvar 'dwgname)) 4))) It grabbed it without taking the .dwg at the end. Kenter Quote Link to comment Share on other sites More sharing options...
alanjt Posted August 3, 2010 Share Posted August 3, 2010 or (vl-filename-base (getvar 'dwgname)) 1 Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 3, 2010 Share Posted August 3, 2010 Thank you both. I used:It grabbed it without taking the .dwg at the end. Kenter Really a very smart result . you do have the ability to get through codes. Best regards Tharwat Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 3, 2010 Share Posted August 3, 2010 or (vl-filename-base (getvar 'dwgname)) Undoubtly , this is the shortest and direct one ..... Quote Link to comment Share on other sites More sharing options...
alanjt Posted August 3, 2010 Share Posted August 3, 2010 Undoubtly , this is the shortest and direct one ..... faster too Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 3, 2010 Share Posted August 3, 2010 Unnecessary, but for the VL-phobic: (substr (getvar 'DWGNAME) 1 (- (strlen (getvar 'DWGNAME)) 4)) Or (cadr (fnsplitl (getvar 'DWGNAME))) Quote Link to comment Share on other sites More sharing options...
Hippe013 Posted August 3, 2010 Share Posted August 3, 2010 (cadr ([color=red]fnsplitl[/color] (getvar 'DWGNAME))) Lee you are a dictionary of undocumented lisp functions! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 3, 2010 Share Posted August 3, 2010 lee you are a dictionary of undocumented lisp functions! .. :) ... 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.