Newb_to_Lsp Posted May 2, 2023 Posted May 2, 2023 There are several (and by that, I mean thousands) of lisp routines out there on the internet to launch explorer from AutoCAD to the current file's directory. Newer versions of cad basically have this built-in from a few places, but the basis of the lisp concept looks like this: (defun c:ExDWG () (startapp "Explorer" (strcat "/N,/E," (getvar "DWGPREFIX"))) (princ) ) What I'm trying to do is a slight variation on the idea. I want to create a lisp or macro that will open the current plot style directory (where the ctbs are.) Something like this: (defun c:pens () (startapp "Explorer" (strcat "/N,/E," (getvar "PrinterStyleSheetDir")) (princ) ) The problem is this second one doesn't work. Now, I'm pretty sure that it doesn't work because it could have multiple file paths. The drawing prefix variable in the first example can only return one value but the pen table support path could be set to an unlimited number of file paths sorted by importance. (Thats the only thing I can think of that is really different between the two statements. Tell me if I'm wrong, I need to learn!!! ) Can someone help me fix this code? I normally (almost always) have only one support path for the .ctb files so if it only works for the 'top one' that is fine with me. Ideally, someone could help me make it work regardless. (open multiple instances of explorer if needed via a loop perhaps?) Quote
Steven P Posted May 2, 2023 Posted May 2, 2023 Here is a bit of a hint, type this into the command line: (getvar "PrinterStyleSheetDir") and see what the result is... This will give a list of what you want I think: (setq MyObj (vla-get-Files (vla-get-Preferences (vlax-get-acad-object)))) (setq MyPlotStylePaths (vla-get-PrinterStyleSheetPath MyObj)) If list length = 1 then do explorer 1 Quote
ronjonp Posted May 2, 2023 Posted May 2, 2023 This: (getvar "PrinterStyleSheetDir") Needs to be this: (getenv "PrinterStyleSheetDir") 2 Quote
ronjonp Posted May 2, 2023 Posted May 2, 2023 2 hours ago, Newb_to_Lsp said: Thanks for the feedback! Works now! 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.