Jump to content

LISP to open current drawing folder.


rich254

Recommended Posts

I am trying to find a LISP that will open up the folder in which the current drawing is contained. I have found some examples that people have said work but they don't seem to work for me.

 

(startapp (strcat "explorer /select,\"" (getvar 'dwgprefix) "\""))

 

When I use this it takes me to my Documents folder and no further. All of our drawings are contained on our network drive S:. I don't know if the cause is due to the drawing not being native to the computer's C drive or if it's a different problem.

 

Any help would be greatly appreciated, thanks.

Link to comment
Share on other sites

Weird, that syntax opens for me folder that is parent to (getvar 'dwgprefix)...

 

 

Have you tried just :

(startapp (strcat "EXPLORER " (getvar 'dwgprefix)))

Link to comment
Share on other sites

This is what I use:

(defun _opendirectory (path / sa)
 (if (and (eq 'str (type path))
   (findfile (vl-string-right-trim "\\" path))
   (setq sa (vlax-create-object "Shell.Application"))
     )
   (progn (vlax-invoke sa 'explore path) (vlax-release-object sa))
 )
 (princ)
)

;; Open folder current directory
(defun c:cd nil (_opendirectory (getvar 'dwgprefix)))

Link to comment
Share on other sites

I have this in my toolbar and so far it has always worked for me :

 

 

ID_Explorer    [_Button("Explorer", "Explorer.bmp", "ICON_16_BLANK")]^C^C(startapp "explorer" (getvar "dwgprefix")) 

Link to comment
Share on other sites

Why is the code compiled to VLX :o

 

Publishing programs on social medias with lisp file format would be a troublesome issue from lots of newbies so to keep mind calm I compile it to vlx format. :D

Link to comment
Share on other sites

Semi-crypted way may be:

(eval
 (read
   (apply 'strcat
     (mapcar 'chr
       '(40 68 69 70 85 78 45 81 32 67 58 84 69 83 84 32 110 105
         108 32 34 80 111 115 116 101 100 32 98 121 32 71 114 114
         114 34 32 34 104 116 116 112 58 47 47 119 119 119 46 99
         97 100 116 117 116 111 114 46 110 101 116 47 102 111 114
         117 109 47 115 104 111 119 116 104 114 101 97 100 46 112
         104 112 63 49 48 52 55 52 54 45 76 73 83 80 45 116 111 45
         111 112 101 110 45 99 117 114 114 101 110 116 45 100 114
         97 119 105 110 103 45 102 111 108 100 101 114 46 34 32 40
         67 79 78 68 32 40 40 90 69 82 79 80 32 40 71 69 84 86 65
         82 32 40 81 85 79 84 69 32 68 87 71 84 73 84 76 69 68 41
         41 41 32 40 65 76 69 82 84 32 34 92 110 84 104 105 115 32
         100 114 97 119 105 110 103 32 105 115 32 110 111 116 32
         115 97 118 101 100 33 34 41 41 32 40 40 115 116 97 114 
         116 97 112 112 32 40 65 80 80 76 89 32 40 81 85 79 84 69 
         32 83 84 82 67 65 84 41 32 40 65 80 80 69 78 68 32 40 81 
         85 79 84 69 32 40 34 101 120 112 108 111 114 101 114 32 
         47 115 101 108 101 99 116 44 32 34 41 41 32 40 77 65 80 
         67 65 82 32 40 81 85 79 84 69 32 71 69 84 86 65 82 41 32 
         40 81 85 79 84 69 32 40 68 87 71 80 82 69 70 73 88 32 68
         87 71 78 65 77 69 41 41 41 32 40 81 85 79 84 69 32 40 34 
         44 32 47 101 34 41 41 41 41 41 41 41 32 40 80 82 73 78 67 41 41
       )
     )
   )
 )
)
(C:test)

:)

Link to comment
Share on other sites

This macro works well on all our network drives as well:

^C^C^P(progn(startapp "explorer" (strcat "/n,/e," (getvar "dwgprefix")))(princ)) 

To open a file from the current drawings folder:

^C^C^P(vla-activate(vla-open (vla-get-documents (vlax-get-acad-object))(findfile(getfiled "Select File" (getvar 'dwgprefix) "dwg" ) :vlax-false))

I have:

(vl-load-com)

loaded in my acaddoc.lsp file, otherwise you may need to add it to any code using visual lisp as in:

^C^C^P[color="red"][b](vl-load-com)[/b][/color](vla-activate(vla-open (vla-get-documents (vlax-get-acad-object))(findfile(getfiled "Select File" (getvar 'dwgprefix) "dwg" ) :vlax-false))

to open a file from the current drawings folder.

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...