Jump to content

question about batch, lisp, script files


todouble22

Recommended Posts

So, to use my original Purge lisp:

 

_open *file* (load "C:\\test\\purger.lsp") (purger) _save _close

Or, to use your Purge LISP as you have posted:

 

_open *file* (load "C:\\test\\purger.lsp") (c:purger) _save _close

Lee

LeeMac you are seriously the MAN! the wscript lisp is awesome and I am attempting to break it all down so I can figure out how it works. I figure I'll just go line by line deciphering it. I got it to work but I know the other users in my office will struggle more than myself throught the process. I understand that it selects the files by the _open *file* portion and then after putting in the load lisp part and then calling the lisp and then saving and closing, it creates the script for all the drawings in the selected folder.. how the heck did you do that?? so then i call the script from autocad and it zips through all drawings in the designated folder and like that its done. I showed one of my coworkers and he asked if there is a way to make it more user friendly? mind you I am not asking you to do anymore you have gone far above as always. I'd like to be able to come up with something that I could just perform the task on the selected drawings in a folder or in this instance purge all drawings in the folder or subfolders

Link to comment
Share on other sites

  • Replies 68
  • Created
  • Last Reply

Top Posters In This Topic

  • todouble22

    25

  • Lee Mac

    19

  • dbroada

    10

  • BIGAL

    4

Todd,

 

The LISP is not too complicated to be honest (not trying to sound patronising), it just takes each drawing filename from the folder (and subfolders) selected, and writes the script line substituting the filename for the *file* token.

 

The Script line can be whatever the user wants to put in their script, our example with running the LISP was just for this case - nothing to do with the script writer itself.

 

You may struggle to decipher it though, as I have used methods that are outside of Visual LISP, using methods from the Shell Object in Windows Shell, but the rest may be comprehensible :)

 

Glad you like it,

 

Lee

Link to comment
Share on other sites

I'm not sure that the user interface could be made much easier to be honest, (I suppose a dialog could be used for script-line entry, but it would be basically the same).

 

All the user needs is a knowledge of how to write a script, and the program will do the rest :)

Link to comment
Share on other sites

Todd,

 

The LISP is not too complicated to be honest (not trying to sound patronising), it just takes each drawing filename from the folder (and subfolders) selected, and writes the script line substituting the filename for the *file* token.

 

The Script line can be whatever the user wants to put in their script, our example with running the LISP was just for this case - nothing to do with the script writer itself.

 

You may struggle to decipher it though, as I have used methods that are outside of Visual LISP, using methods from the Shell Object in Windows Shell, but the rest may be comprehensible :)

 

Glad you like it,

 

Lee

I put it in vlisp and I'm going back and forth from each line now with the help screen to get a little better grasp on it. I'll see what I can figure out about the shell object part of it. I had a qick question on the beginning actually already?

(setq *acad (cond (*acad) ((vlax-get-acad-object))) ;Sets the value of a symbol or symbols to associated expressions, Serves as the primary conditional function for AutoLISP

;Retrieves the top level AutoCAD application object for the current AutoCAD session what does *acad do in this?

 

*doc (cond (*doc) ((vla-get-ActiveDocument *acad)))) ; what does *doc do? and vla-get-activedocument? is it the same as Returns a running instance of an application object

SERIOUSLY!! THANK YOU SOO MUCH!!

Link to comment
Share on other sites

went that link, read my initials, for all what I posted there now I am blank, don't remember nothing, nada, niep, nil.... :-(

 

Haha, did you hit your head at some point Luis... bit of amnesia... o:)

Link to comment
Share on other sites

LeeMac, I've been toying around with it a bit and using the script writer to call to other scripts that I have written so that I can use it to perform it on multiple drawings throught the folder selection method that you have put in it. The problem is that when I call another script it doesnt go on to the next drawing? Any suggestions as to what I am doing wrong? Or if you or anyone else has a better way of doing these sorts of things. thanks in advance

Link to comment
Share on other sites

LeeMac, I've been toying around with it a bit and using the script writer to call to other scripts that I have written so that I can use it to perform it on multiple drawings throught the folder selection method that you have put in it. The problem is that when I call another script it doesnt go on to the next drawing? Any suggestions as to what I am doing wrong? Or if you or anyone else has a better way of doing these sorts of things. thanks in advance

 

 

You cannot "nest" scripts - the new script in operation takes precedence over any others.

 

To be honest, I detest using scripts to perform operations - I would much rather put everything I want to do in a LISP and just call the one LISP from the script I am running.

 

Lee

Link to comment
Share on other sites

You can use multiple scripts in an operation, however, you would have to hard-code in a means to "pause" the LISP (or script, but I'm not sure how that would work) that's calling them until the previous one is finished running. I suppose it would look something like this (note: pseudo code)

 

...
[i]run script1
[/i](while (not var1)) ; This loop will repeat endlessly until var1 is set
[i]run script2
[/i](while (not var2)) ; This loop will repeat endlessly until var2 is set
...

;script1[i]
do stuff[/i]
(setq var1 T)

;script[i]2
do stuff[/i]
(setq var2 T)

I'm not 100% positive if this technique will work flawlessly. Further, trying to have a script run scripts may, by default, simply cancel the first script, or try to run both at the same time and thus not run at all. The only other way to do it is to daisy chain them: call the next script at the end of each script. Either way, it would mean you have to re-write all of your scripts. Now there are ways to do that with LISP, but there are simply easier methods. Bottom line is, AutoCAD abhors running concurrent scripts. It's best to avoid it.

Link to comment
Share on other sites

You cannot "nest" scripts - the new script in operation takes precedence over any others.

 

To be honest, I detest using scripts to perform operations - I would much rather put everything I want to do in a LISP and just call the one LISP from the script I am running.

 

Lee

Thanks again LeeMac , I am gonna play around with my script that I have for changing all title block attributes and see if I can write a lisp routine out of it all. Any suggestions for a start in that how I call the attributes to change?

Link to comment
Share on other sites

You can use multiple scripts in an operation, however, you would have to hard-code in a means to "pause" the LISP (or script, but I'm not sure how that would work) that's calling them until the previous one is finished running. I suppose it would look something like this (note: pseudo code)

 

...
[i]run script1[/i]
(while (not var1)) ; This loop will repeat endlessly until var1 is set
[i]run script2[/i]
(while (not var2)) ; This loop will repeat endlessly until var2 is set
...

;script1
[i]do stuff[/i]
(setq var1 T)

;script[i]2[/i]
[i]do stuff[/i]
(setq var2 T)

I'm not 100% positive if this technique will work flawlessly. Further, trying to have a script run scripts may, by default, simply cancel the first script, or try to run both at the same time and thus not run at all. The only other way to do it is to daisy chain them: call the next script at the end of each script. Either way, it would mean you have to re-write all of your scripts. Now there are ways to do that with LISP, but there are simply easier methods. Bottom line is, AutoCAD abhors running concurrent scripts. It's best to avoid it.

thanks for this info FreeRefill I am gonna mess around with this for a minute and see the results

Link to comment
Share on other sites

To be honest, I detest using scripts to perform operations - I would much rather put everything I want to do in a LISP and just call the one LISP from the script I am running.

 

Lee

and I would rather use a script. Much easier to make quick changes and simple enough for most draughties to do unsupervised. ;)

 

It does depend what the task is. If you know you have 80 drawings that all need issue box 1 changed it can be done in about 10 lines with a script. And next week when a different 120 drawings need issue box 5 changed the same script can be reused simply.

 

If however I have a series of drawings that need up issuing but the issue varies across the set I would use VBA.

Link to comment
Share on other sites

You can use multiple scripts in an operation, however, you would have to hard-code in a means to "pause" the LISP (or script, but I'm not sure how that would work) that's calling them until the previous one is finished running. I suppose it would look something like this (note: pseudo code)

 

...
[i]run script1
[/i](while (not var1)) ; This loop will repeat endlessly until var1 is set
[i]run script2
[/i](while (not var2)) ; This loop will repeat endlessly until var2 is set
...

;script1[i]
do stuff[/i]
(setq var1 T)

;script[i]2
do stuff[/i]
(setq var2 T)

I'm not 100% positive if this technique will work flawlessly. Further, trying to have a script run scripts may, by default, simply cancel the first script, or try to run both at the same time and thus not run at all. The only other way to do it is to daisy chain them: call the next script at the end of each script. Either way, it would mean you have to re-write all of your scripts. Now there are ways to do that with LISP, but there are simply easier methods. Bottom line is, AutoCAD abhors running concurrent scripts. It's best to avoid it.

 

An idea, but in my opinion this is a bit of a "bodge" - when you want something done its surely worth doing it properly :wink:

 

and I would rather use a script. Much easier to make quick changes and simple enough for most draughties to do unsupervised. ;)

 

It does depend what the task is. If you know you have 80 drawings that all need issue box 1 changed it can be done in about 10 lines with a script. And next week when a different 120 drawings need issue box 5 changed the same script can be reused simply.

 

If however I have a series of drawings that need up issuing but the issue varies across the set I would use VBA.

 

Ok, so for those who don't know LISP too well, it is perhaps not an option, but for all the messing around with nesting scripts in scripts and using timers, why not just take advantage of the additional power and accuracy you get with LISP, not to mention the extra error trapping.

 

With a knowledge of the language whether it be VBA or LISP, it is just as easy to modify the LISP as it would be the script.

Link to comment
Share on other sites

Thanks again LeeMac , I am gonna play around with my script that I have for changing all title block attributes and see if I can write a lisp routine out of it all. Any suggestions for a start in that how I call the attributes to change?

 

Perhaps create a selection set of the blocks needing to be changed, and then iterate through the set. I can help you a tad more if you describe what you would like to achieve ultimately :)

Link to comment
Share on other sites

Ok, so for those who don't know LISP too well, it is perhaps not an option, but for all the messing around with nesting scripts in scripts and using timers, why not just take advantage of the additional power and accuracy you get with LISP, not to mention the extra error trapping.

 

With a knowledge of the language whether it be VBA or LISP, it is just as easy to modify the LISP as it would be the script.

I certainly wouldn't nest scripts, I think that is asking for trouble. As for the time spent modifying a script the example above would take anyone in our office less than 5 minutes to prepare the script to action as many drawings as required. It takes longer than that for the VBA editor to load on my machine. :)
Link to comment
Share on other sites

An idea, but in my opinion this is a bit of a "bodge" - when you want something done its surely worth doing it properly :wink:

 

Oh, don't get me wrong, I know it's a bodge. I've had plenty of experience myself in its bodginess. However, regardless of how much it bodgifies the process or bodges the ultimate goal, a solution is, after all, a solution, no matter how bodged.

 

And really, I didn't want to respond to this for the sake of anything other than seeing how many different ways I could use the word "bodge."

Link to comment
Share on other sites

I certainly wouldn't nest scripts, I think that is asking for trouble. As for the time spent modifying a script the example above would take anyone in our office less than 5 minutes to prepare the script to action as many drawings as required. It takes longer than that for the VBA editor to load on my machine. :)

 

Perhaps I'm biased, but I just try to keep as many operations out of the script as I can - and would just use it to open, save and close.

 

I realise that you are looking at it from the speed aspect, but for reliability, there is no comparison.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...