TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: AVCAD on September 26, 2008, 03:50:15 PM
-
I have a 600 drawings I need to do a bunch of stuff too. I have a button that loads a simple lisp routine that I usually use but 600 drawings....each on at a time...I don't have time to do that. IS there any way I can load the lisp's in a SCRIPT files and then batch it using scriptpro?
here is what I did, I thought it would work but obviously it isnt.
;Sets Undo Control to Off
Undo control none
;
;
;Sets Viewres 10000
viewres
y
10000
;
;
fieldeval
31
;
;
;
LAYEREVAL
0
;
;
;
LAYERNOTIFY
0
;
;
;
visretain
1
;
;Enter new value for INSUNITS (0=unitless, 1=inches, 4=millimeter)
insunits
4
;
;
;
;
;Enter new value for INSUNITS (0=unitless, 1=inches, 4=millimeter)
insunitsdefsource
4
;
;
;
;
;Enter new value for INSUNITS (0=unitless, 1=inches, 4=millimeter)
insunitsdeftarget
4
;
;
(COMMAND "IMAGEFRAME" "0")
;
;
;
;
(load "C:/xxxx/lisp/XLAYER.LSP")
(XLAYER)
(load "C:/xxxx/lisp/clean.vlx")
(clean)
(load "C:/xxxx/lisp/PURGNEST.LSP")
(PURGNEST)
(load "C:/xxxx/lisp/xclean.lsp")
(xclean)
;
(COMMAND "DVIEW" "" "TWIST" "0" "")
(COMMAND "SNAPANG" "0")
(COMMAND "ZOOM" "E")
(COMMAND "LTSCALE" "1000")
;
;
;
;
;Sets Undo Control to On
Undo All
;
;
;
;
;Quick Saves
._qsave
Thanks in advance.
-
is this of any use - X-Batch (http://www.theswamp.org/index.php?topic=25128)
-
Or >>this (http://www.theswamp.org/index.php?topic=21412.msg259520#msg259520)<<?
-
no sorry neither are those are what I am looking for.
All I need to do is load and run my LSP files from a SCR file.
Is that possible, and how?
-
You can do that with what I posted a link to.
The following will load a LSP called 'My-Layers'
(write-line (strcat "(load " (chr 34) "My-Layers" (chr 34) ")") scrfile)
It's the same as typing (load"my-layers") at the command line.
-
you mean something like:
(load "lispfilename" "\nlispfilename.lsp file not loaded.")
-
I dont know. I cant anything you guys are posting to work. my SCR file just wont run the commands from my LISP file.
-
Make a Lisp file with all those things you want to do, and then change the highlighted in red line to what you called your Lisp file, and run this from within a drawing.
;batch_anything.lsp
;Created XXXXXXXX
;Date: Sept of 2002
;Description: Batch Process
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;start prog
(DEFUN C:batch_anything ()
;;;;;;;;;;;;;;;;;;;;;;;;;Select directory to be processed
(setq dfil (getfiled "Select A File In The Directory You Want To Batch Process" "p:/" "dwg" 0))
(setq wutdir (vl-filename-directory dfil))
(setq wutfiles (vl-directory-files wutdir "*.dwg"))
(setq scrfile (open "c:\\scrfile.scr" "w"))
(close scrfile)
(setq scrfile (open "c:\\scrfile.scr" "a"))
(foreach n wutfiles
(setq n2 (strcat "\""wutdir "\\" n "\""))
(setq n2 (vl-string-translate "\\" "\\" n2))
(setq scrline (strcat "open" " " n2 " " "(load\"[color=red]YOURLISP[/color]\")" " " "[color=red]YOURLISP[/color]" " " "qsave" " " "close"));;;;;;;COMMANDS FOR BATCH GO HERE
(write-line scrline scrfile)
(princ)
)
(close scrfile)
(command "script" "c:\\scrfile")
(princ "\n***Batch complete.***")
(princ)
);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;DEFUN
This basically goes the opposite direction you are trying to go. It creates, and runs a script from a Lsip, instead of running a Lisp from a Script. That's why I created it, to do just what you are talking about, batch process a whole crapload of dwg's.
-
I did what you said and it runs the LISP files now but how do I get it to run on multiple drawings?
-
That should have ran the script on all the drawings in the directory you selected?
-
I did what you said and it runs the LISP files now but how do I get it to run on multiple drawings?
Load the batch_anything lisp and run it, then select a folder that contains the drawings to be processed.
-
Oh, and change the drive letter too:
(setq dfil (getfiled "Select A File In The Directory You Want To Batch Process" "p:/" "dwg" 0))
-
ya i did that too, it runs on 1 drawings and then stops
-
An error will stop a script.
I forget but there is a way to resume from some errors.
But you need to manually step through the process and find the error.
-
could you add something like:
(while (= (getvar "cmdactive") 0)
(command "resume")
);while
-
I found it.
http://www.theswamp.org/index.php?topic=10539.msg133920#msg133920
-
ya i did that too, it runs on 1 drawings and then stops
Not sure what the problem is. If you still need help, I'll try and test some things when I get a chance.
-
or -> this (http://www.caddepot.com/cgi-bin/cfiles/cfiles.cgi?0,0,0,0,21,2537)
-
I am making one of my first tentative forays into LISP writing. All I want to do at the moment is to create a LISP to run an existing script of mine.
Here's what it consists of at the moment:
(DEFUN C:LDS200-0 ()
(command "script" "K:\\\\_LDS JOB DATA\\RE_FILES\\DRAWING SCRIPTS\\0_LAYER PROPERTIES.scr")
)
The script is stored on a network drive (hence the additional \\'s). When I run this, I just get an error saying invalid file name. Obviously, I've checked that the path is correct and that everything is spelt right. If I copy the script onto my C drive and change the path in the LISP accordingly, it all works fine. So how can I get my LISP to browse to the script on the network drive??
-
I guess you'er sure about the double \\?
Have you tried this:
(command "script" "K://_LDS JOB DATA/RE_FILES/DRAWING SCRIPTS/0_LAYER PROPERTIES.scr")
or this:
(command "script" "K:\\/_LDS JOB DATA\\RE_FILES\\DRAWING SCRIPTS\\0_LAYER PROPERTIES.scr")
-
Thanks for the reply Alan, but both those lines result in the same error message as before (invalid file name)
-
BTW welcome to the Swamp.
Just for grins would you try these too.
(command "script" "K:/_LDS JOB DATA/RE_FILES/DRAWING SCRIPTS/0_LAYER PROPERTIES.scr")
or this:
(command "script" "K:\\_LDS JOB DATA\\RE_FILES\\DRAWING SCRIPTS\\0_LAYER PROPERTIES.scr")
-
BTW welcome to the Swamp.
Thanks!
And thanks for the other two suggestions - they both worked! Now I have the quandary of which one to use!!
-
That's a good problem to have. 8-)