j2lstaples Posted September 11, 2023 Posted September 11, 2023 Hi guys, is there any way for me to save the (pburst) primary burst selection to a list and then unburst it? I want to be able to extract something from the nested blocks inside of my dynamic blocks without messing with the dynamic block themselves. If Lee Mac can answer that would be helpful as well. Quote
Steven P Posted September 12, 2023 Posted September 12, 2023 Can you post an example what you are wanting to do? Quote
j2lstaples Posted September 12, 2023 Author Posted September 12, 2023 In Lee Mac's burst, there's two versions, pburst and nburst, pburst only 'explodes' the dynamic block once to get the subsequent nested blocks and 'preserves' the locations of the blocks. Suppose BLOCKA is composed of BLOCKB, BLOCKC, and BLOCKD, (these are the effectivenames), how can I not explode/burst BLOCKA but still get the information of BLOCKB, BLOCKC, and BLOCKD? PBURST requires a selection and then basically explodes the block and then you can't really put it back together while getting information, even getting the entity names of them would suffice. I don't really have blocks to work with currently, my job doesn't allow me to share the blocks. I apologize in advance and thanks for the help. Quote
Steven P Posted September 12, 2023 Posted September 12, 2023 could be tricky without an image of what needs to be done, what are you trying to extract or copy? Quote
j2lstaples Posted September 12, 2023 Author Posted September 12, 2023 Just now, Steven P said: could be tricky without an image of what needs to be done, what are you trying to extract or copy? just the entity names of the nested blocks to be honest. Quote
Steven P Posted September 12, 2023 Posted September 12, 2023 Can you do anything with nentsel ? All I am thinking that bursting the blocks, grabbing the information you want, putting them back together again is a long way around. Would something like this work? Should select something within the the block where the mouse is clicked (defun c:tt ( / MySelection MyEnt) (setq MySelection (nentselp "Select")) (setq MyEnt (car MySelection)) (entget MyEnt) ) Quote
BIGAL Posted September 12, 2023 Posted September 12, 2023 Now where is that code get names of nested blocks. It exists. Try this, I forget where I found it, apology to author. (defun BlkNameN (/ blksel blkobj) (setq blksel (nentsel "\nSelect Block or nested Block: ") blkobj (vlax-ename->vla-object (car (last blksel))) ) (prompt (strcat "\nBlock name is: " (vlax-get-property blkobj (if (vlax-property-available-p blkobj 'effectivename) 'effectivename 'name)) ) ) (princ) ) (BlkNameN) Quote
exceed Posted September 13, 2023 Posted September 13, 2023 8 hours ago, j2lstaples said: just the entity names of the nested blocks to be honest. http://lee-mac.com/nestedblockcounter.html you can do that with this routine. 1 hour ago, BIGAL said: Try this, I forget where I found it, apology to author. https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-get-name-of-a-nested-block/m-p/4656869/highlight/true#M317342 maybe this link Quote
j2lstaples Posted September 25, 2023 Author Posted September 25, 2023 so typically I can get the first subentity using: (setq en1 (nentselp (cadr (entsel)))) since it uses the insertion point of the (nested) entity and shows the first subentity, and then using: (setq subent1 (LM:al-effectivename (car (caddr (cdr en1))))) So, I get the first subentity name. Even just getting the (car (caddr (cdr en1))) is also already useful. Quote
Lee Mac Posted September 25, 2023 Posted September 25, 2023 You can use nentsel directly in place of entsel, rather than performing two selections. Quote
j2lstaples Posted September 25, 2023 Author Posted September 25, 2023 1 minute ago, Lee Mac said: You can use nentsel directly in place of entsel, rather than performing two selections. Yes, I even used nentselp to supply a point instead of a user input. I just wanted to be able to figure out all the entity names of the subentities inside of the block like what you did on Nested Block Counter but I only need the entity names not the effective names. Quote
Lee Mac Posted September 25, 2023 Posted September 25, 2023 If you already know the target block definition, you can obtain the AcDbBlockBegin (BLOCK) entity using tblobjname and then iterate over the component entities using the entnext function until it returns nil (at which point it has reached the AcDbBlockEnd (ENDBLK) entity). Quote
j2lstaples Posted September 27, 2023 Author Posted September 27, 2023 After a few days of going back and forth with AI, we've come up with a way to list the entity name and translated insertion point of the sub-entities inside a nested block. I'm using a function like this: (defun get-block-entity-info (blk / ent lst rot entloc entlistinfo effname) ;; Define the function, declare local variables (setq entloc (cdr (assoc 10 (entget blk)))) (setq rot (cdr (assoc 50 (entget blk)))) (if ;; If the following returns a non-nil value ;; i.e. if the block exists in the drawing (setq ent (tblobjname "block" (cdr (assoc 2 (entget blk))))) ;; get the BLOCK entity (while (setq ent (entnext ent)) ;; Step through the entities in the block definition (if (= (cdr (assoc 0 (entget ent))) "INSERT") (setq lst (cons ent lst)) (setq lst lst) ) ;; Construct a list of the block components ) ;; end WHILE ) ;; end IF ;(reverse lst) ;; Return the list (setq entlistinfo '()) (foreach item lst (setq entlistinfo (cons (list item ;(LM:al-effectivename item) (mapcar '+ (list (* (distance '(0.0 0.0) (cdr (assoc 10 (entget item))) ) (cos (+ rot (angle '(0.0 0.0) (cdr (assoc 10 (entget item))) ) ) ) ) (* (distance '(0.0 0.0) (cdr (assoc 10 (entget item))) ) (sin (+ rot (angle '(0.0 0.0) (cdr (assoc 10 (entget item))) ) ) ) ) 0.0 ) entloc ) ) entlistinfo ) ) ) entlistinfo ) ;; end DEFUN Thanks for the help @Lee Mac I'm basically using this as a data point for annotating the blocks with another massive auto-leader script that I have. 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.