Script wont go past LISP Command

Script wont go past LISP Command

david.faunce
Enthusiast Enthusiast
1,512 Views
6 Replies
Message 1 of 7

Script wont go past LISP Command

david.faunce
Enthusiast
Enthusiast

USING AUTOCAD ELECTRICAL 2017

 

I have a script that will do the following:

1. Copy a master project into a new folder with a new name

2. Open up each drawing in the project and run a lisp function to update the titleblock

 

*The project has 17 sheets (I only listed the routine for the first few)*

 

I've narrowed down to the line that says "(setq copyproject (c:wd_...."). It does copy the project, but the script STOPS after that

it does not continue on.

 

*NOTE -  I have separated this script to run everything below the "copyproject" line and it works great. The problem is that the SCRIPT decides to end after the that specific LISP command.

 

Can anyone help? I'm sure there is a more efficient way to do this - can someone provide some insight?

 

Thanks in advance!

 

 

(load "C:/Users/ussatdafa/Desktop/ACAD_FILES/attributes.lsp")
FILEDIA
0
(setq prj "C:/Users/ussatdafa/Desktop/ACAD_FILES/master/master.wdp")
(setq newpath "C:/Users/ussatdafa/Desktop/ACAD_FILES/PROCESSED/G99999-1")
(setq newprj "C:/Users/ussatdafa/Desktop/ACAD_FILES/PROCESSED/G99999-1/G99999-1.wdp")
(setq copyproject (c:wd_cpyprj_main (list prj newprj nil newpath "" "" nil nil)))
(load "C:/Users/ussatdafa/Desktop/ACAD_FILES/attributes.lsp")
(setq fdwg "C:/Users/ussatdafa/Desktop/ACAD_FILES/PROCESSED/G99999-1/001 COVER SHEET.dwg")
(vla-activate (vla-open (vla-get-documents (vlax-get-acad-object)) fdwg))
(load "C:/Users/ussatdafa/Desktop/ACAD_FILES/attributes.lsp")
(setq titleblock_list (list "TITLEBLOCK" '("PROJECTNUMBER" . "G99999-1") '("PROJECTNAME" . "FAKE NEW CUSTOMER (G99999-1)") '("DESCRIPTION" . "") '("DATE" . "2017-10-05") '("SIZE" . "ANSI B") '("REVISION" . "A") '("SHT1" . "1") '("SHT2" . "16") '("SEQUENCENUMBER" . "SEE SUBMITTAL") '("MODELNUMBER" . "UNIT 1")))
(m:tbatts titleblock_list)
(setq fdwg "C:/Users/ussatdafa/Desktop/ACAD_FILES/PROCESSED/G99999-1/002 CUSTOMER CONNECTIONS.dwg")
(vla-activate (vla-open (vla-get-documents (vlax-get-acad-object)) fdwg))
(load "C:/Users/ussatdafa/Desktop/ACAD_FILES/attributes.lsp")
(setq titleblock_list (list "TITLEBLOCK" '("PROJECTNUMBER" . "G99999-1") '("PROJECTNAME" . "FAKE NEW CUSTOMER (G99999-1)") '("DESCRIPTION" . "") '("DATE" . "2017-10-05") '("SIZE" . "ANSI B") '("REVISION" . "A") '("SHT1" . "1") '("SHT2" . "16") '("SEQUENCENUMBER" . "SEE SUBMITTAL") '("MODELNUMBER" . "UNIT 1")))
(m:tbatts titleblock_list)
0 Likes
1,513 Views
6 Replies
Replies (6)
Message 2 of 7

marko_ribar
Advisor
Advisor

Why is your command function (c:wd_cpyprj_main) defined with arguments... I'd personally defined it as non-command function (wd_cpyprj_main args...)... Is there something inside that command function that will prevent script from continuing operations - something like "\\" pause for user input, (alert) function or something unusual?... I'd inspect it more seriously and looked into what output should be... If it's something not nil then passing that value to your setq variable would be correct - if it's nil, then I'd watch to avoid this by debugging that (wd_cpyprj_main args...) function and make sure it returns correct value... I am still not so knowledgeable person to mention what could be all possible reasons why script stopped, but search for those I did mention and see if it makes the changes... Looking forward to see that you overcome this issue with your own expertise...

Kind regards, M.R.

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 3 of 7

zph
Collaborator
Collaborator

I've a little experience mixing script and AutoLISP routine files.  So, I take a stab on your issue.

 

I had success with 'chaining' script and AutoLISP files.

 

For instance, you run script1 and it calls the LISP routine.  At the end of the LISP routine, use the script function to execute script2 (which would be the portion of code you currently have AFTER the LISP routine).

 

Does this make sense?

 

0 Likes
Message 4 of 7

david.faunce
Enthusiast
Enthusiast

I've already tried it as

 

(c:wd_cpyprj_main (list prj newprj nil newpath "" "" nil nil))

with no success. This was just me trying to figure out another way to keep the script alive.

 

The nils are intentional. The first nil (location 2) means "copy all drawings in project"

 

The last two nils are:

"*optional list of flags for related files to copy, use nil to ignore"

"*list of file names for above flags, use nil to ignore"

0 Likes
Message 5 of 7

david.faunce
Enthusiast
Enthusiast

I actually did try to chain the scripts and still no success. I think the issue is that the "(c:wd_cpyprj_main)" function takes about 5 seconds to fully process. I think the script tries to read the next line before the copy project function finishes.

 

Someone mentioned a "PAUSE". How do I use this?

0 Likes
Message 6 of 7

marko_ribar
Advisor
Advisor

I said that you should avoid PAUSE inside problematic function... Also avoid (alert) function as it can stop script... But without looking into body of problematic function I can't tell you more, and even if I see it I don't think I would say something special I already didn't say...

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 7 of 7

zph
Collaborator
Collaborator

Without seeing the code contained within "(c:wd_cpyprj_main)" I have to assume the problem lies within it as you stated everything else is working as you intended in your script.

 

Although, just in case and for your reference:

 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/run-script-file-through-lisp-routine...

 

(command "_script" "C:/path/yourscript.scr")

 

^ This code would be inserted in your "(c:wd_cpyprj_main)" routine as the last line of code leading to the 2nd script.

 

Best of luck to you, sir.

0 Likes