Hi everyone,
I found this great LiSP by Lee Mac, it does exactly what I am looking for but I would like to modify it to use in a larger LiSP that I am writing. I looking to have the LiSP select ALL blocks without prompting the user to select anything and then run the LiSP as it normally would. I have been playing with it and got it to work... sort of... With the modification below I can get it to select all the blocks and run but the command will produce this: "*Invalid selection* Expects a point or Last/ALL/Group" a couple of times and then ask to select object again. But it DOES burst all the blocks in the entire drawing in model and all layout tabs. I just need to get it to stop producing that error and to not ask for selection again after running.
The full LiSP is attached for reference.
I hope I made sense. Thank you in advance.
Original code by Lee Mac:
Code:
(defun c:nburst ( / *error* idx sel )
(defun *error* ( msg )
(LM:endundo (LM:acdoc))
(if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))
(princ (strcat "\nError: " msg))
)
(princ)
)
(LM:startundo (LM:acdoc))
(if
(setq sel
(LM:ssget "\nSelect blocks to burst: "
(list "_:L"
(append '((0 . "INSERT"))
(
(lambda ( / def lst )
(while (setq def (tblnext "block" (null def)))
(if (= 4 (logand 4 (cdr (assoc 70 def))))
(setq lst (vl-list* "," (cdr (assoc 2 def)) lst))
)
)
(if lst (list '(-4 . "<NOT") (cons 2 (apply 'strcat (cdr lst))) '(-4 . "NOT>")))
)
)
(if (= 1 (getvar 'cvport))
(list (cons 410 (getvar 'ctab)))
'((410 . "Model"))
)
)
)
)
)
(repeat (setq idx (sslength sel))
(LM:burstnested (vlax-ename->vla-object (ssname sel (setq idx (1- idx)))))
)
)
(LM:endundo (LM:acdoc))
(princ)
)
;; Burst Nested - Lee Mac
;; Bursts the supplied block & all nested blocks found within.
;; obj - [vla] VLA Block Reference Object
(defun LM:burstnested ( obj / cmd col ent lay lin lst qaf tmp )
(if
(and
(= "AcDbBlockReference" (vla-get-objectname obj))
(vlax-write-enabled-p obj)
(or (and (LM:usbl ... (Code continues...)
Section I modified to select all and that sort of works:
Code:
(defun c:nburst ( / *error* idx sel )
(defun *error* ( msg )
(LM:endundo (LM:acdoc))
(if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))
(princ (strcat "\nError: " msg))
)
(princ)
)
(LM:startundo (LM:acdoc))
(if
(setq sel
(ssget "_X" (list (cons 0 "INSERT")))
)
(repeat (setq idx (sslength sel))
(LM:burstnested (vlax-ename->vla-object (ssname sel (setq idx (1- idx)))))
)
)
(LM:endundo (LM:acdoc))
(princ)
)
;; Burst Nested - Lee Mac
;; Bursts the supplied block & all nested blocks found within.
;; obj - [vla] VLA Block Reference Object
(defun LM:burstnested ( obj / cmd col ent lay lin lst qaf tmp )
(if
(and
(= "AcDbBlockReference" (vla-get-objectname obj))
(vlax-write-enabled-p obj)
(or (and (LM:usbl .... (Code continues...)