andy_06 Posted 13 hours ago Posted 13 hours ago Hi, I am looking for some help with regards to a lisp routine. I have a scenario where I need to select multiple blocks (all named 'Service Connection') and then explode them. I currently do this using Qselect and then manually explode but wonder there is a way to do all of this in one lisp routine to speed up the process? Thank you! Quote
GLAVCVS Posted 9 hours ago Posted 9 hours ago Try this (defun c:myExplode (/ conj n ent lstent nmBlq para) (while (not para) (if (setq ent (car (entsel "\nSelect a sample of blocks to explode..."))) (if (= (cdr (assoc 0 (setq lstent (entget ent)))) "INSERT") (setq nmBlq (cdr (assoc 2 lstent)) para T ) (princ "\n*** SELECTED OBJECT IS NOT A BLOCK ***\Please, try again..." ) ) (princ "\n*** NOTHING SELECTED ***\Please, try again..." ) ) ) (setq n 0) (if nmBlq (if (setq conj (ssget "x" (list (cons 0 "INSERT") (cons 2 nmBlq)))) (WHILE (SETQ ent (SSNAME conj n)) (setq lstent (entget ent) n (+ n 1) ) (vla-explode (vlax-ename->vla-object ent)) ) ) ) (princ) ) Quote
andy_06 Posted 9 hours ago Author Posted 9 hours ago 13 minutes ago, GLAVCVS said: Try this (defun c:myExplode (/ conj n ent lstent nmBlq para) (while (not para) (if (setq ent (car (entsel "\nSelect a sample of blocks to explode..."))) (if (= (cdr (assoc 0 (setq lstent (entget ent)))) "INSERT") (setq nmBlq (cdr (assoc 2 lstent)) para T ) (princ "\n*** SELECTED OBJECT IS NOT A BLOCK ***\Please, try again..." ) ) (princ "\n*** NOTHING SELECTED ***\Please, try again..." ) ) ) (setq n 0) (if nmBlq (if (setq conj (ssget "x" (list (cons 0 "INSERT") (cons 2 nmBlq)))) (WHILE (SETQ ent (SSNAME conj n)) (setq lstent (entget ent) n (+ n 1) ) (vla-explode (vlax-ename->vla-object ent)) ) ) ) (princ) ) That is perfect, thank you so much! Quote
andy_06 Posted 8 hours ago Author Posted 8 hours ago I have been testing this and it works great for a standard block but I also have a scenario where I have some dynamic blocks and it doesn't seem to work for those. Is there a way to include dynamic blocks as well? Quote
LanloyLisp Posted 5 hours ago Posted 5 hours ago (defun c:myExplode (/ conj n ent lstent nmBlq para) (while (not para) (if (setq ent (car (entsel "\nSelect a sample of blocks to explode..."))) (if (= (cdr (assoc 0 (setq lstent (entget ent)))) "INSERT") (setq v (vlax-ename->vla-object ent) ;; nmBlq (cdr (assoc 2 lstent)) nmBlq (vla-get-effectivename v) para T ) (princ "\n*** SELECTED OBJECT IS NOT A BLOCK ***\Please, try again..." ) ) (princ "\n*** NOTHING SELECTED ***\Please, try again..." ) ) )(print (strcat nmBlq ",`*U*")) (setq n 0) (if nmBlq (if (setq conj (ssget "x" (list (cons 0 "INSERT") (cons 2 (strcat nmBlq ",`*U*"))))) (WHILE (SETQ ent (SSNAME conj n)) (setq v (vlax-ename->vla-object ent) lstent (entget ent) n (+ n 1) ) (if (eq (vla-get-effectivename v) nmBlq) (vla-explode v) ) ) ) ) (princ) ) Hi Andy, check the above code, few edits from GLAV's original code. Quote
Lee Mac Posted 4 hours ago Posted 4 hours ago Note that (vla-explode) creates an exploded copy, the original reference will still exist. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.