I have a lisp that I've been working on that runs multiple COD scripts on an object during the routine but I have to keep selecting the object after each executescript. I've worked around this by using pselect repeatedly throughout the lisp. I want it to work on a per object basis after selecting more than one object. It works great if everything you select needs the same information, but if I need to pull/push back different information it doesnt. It just pulls the info from the last item selected and gives them all that information.
I've tried using selection sets but because it deselects after each executescript, I just can't figure it out.
(defun c:replacevavtags(/ *error*)
;;error handling
(defun *error* (msg)
(and *AcadDoc* (vla-endundomark *AcadDoc*))
(if (and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*QUIT*,")))
(princ (strcat "\nError: " msg))
)
(close nfile)
(close ofile)
(close j)
)
(setq size (getvar 'textsize))
;; set object and get layer name
(setq e (ssname (ssget) 0))
(setq vlaobj (vlax-ename->vla-object e))
(setq layername (vlax-get-property vlaobj 'layer))
;; end set
(COMMAND "PSELECT" "P" "")
(executescript "X:/Design Aids/scripts/cdback.cod")
(COMMAND "PSELECT" "P" "")
(setq
ofile (open "c:\\text files\\textw.txt" "r")
nfile (open "c:\\text files\\textn.txt" "w")
j (open "c:\\text files\\textr.txt" "w")
)
;; start count of lines (ignores empty lines)
(setq count 1)
(while (setq aline (read-line ofile))
(if (/= aline "")
(setq count (1+ count))
)
)
(setq Nu1 (itoa count))
(write-line NU1 j)
(setq count (1- count))
(close j)
;; end count of lines
;; start ask if replace or not
(initget "Y N _Y N")
(setq option (getkword "\nDo you want to change the tag? (Y/N): "))
(cond ((= option "Y")
;; start replace text
(initget "Y N _Y N")
(setq option (getkword "\nDo you want to change the number of lines? (Y/N): "))
(cond ((= option "Y")
(progn
(cond
((= (wcmatch layername "*EQPM*") T)
(progn
(while
(and
(progn
(initget 6)
(setq count2 (getint "\How many lines for EQ tag? (1 - 4)"))
(setq count count2)
)
(not (wcmatch (itoa count2) "[1-4]"))
)
(princ "\nCan't be less than 1 or more than 4.")
))
)
(t
(progn
(while
(and
(progn
(initget 6)
(setq count2 (getint "\How many lines for tag? (1 - 5)"))
(setq count count2)
)
(not (wcmatch (itoa count2) "[1-5]"))
)
(princ "\nCan't be less than 1 or more than 5.")
))
)
)
)
)
((= option "N") (setq count2 count))
)
(vl-file-delete "c:\\text files\\textr.txt")
(setq j (open "c:\\text files\\textr.txt" "w"))
(setq count count2)
(setq count3 (1+ count))
(setq Nu1 (itoa count3))
(write-line NU1 j)
(while (>= count3 2)
(/= (setq inpNew (getstring t "\nEnter new line: ")) "")
(write-line inpNew nfile)
(setq count3 (1- count3))
)
(close nfile)
(close ofile)
(close j)
;; end replace text
)
)
;; start replace vav tag
(vl-file-delete "c:\\text files\\textw.txt")
(vl-file-rename "c:\\text files\\textn.txt" "c:\\text files\\textw.txt")
(command "removectext")
(COMMAND "PSELECT" "P" "")
(executescript "X:/Design Aids/scripts/entry.cod")
(COMMAND "PSELECT" "P" "")
(setq k (open "c:\\text files\\textr.txt" "r"))
(setq l (read-line k))
(COMMAND "PSELECT" "P" "")
(cond
((= size 4.0)
(prompt "\n Textsize is 1/4")
(cond
((= (wcmatch layername "*EQPM*") T)
(progn
(if (= l "5") (ctext "term5"))
(if (= l "4") (ctext "term4"))
(if (= l "3") (ctext "term3"))
(if (= l "2") (ctext "term2"))
(if (= l "1") (ctext "term1"))
))
(t
(if (= l "6") (ctext "entry5"))
(if (= l "5") (ctext "entry4"))
(if (= l "4") (ctext "entry3"))
(if (= l "3") (ctext "entry2"))
(if (= l "2") (ctext "entry1"))
)
)
)
((= size 8.0)
(prompt "\n Textsize is 1/8")
(cond
((= (wcmatch layername "*EQPM*") T)
(progn
(if (= l "5") (ctext "96term5"))
(if (= l "4") (ctext "96term4"))
(if (= l "3") (ctext "96term3"))
(if (= l "2") (ctext "96term2"))
(if (= l "1") (ctext "96term1"))
))
(t
(if (= l "6") (ctext "96entry5"))
(if (= l "5") (ctext "96entry4"))
(if (= l "4") (ctext "96entry3"))
(if (= l "3") (ctext "96entry2"))
(if (= l "2") (ctext "96entry1"))
)
)
)
(T (prompt "\nNeither 1/4 nor 1/8 Scale"))
);cond
(settext(ssget)64"on")
(close k)
(close nfile)
(close ofile)
(close j)
(close fn)
;; end replace vav tag
;; clean up folder
(vl-file-delete "c:\\text files\\textw.txt")
(vl-file-delete "c:\\text files\\textr.txt")
;; end clean up folder
(princ)
)