Hi everyone,
I am having an issue with scripts and batch functions.
I have wrote simple script :
PSLTSCALE
0
PURGEALL
ENTER
CLOSE
ENTER
PURGE ALL - Being the lisp that i have been using for cleaning the file. I loaded it in Scriptpro and it has a problem to preform on multile files. It does the task on one file and the rest goes bad.
(defun c:purgeall ()
(dictremove (namedobjdict) "ACAD_DGNLINESTYLECOMP")
(command "-purge" "all" "" "n")
(command "-purge" "r" "" "n")
(command "qsave")
)
Second thing is that I would like to do a XRCOL.lsp - (return selected xref to original color and layer state) in a batch, but the problem is that it ask to manually select xref... I is possible to insert a line or to and tell hin to selects all layers, or all layers with A_T4 in file name....?
; XRCOL.LSP
; Return selected xref to original color
(defun c:xrcol (/ ent xdwgname choose)
(while (= ent nil)
(setq ent (entsel "\nSelect Xref"))
(if (= (cdr (assoc 0 (entget (car ent)))) "INSERT")
(progn
(setq xdwgname (cdr (assoc 2 (entget (car ent)))))
(setvar "visretain" 0)
(command "-xref" "r" xdwgname)
(princ (strcat "\nFile " xdwgname " reloaded"))
(setvar "visretain" 1)
)
(progn
(princ "\nSelect entity is not an XREF")
(setq ent nil)
)
)
)
(princ)
)
Help would ne much appreciated.
Ciao
Jan
Solved! Go to Solution.
Solved by Moshe-A. Go to Solution.
Jan Hi,
firstly in AutoCAD (old) script terms format ENTER should be an empty line but i do not see that you need to put enter
so the correction to your script code is as follows:-
1> PSLTSCALE 0
2> PURGEALL
3> CLOSE
on line '1>' there is one character space, in script terms format each space is like pressing spacebar on the KB
just out of curiosity why set psltscale to 0? it better be 1 always.
secondly you could reload all xrefs like that:-
(defun c:XRR ()
(setvar "visretain" 0)
(command ".xref" "reload" "*") ; "*" means all xrefs
(setvar "visretain" 1)
(princ)
)
cheers
Moshe
Moshe,
Thanks a lot. I have made modifications and it all works as a charm. Also thanks for XRR, it does what it should.
I am slowly getting in logic of scripting and lisps and I cant wait to start producing it. It seems like great deal of tasks we are doing in office can be automatized 🙂 I just hope that we dont become redundant 🙂
Cheers
Jan