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

Open standard drawing from menu

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
Erik_NL
643 Views, 6 Replies

Open standard drawing from menu

I have a small number of drawings that I use very often. I would like to make a menu item to open a certain drawing but I keep getting stuck when the drawing name should be entered automatically.

I use the code

^C^Cfiledia;0;open;"test.dwg";filedia;1;

 

The drawing is my support file search path and the name is unique. How do I get this to work properly?

 

When running this command:

Command: filedia
Enter new value for FILEDIA <1>: 0
Command: open

Enter name of drawing to open <C:\previous.dwg>:

*cancel*
Command: "test.dwg"
Unknown command ""TEST.DWG"".  Press F1 for help.
Command: filedia
Enter new value for FILEDIA <0>: 1

 

It asks what file to open and suggests the last opened file, and whatever I tried so far this keeps happening.

 

*.scr files are not allowed on our network, I can't create or rename files to *.scr. Of course I could ask the admins to allow this but I think our security policy is more important than me having a button to open a file.

6 REPLIES 6
Message 2 of 7
Kent1Cooper
in reply to: Erik_NL


@Erik_NL wrote:

.... I would like to make a menu item to open a certain drawing but I keep getting stuck when the drawing name should be entered automatically.

I use the code

^C^Cfiledia;0;open;"test.dwg";filedia;1;

.... 

When running this command:

Command: filedia
Enter new value for FILEDIA <1>: 0
Command: open

Enter name of drawing to open <C:\previous.dwg>:

*cancel*
Command: "test.dwg"
Unknown command ""TEST.DWG"".  Press F1 for help.
....


Could it be that you have some overlay program that may have redefined the Open command somehow?  Try using the decimal prefix to the command name, to force it to use the native AutoCAD version of the command.  And in this situation, I believe you don't need the quotes, nor the file type, with the drawing name.

 

^C^Cfiledia;0;.open;test;filedia;1;

 

[If that succeeds in opening the drawing, I'm not sure the Filedia reset will happen, since it will be in a different drawing than when the menu item was picked, but I haven't tried it.]

Kent Cooper, AIA
Message 3 of 7
Erik_NL
in reply to: Erik_NL

thanks, but this does not work. The same thing happens, but now we know the open command is called correctly.

I am pretty sure that there is no overlay or something else messing with the open command.

Message 4 of 7
Kent1Cooper
in reply to: Erik_NL

I found this:

http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/OPEN-command/m-p/790860/highlight/tru...

 

which suggests, at the beginning, using (command ".fileopen" "drawingname"), but I find it wants to close the current drawing, which I assume you wouldn't always want to do [I certainly wouldn't].  But it goes on with other more complicated ways to approach it, further down [I'll let you explore].

 

Also this:

 

http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Command-open-Failure/m-p/1458990/high...

Kent Cooper, AIA
Message 5 of 7
Erik_NL
in reply to: Kent1Cooper

Thanks, those discussions are ancient archives but they gave me a good hint.

 

I ended up with a VBA routine that I call from the menu:

 

In a .dvb that is automatically loaded:

Sub Opentestdwg()
Application.Documents.Open "C:\test.dwg", False
End Sub

 

In the menu:

^C^Cfiledia;0;.vbarun;Opentestdwg;filedia;1;

Message 6 of 7
dbroad
in reply to: Erik_NL

You can also do it without loading a vb module 2 ways. Remember that whenever you expect vba to work, you need to download the vba module since it hasn't been part of AutoCAD since around 2008.

 

(command "vbastmt" "application.documents.open (\"C:/junk.dwg\")")

 

or

 

(vla-activate(vla-open (vla-get-documents(vlax-get-acad-object)) "c:/junk.dwg"))

 

The second option is not dependent on you downloading the vba module.

 

If you want the menu macro to be done quietly, use ^P before the macro after the ^c^c

Architect, Registered NC, VA, SC, & GA.
Message 7 of 7
Erik_NL
in reply to: Erik_NL

Thanks!

I still use VBA just because I know it and used it in Microstation as well.

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

Post to forums  

”Boost