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.
Solved! Go to Solution.
Solved by Erik_NL. Go to Solution.
@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: openEnter 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.]
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.
I found this:
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:
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;
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