Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

open command

10 REPLIES 10
Reply
Message 1 of 11
Anonymous
306 Views, 10 Replies

open command

Is there a way to create a toolbar menu macro or lisp routine so that when
activated it issues the OPEN command with the dialog box set to a particular
directory?
10 REPLIES 10
Message 2 of 11
Anonymous
in reply to: Anonymous

Here is a start:

(setq FNAME (getfiled "Open" "C:/Program Files/Autodesk Architectural Desktop 2005/Support/" "dwg" 16))
Message 3 of 11
tader1
in reply to: Anonymous

not a lisp thing, but u could right click on your acad icon on desktop and properties and fill in the "start in". This will now become your default opening directory.
Message 4 of 11
Anonymous
in reply to: Anonymous

You will find another clue here:

http://discussion.autodesk.com/thread.jspa?messageID=4984032
Message 5 of 11
Anonymous
in reply to: Anonymous

Thanks for your help all, I do have the "start in" set already to our most
common drawings directory but I have another directory that it would be very
handy to be able to open right to. That's what I want to do with a
keystroke or toolbar icon. I am going to explore Sherm's posts...
I had been using the shell command which fires up windows explorer to that
directory but it's unclean in the sense that it leaves explorer windows
open. I knew there had to be a better way.
Thanks again.
wrote in message news:5087675@discussion.autodesk.com...
not a lisp thing, but u could right click on your acad icon on desktop and
properties and fill in the "start in". This will now become your default
opening directory.
Message 6 of 11
Anonymous
in reply to: Anonymous

Thanks Sherm,
I am familiar with the getfiled function but it seems that it is not
possible to get autocad to "open" FILEN in the same instance of AutoCAD. Am
I correct?

wrote in message news:5088094@discussion.autodesk.com...
You will find another clue here:

http://discussion.autodesk.com/thread.jspa?messageID=4984032
Message 7 of 11
EC-CAD
in reply to: Anonymous

You are correct. About the only way would be to
write a Lisp program, called from your Menu Macro.
In that Lisp.. select the file you want to open, using
(getfiled .. then, open a script file, write into that,
.qsave
.close
.open
filename (from getfiled)
......end of script.
close the script file, and
use (command "script" .. to run the script.

Bob
Message 8 of 11
Anonymous
in reply to: Anonymous

Hi Greg,

Here is a little lisp that will work in multiple document mode.
It is also possible to make it work in single document mode; you just have to add some code to check if the current drawing needs to be saved or not...

Regards
S

[code]
(defun MyOpen (FileName ReadOnly / );vlisp open method by T.Willey
(vla-Open (vla-get-Documents (vlax-get-Acad-Object)) FileName (if ReadOnly :vlax-true :vlax-false))
)

(defun c:op ( / FNAME NEWDOC)
(if (= (getvar "SDI") 0)
(progn
(setq FNAME (getfiled "Open" "C:/Program Files/Autodesk Architectural Desktop 2005/Support/" "dwg" 16))
(setq NEWDOC (MyOpen FNAME nil))
(vla-put-activedocument (vlax-get-Acad-Object) NEWDOC)
)
(alert "Only works in Multiple Document Mode!\n (SDI = 0)")
)
(princ)
)
[/code]
Message 9 of 11
Anonymous
in reply to: Anonymous

Thanks for your input all.
Sherm, I didn't see any code in your last post, but I tried this and I think
it's going to do what I need it to...

(defun c:EZERWASOPEN (/ filename)
(setvar "sdi" 0)
(setq filename (getfiled "Open"
"f:/shared/drawings/current/ezerwas"
"dwg"
16
)
)
(vl-load-com)
(vla-activate
(vla-open (vla-get-documents (vlax-get-acad-object))
filename
)
)
)

I just assigned it to a toolbar macro and seems to work.

"Greg Hubers" wrote in message
news:5087651@discussion.autodesk.com...
Is there a way to create a toolbar menu macro or lisp routine so that when
activated it issues the OPEN command with the dialog box set to a particular
directory?
Message 10 of 11
Anonymous
in reply to: Anonymous

Hi Greg,

What are you using to view this DG? If you couldn't see the code I would change if I were you?! I am using iExplorer! The code was wrapped in [ code ] [ / code ] tags to maintain formatting

Also there was a file attached. Could you not see that either?
Here is the code BUT watch for word wrap and all the indenting is probably gone!

(defun MyOpen (FileName ReadOnly / );vlisp open method by T.Willey
(vla-Open (vla-get-Documents (vlax-get-Acad-Object)) FileName (if ReadOnly :vlax-true :vlax-false))
)

(defun c:op ( / FNAME NEWDOC)
(if (= (getvar "SDI") 0)
(progn
(setq FNAME (getfiled "Open" "C:/Program Files/Autodesk Architectural Desktop 2005/Support/" "dwg" 16))
(setq NEWDOC (MyOpen FNAME nil))
(vla-put-activedocument (vlax-get-Acad-Object) NEWDOC)
)
(alert "Only works in Multiple Document Mode!\n (SDI = 0)")
)
(princ)
)

Also after a bit of playing with vlisp I have not been able to get it to work in SDI mode! Not sure if its possible or just that I don't know what I am doing! 😉

Cheers
S
Message 11 of 11
Anonymous
in reply to: Anonymous

I didn't know about vla-activate! Shows how much I know! or don't!

(defun c:op ( / FNAME NEWDOC)
(if (= (getvar "SDI") 0)
(progn
(setq FNAME (getfiled "Open" "f:/shared/drawings/current/ezerwas" "dwg" 16))
(vla-activate (vla-Open (vla-get-Documents (vlax-get-Acad-Object)) FNAME :vlax-false))
)
(alert "Only works in Multiple Document Mode!\n (SDI = 0)")
)
(princ)
)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost