- (defun c:test( / ss i ent ents pt blkname blk_lst)
- (setq ss (ssget "x" '((0 . "INSERT"))))
- (setq i 0)
- (repeat (sslength ss)
- (setq ent (ssname ss i))
- (setq ents (entget ent))
- (setq blkname (cdr (assoc 2 ents)))
- (if (not (assoc blkname blk_lst))
- (progn
- (setq pt (cdr (assoc 10 (tblsearch "BLOCK" blkname))))
- (setq blk_lst (append blk_lst (list (list blkname pt))))
- )
- )
- (setq i (1+ i))
- )
- (mapcar 'Getent (mapcar 'car blk_lst) (mapcar 'cadr blk_lst))
- (princ)
- )
- (defun Getent(blkname pt / ent ent_lst)
- (setq ent (tblobjname "BLOCK" blkname))
- (while (setq ent (entnext ent))
- (setq ent_lst (append ent_lst (list ent)))
- )
- (Makeblk ent_lst pt blkName)
- )
- (defun Makeblk(ent_lst pt blkName)
- (entmake (list
- '(0 . "BLOCK")
- (cons 2 blkname)
- '(70 . 0)
- (cons 10 pt)))
- (mapcar '(lambda(e) (entmake (entget e))) ent_lst)
- (entmake '((0 . "ENDBLK")))
- )
|