TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: PPETROS on January 18, 2023, 05:59:46 AM
-
Hello, everyone!
I am trying to adjust the following lisp in order to select (multiple) both blocks and dynamic blocks at once based on their name, by previewing the selection.
I am doing something wrong.
Can anyone help me by fixing the code?
Thank you in advance.
-
;;THIS IS THE CODE
(defun C:sblks (/ e ss sss obj blk blkl) ; multiple
(setq blkl "" sss (ssadd))
(while
(setq obj (vlax-ename->vla-object (Car (entsel))))
(setq e (vla-get-effectivename obj))
(setq blkl (strcat blkl "," e))
(princ (substr blkl 2))
);while
(if (setq ss (ssget "_X" '((0 . "INSERT"))))
(progn
(repeat (setq i (sslength ss))
(setq name (strcase (vla-get-effectivename (vlax-ename->vla-object (setq blk (ssname ss (setq i (1- i))))))))
(if (wcmatch name (strcase e))
(ssadd blk blkl)))
(if (zerop (getvar "CMDACTIVE"))
(progn (sssetfirst nil blkl)
(princ "Use 'P' for this selection set: ")(princ))
blkl)))
)
-
Don't think this will work on dynamic blocks since they are stored as anonymous blocks?
(defun C:sblks
(/ ss blklst
) ; multiple )
)
)
)
-
First of all, I would like to thank you very much for your help.
I tested your code and indeed it does not work with the dynamic block.
I need a lisp that selects both dynamic and normal blocks, by previewing the selection and adding them in a desired list.
Consider the name of blocks as the effectivename.
I really appreciate your effort.
-
(defun C:sblks
(/ ss ss1 name lst
) ; multiple )
)
)
)
)
)
)
-
Mate, I have tested the lisp file and it works fine.
Very good work.
Thank you very much for your help.