Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Active Member
iharper
Posts: 6
Registered: ‎03-02-2006
Message 1 of 8 (5,471 Views)

Script file to open multiple dwg file and run a lisp not working in ACAD 2012

5471 Views, 7 Replies
12-22-2011 10:46 AM

I am trying to make a script file to open a drawing and run a lisp routine. They both work independently just fine, the script file will open the all of the files fine... and the lisp is in the startup suite and works in all the files. But when I tell the script file to open the first drawing then run the lisp it hangs trying to open the next file after running the lisp. I have Filedia set to 0, but the message I get when it goes to open the next is "No canvas exists. Please click New Canvas." (And on top of that... Filedia even set back to 1 still does not display the Dialog box anymore, I have to shut down AutoCAD 2012 and start again then it works.) I Have tried several ways, Opening one at a time then run lisp, and open all files first and then try to run lisp (that closes the file after running) and try and run it again in the next... It will only run the lisp one time and then locks up from there. PLEASE HELP ME... if anybody knows how to fix this... besides me having to learn .NET :smileyfrustrated: Thank you!

*Expert Elite*
Patchy
Posts: 6,257
Registered: ‎09-16-2009
Message 2 of 8 (5,455 Views)

Re: Script file to open multiple dwg file and run a lisp not working in ACAD 201

12-22-2011 12:53 PM in reply to: iharper
Active Member
Southernamp
Posts: 6
Registered: ‎05-03-2010
Message 3 of 8 (5,431 Views)

Re: Script file to open multiple dwg file and run a lisp not working in ACAD 201

12-23-2011 05:53 AM in reply to: iharper

Getting a look at the lisp/script would give us all a huge head start at getting you pointed in the right direction...

 

My initial thoughts, sight unseen, would be what is your SDI value set to?

Active Member
iharper
Posts: 6
Registered: ‎03-02-2006
Message 4 of 8 (5,401 Views)

Re: Script file to open multiple dwg file and run a lisp not working in ACAD 201

12-27-2011 10:06 AM in reply to: iharper

SDI=0 the SCR will open all dwgs and run lisp once in 1st file only. If I open one at a time and running the lisp it will not run the lisp in the 2nd dwg file. Lisp is in Startup Suite (However, it will work at the keyboard). 

*Expert Elite*
M_Hensley
Posts: 1,712
Registered: ‎12-11-2003
Message 5 of 8 (5,394 Views)

Re: Script file to open multiple dwg file and run a lisp not working in ACAD 201

12-27-2011 11:37 AM in reply to: iharper

To avoid any issues with the lisp not being properly auto-loaded into each drawing you should load the lisp file in your script.

My script files for running lisp programs look like this:

 

OPEN

"drawingname"

(load "lispfilename")

QSAVE

CLOSE

OPEN...

 

(I write my lisp program without a defun C: so it will run when loaded without issuing another command.)

 

Also if your lisp program does not fully run and exit cleanly then the script will not open the next drawing.

Active Member
iharper
Posts: 6
Registered: ‎03-02-2006
Message 6 of 8 (5,381 Views)

Re: Script file to open multiple dwg file And run a lisp not working in ACAD 201

12-27-2011 02:45 PM in reply to: iharper

Ok so I fixed the routine to run like you said... And if I open the file manually And type (load"86") it works fine...

(command "-layer" "T" "CAFM-PATT" "ON" "CAFM-PATT" "S" "CAFM-PATT" ""()
(command "-layer" "F" "*" "")
(command "-layer" "T" "CAFM-QURY" "ON" "CAFM-QURY" "")
(command "-layer" "T" "CAFM-TYPE" "ON" "CAFM-TYPE" "")
(command "-layer" "A" "D" "CLEAR PATT-QURY-TYPE" "" "")
(command "-layer" "A" "S" "CLEAR PATT-QURY-TYPE" "" "" "")
(command "-layer" "A" "R" "CLEAR PATT-QURY-TYPE" "" "")
(command ".erase" "ALL" "")
(command "-layer" "A" "R" "_MASTER" "" "")
)

But when it is in my script file...

FILEDIA
0
OPEN
"C:\_Isaac\TEST-DRAWINGS\TEST1.DWG"
(load"86")
QSAVE
CLOSE
OPEN
"C:\_Isaac\TEST-DRAWINGS\TEST2.DWG"
(load"86")
QSAVE
CLOSE
OPEN
"C:\_Isaac\TEST-DRAWINGS\TEST3.DWG"
(load"86")
QSAVE
CLOSE
OPEN
"C:\_Isaac\TEST-DRAWINGS\TEST4.DWG"
(load"86")
QSAVE
CLOSE
FILEDIA
1

 

It opens TEST1.dwg fine but now I get nothing after that... this is the command prompt now.

Command: "C:\_Isaac\TEST-DRAWINGS\TEST1.DWG"
Unknown command "DWG"". Press F1 for help.

I made sure there is no extra spaces at the end of the script lines, And I hit enter on the last line...?

Im stumped... Before it would run the lisp once And open the next file but not run the lisp in the second file that opened. Now it will not even run the lisp in the first file it opens...

Here are the new files... FYI , the test2... test3... test4 dwg files are just a saveas of test1 And the new names.  

 

Sorry can't send the SCR I guess it's not a valid acceptable extension, but it's shown above. 

Once again thank you for your help.

*Expert Elite*
M_Hensley
Posts: 1,712
Registered: ‎12-11-2003
Message 7 of 8 (5,360 Views)

Re: Script file to open multiple dwg file And run a lisp not working in ACAD 201

12-28-2011 04:17 AM in reply to: iharper

I tried your script and it ran perfectly for me. Opened each drawing, loaded the lisp, saved and closed.

Seems like yourfiles are OK. Need to look for some other culprit.

 

Make sure none of your drawings are open i.e. call the script from a drawing that is not one that is named in the script.

Mentor
stevor
Posts: 853
Registered: ‎12-26-2005
Message 8 of 8 (5,360 Views)

Re: Script file to open multiple dwg file And run a lisp not working in ACAD 201

12-28-2011 04:18 AM in reply to: iharper

To send files that are blocked by their extension,

you can change the extension, ie, .SCR to .RCS,

or put eveything in a zip or 7z container.

S
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.