PDA

View Full Version : How can I create a button to open a folder?



hasancad
2009-08-20, 04:08 PM
How can I create a button to open a folder?

this folder is a projrcts folder on server.

rkmcswain
2009-08-20, 05:02 PM
This macro opens Explorer to the directory of the current drawing.


^C^C^P(STARTAPP (strcat "EXPLORER /e," (getvar "dwgprefix")))(PRINC)


For some paths it may not work, so you can create a small lisp function and then call the function with the macro.



(defun openfolder ()
(STARTAPP "EXPLORER /e, \\\\server\\share\\")
)
;;;Then you macro would be
^C^C(openfolder);

Opie
2009-08-31, 06:19 PM
R.K.,

Couldn't you add quote characters (chr 34) around the (getvar "dwgprefix") code to get around the need of an additional routine?

(STARTAPP (strcat "EXPLORER /e," (chr34)(getvar "dwgprefix")(chr34)))(PRINC)
Of course, they are only needed if the designated folder contains spaces in any of the folder names.

alimhmd4
2009-09-03, 10:32 PM
This macro opens Explorer to the directory of the current drawing.


^C^C^P(STARTAPP (strcat "EXPLORER /e," (getvar "dwgprefix")))(PRINC)


For some paths it may not work, so you can create a small lisp function and then call the function with the macro.



(defun openfolder ()
(STARTAPP "EXPLORER /e, \\\\server\\share\\")
)
;;;Then you macro would be
^C^C(openfolder);



after you make this new command you can pull down in any menu in the cui
i put it in window menu
this is very good tips

Tom Beauford
2009-09-28, 06:22 PM
Few more examples...

For folders in the path:

^C^C^P(progn(startapp "explorer" (strcat "/n,/e," (findfile "Vlisp")))(princ))
Roamable Support Directory

^C^C^P(progn(startapp "explorer" (strcat "/n,/e," (getvar "roamablerootprefix")"Support"))(princ))
Drawing Template Directory

^C^C^P(progn(startapp "explorer" (strcat "/n,/e," (getvar "localrootprefix")"template"))(princ))
My Documents Directory

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

RobertB
2009-09-28, 10:22 PM
For folders in the path:

^C^C^P(progn(startapp "explorer" (strcat "/n,/e," (findfile "Vlisp")))(princ)) Huh? What do you mean by "in the path"? In the path to what? For the current drawing's folder I would use:

(startapp (strcat "Explorer /e,\"" (getvar 'DwgPrefix) "\""))

Drawing Template Directory

^C^C^P(progn(startapp "explorer" (strcat "/n,/e," (getvar "localrootprefix")"template"))(princ))
Probably a bad assumption. Many firms point the Templates folder to another location other the the OOTB folder.

(vl-load-com)
(startapp (strcat "Explorer /e,\"" (vla-Get-TemplateDWGPath (vla-Get-Files (vla-Get-Preferences (vlax-get-acad-object)))) "\""))

Tom Beauford
2009-09-29, 11:33 AM
Huh? What do you mean by "in the path"? In the path to what? For a folder expected to be in the support path you can use 'findfile'.

For the current drawing's folder I use about the same as you.

Our Templates folder is the OOTB folder, but I like your macro better. May keep mine tucked away just in case support fades away for Vlisp. Still supprised I needed a download for it to work in 2010.

RobertB
2009-09-29, 03:32 PM
For a folder expected to be in the support path you can use 'findfile'.Where I was going with that question is that "VLisp" does not exist on my system in the support path anywhere, so that specific example might not be a good example for the forum post.

ignjat123
2009-09-30, 12:44 PM
how I can use this macro to open root of my drawing in total commander, I try something like this ^C^C^P(startapp "D:\totalcmd1\TOTALCMD.EXE") (getvar "dwgprefix"))(PRINC) but it does not works

RobertB
2009-09-30, 03:30 PM
how I can use this macro to open root of my drawing in total commander, I try something like this
^C^C^P(startapp "D:\totalcmd1\TOTALCMD.EXE") (getvar "dwgprefix"))(PRINC) but it does not worksYou have a bad closing paren (indicated in red above). You may also run into issues with long filenames as it is currently written depending on how the application handles its arguments. Look more closely at the posted examples to see how to wrap long filenames in double quote marks.