When opening a file from a script in Windows 7, Autocad 2011, I get the message "Cannot find the specified drawing file", although the file exists and I can open it in the normal way. What could be causing this?
Solved! Go to Solution.
Solved by tmccar. Go to Solution.
The script file has multiple commands like this:
open <filename.dwg>
attin <filename.txt>
save
open <filename.dwg>
attin <filename.txt>
save
open <filename.dwg>
attin <filename.txt>
save
Windows 7 is set to use Autocad to open .dwg files
Ok, thanks. I guess you would need some way of returning control to the script, after the file has been closed.
Well, that's sort of it, but it's really due to the fact that a script runs within a document, not within (and throughout) the application. Once you issue the "open" command from a script, you are now in a different document which cannot "see" the script that is running in the other document.
But without knowing the content of your script and understanding what you are actually trying to accomplish, this is just a "guess" as to what is going on.
Post your script if you would like more meaningful assistance. I suspect what you are trying to do can be done fairly easily with a minor change to your strategy.
If you would like to do some self-directed learning, see this Help topic and look for the discussion of acaddoc.lsp:
http://docs.autodesk.com/ACD/2013/ENU/files/GUID-FDB4038D-1620-4A56-8824-D37729D42520.htm
Here's what the script looks like - pretty simple really:
open <filename.dwg>
attin <filename.txt>
save
open <filename.dwg>
attin <filename.txt>
save
open <filename.dwg>
attin <filename.txt>
save
Okay. Well, first of all, a script has to contain all the "information" (commands, options, responses) that AutoCAD would need just as if you were typing it at the command line. So, the main problem right now is that "<filename.dwg>" and "<filename.txt>" are not valid responses to the OPEN and ATTIN commands. The chevrons at the beginning and end are being interpreted as part of the filename, so you don't want to include them. You also need to enter the actual filename, and you might need to include the path along with the filename.
See this Help topic:
http://docs.autodesk.com/ACD/2013/ENU/files/GUID-95BB6824-0700-4019-9672-E6B502659E9E.htm
Start by entering the commands at the command line and noticing how AutoCAD wants the responses.
To help keep things on the command line (instead of popping up dialog or browse windows) while you're doing this, set FILEDIA to 0 (zero, or off). Also note that certain commands that would normally pop up a dialog may have to be run with a "-" (dash) prefix, as in -PLOT, but so far your script doesn't appear to include any of those commands.
No, that is not what is in the script. I do have actual filenames and no chevrons. I just have it in my post as a placeholder.
Okay, that's encouraging.
So, then I will assume you have the correct path/filename in your script.
Now, write the script to do what you want done to just one (the current) DWG file, assuming that file is already open. Based on what you posted earlier, the script might do nothing more than run the ATTIN command and then QSAVE or CLOSE. That's okay, because even something that simple can benefit from a script. The key (which we'll get to eventually) is figuring out how to get that script to run on a group of DWG files.
Test the script and make sure it works.
What does that script look like?
Whether the script works or not, post the exact script here for further guidance.
Ok, here is the bones of it:
open TV710-FS-382.dwg
attin TV1710-FS-382.txt
save
open TV1710-VA-382.dwg
attin TV1710-VA.txt>
save
open TV1710-FT-382.dwg
attin TV1710-FT-382.txt
save
.....and so on
The "open" part has to go away, unless it's all you want to do. You have to assume the DWG file is already open when the script runs. (We can deal with that later.)
So based on the script you posted, it looks like you want to run ATTIN, open a specific TXT file, and then SAVE. You might also want to quit/close the file after this is done, but I'll let you decide whether and how you do that.
One significant problem I see: it looks like the file you are "ATTIN-ing" will be different for each DWG file you want to run the script with. If this is true, then you won't be able to do this with a script that has a "hard-coded" (permanent) path/filename - you will have to allow (force) the user to either type in the filename or (better option) select the file from a browse window.
[That's all I can handle for now - the weekend is here. I will pick this up on Monday unless someone else slides in here, or unless you've had enough of this.]
Ok, thanks for all your help so far. It's on myh work PC anyway which is 3 hours away and I won't be there until Monday morning dv.
Solved it! I just needed to add the full pathname (in quote marks) and add a blank line after "save".
(I have substituted the real server name)
open "\\Servername\share$\My Documents\CAD\T1711-VA-305.dwg"
attin T1711-VA-305.txt
save
open "\\Servername\share$\My Documents\CAD\T1711-VA-705.dwg"
attin T1711-VA-705.txt
save
open "\\Servername\share$\My Documents\CAD\T1711-VA-805.dwg"
attin T1711-VA-805.txt
save
open "\\Servername\share$\My Documents\CAD\T1711-VA-605.dwg"
attin T1711-VA-605.txt
save
Glad you solved it.
I'm curious to know how the script is working. How are you running it, and how do you get it to continue from one DWG to the next?
I saved the file with a ".scr" extension and I run it from a blank drawing. It continues from one drawing to another without any problems. The only thing is, it leaves them open - I haven't tried running with any "close" commands.
When responding to a specific statement in a post, it's helpful to quote the specific statement, so we can better understand what your response means.