Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Cannot find drawing from script

17 REPLIES 17
SOLVED
Reply
Message 1 of 18
tmccar
1770 Views, 17 Replies

Cannot find drawing from script

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?  

17 REPLIES 17
Message 2 of 18
pendean
in reply to: tmccar

What's in your script file?
What is Win7 set to use to open a DWG file?
Message 3 of 18
tmccar
in reply to: pendean

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

Message 4 of 18
dmfrazier
in reply to: tmccar

I think the main issue is that you are trying to open a file via the script and then continue to run the script in the newly opened file. Scripts (by themselves) can't do that. There is a program called ScriptPro (as well as others) that can run a script across multiple DWGs. There are also other ways to do what I think you are trying to do, but I can't be sure without seeing the actual script and maybe examples of filenames and/or paths that you try to run it with.
Message 5 of 18
tmccar
in reply to: dmfrazier

Ok, thanks. I guess you would need some way of returning control to the script, after the file has been closed.

Message 6 of 18
dmfrazier
in reply to: tmccar

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

 

Message 7 of 18
tmccar
in reply to: dmfrazier

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

Message 8 of 18
dmfrazier
in reply to: tmccar

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.

Message 9 of 18
tmccar
in reply to: dmfrazier

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.

Message 10 of 18
dmfrazier
in reply to: tmccar

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.

Message 11 of 18
tmccar
in reply to: dmfrazier

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

Message 12 of 18
dmfrazier
in reply to: tmccar

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.]

Message 13 of 18
tmccar
in reply to: dmfrazier

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.

Message 14 of 18
tmccar
in reply to: tmccar

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

 

Message 15 of 18
dmfrazier
in reply to: tmccar

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?

Message 16 of 18
tmccar
in reply to: dmfrazier

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.

Message 17 of 18
melanie.mKWEBN
in reply to: dmfrazier

yes they can
Message 18 of 18
dmfrazier
in reply to: melanie.mKWEBN

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.

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

Post to forums  

”Boost