Hi friends,
I wanted to do a different lsp work to count blocks. But I have a problem with listing. Tell me what I want to do;
I can count the blocks of the same name, find out how many of them are. I want to create a separate selection set for each block so that I can find the block insert point that belongs to each block. I see this insert point with dxf codes. But I have to make a selection set list. Every block counted on the list is first, second, third.
I will write to the block insert point with the text command. So I need to create a list and find the block insert point for each block.
Can you help me create a list for selected / counted blocks?
My counting lisp code :
;; Block counting add-on for Autocad.
;; According to the block name, the number of blocks in the drawing is determined.
;; For the user, the counted block name and the number of blocks are reported.
(defun c:blkcnt (/ blkselect entitylist blkname blkssget blkcount)
(setq blkselect (car (entsel "\n Select Block to be counted :"))) ;; <Entity name: 7ff7b7e97b80>
(setq entitylist (entget blkselect)) ;; Entity listed in all
(setq blkname (cdr(assoc 2 entitylist))) ;; Block name shown
(if blkname
(progn
(setq blkssget (ssget "X" (list (cons 2 blkname))))
(if blkssget
(setq blkcount (sslength blkssget))
)
(cond ( (> blkcount 1)
(alert (strcat "\n Block name : " (strcase blkname) " from " "\n Total :" " " (itoa blkcount) " There are pieces !")) )
( (= blkcount 1)O
(alert (strcat "\n Block name : " (strcase blkname) " Only 1 piece available !")))
( t
(alert (strcat "\n Block name : " (strcase blkname) " No have block with this name !!! ")))
)
)
)
(princ)
)
Sample coding for block insertpoint :
(setq blkselect (car (entsel "\n Select a block :"))) ;; <Entity name: 7ff7b7e97b80>
(setq entitylist (entget blkselect)) ;; Entity listed in all
(setq blkpoint1 (cdr (assoc 10 entitylist)) ) ;; İnsert poit ;; (115.982 59.3608 0.0)
(setq blkname (cdr(assoc 2 entitylist))) ;; Block name
;; To get the insertion point of the block :
;; (setq blkpoint (cdr (assoc 10 entitylist)) )
;; To get the name of the block :
;; (cdr(assoc 2 entitylist))