Jump to content

please? blocks


bonacad

Recommended Posts

yeah, but i dont want to select object.

 

i have for example this:

 

Command: (setq [b]my-block[/b] (entget (entlast)))
((-1 . <Entity name: 7ef9e050>) (0 . "INSERT") (330 . <Entity name: 7ef65cf8>) 
(5 . "BA") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 . 
"AcDbBlockReference") (2 . "test") (10 3.38842 8.55032 0.0) (41 . 1.0) (42 . 
1.0) (43 . 1.0) (50 . 0.0) (70 . 0) (71 . 0) (44 . 0.0) (45 . 0.0) (210 0.0 0.0 
1.0))

how do i retreve list of all Entity names in my-block?

Link to comment
Share on other sites

Every Block Reference contains the same entities set. You need to extract the Block Definition from BLOCK table and use ENTNEXT function to find all nested entities:

 

(defun GetEntitiesList(Name / blLst cEnt oLst)
 (if(setq blLst(tblsearch "BLOCK" Name))
   (progn
     (if(setq cEnt(cdr(assoc -2 blLst)))
(progn
  (setq oLst(list cEnt))
  (while(setq cEnt(entnext cEnt))
    (setq oLst(cons cEnt oLst))
    ); end while
  ); end progn
); end if
     ); end progn
   ); end if
 oLst
 ); end of GetEntitiesList

 

Example of usage:

 

Command: (GetEntitiesList "01-06-Adr_Isolator")
(<Entity name: 7efe2508> <Entity name: 7efe2500> <Entity name: 7efe24f8> 
<Entity name: 7efe24f0> <Entity name: 7efe24e8> <Entity name: 7efe24e0> <Entity 
name: 7efe24d8> <Entity name: 7efe24d0> <Entity name: 7efe24c8> <Entity name: 
7efe24c0> <Entity name: 7efe24b8>)

Link to comment
Share on other sites

i have made adjustments to my needs.

ename instead blkname for arg.

function gives me back just text entities from block.

 

(DEFUN
  txtlstfromblk (ename / c txtl bllst cent olst tmp)
(IF (SETQ bllst (TBLSEARCH "BLOCK" (CDR (ASSOC 2 (ENTGET ename)))))
 (PROGN
  (IF (SETQ cent (CDR (ASSOC -2 bllst)))
   (PROGN
    (SETQ olst (LIST cent))
    (WHILE (SETQ cent (ENTNEXT cent)) (SETQ olst (CONS cent olst)))
    ) ;_ endPROGN
   ) ;_ endIF
  ) ;_ endPROGN
 ) ;_ endIF
(SETQ c (LENGTH olst))
(WHILE (>= (SETQ c (1- c)) 0)
 (SETQ
  text?
  (CDR (ASSOC 0 (ENTGET (SETQ tmp (CAR olst)))))
  olst
  (CDR olst)
  ) ;_ endSETQ
 (IF (= text? "TEXT")
  (SETQ txtl (APPEND txtl (SETQ txtl (LIST tmp))))
  ) ;_ endIF
 ) ;_ endWHILE
txtl
) ;_ endDEFUN

for

Command: (setq my-block (entlast))

 

function call (txtlstfromblk my-block)

 

Replacing (= text? "TEXT") with another type, can be used for

retrieving other entity types.

 

---

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...