Jump to content

Lisp to open explorer to current PrinterStyleSheetDir


Newb_to_Lsp

Recommended Posts

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?)

 

 

Link to comment
Share on other sites

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

  • Like 1
Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...