entity in blocks

Discussion in 'AutoCAD' started by M_Dobek, Jan 4, 2005.

  1. M_Dobek

    M_Dobek Guest

    Hi everyone,

    In my drawing I've got a lot of blocks
    Some blocks have a circle (0.5 radius) and I need to count all circles.

    Maybe someone have a lisp that he can count entity (circle) in blocks?

    any help will be greatfull,
    Marcin_D
     
    M_Dobek, Jan 4, 2005
    #1
  2. M_Dobek

    LUCAS Guest

    ;;not for nested blk
    (defun C:TT (/ BLK COUNT SS)
    (setq BLK (car (entsel)))
    (command "_.explode" BLK)
    (if (setq SS (ssget "p" '((0 . "circle"))))
    (setq COUNT (sslength SS))
    (setq COUNT 0)
    )
    (command "_.undo" "1")
    COUNT
    )
     
    LUCAS, Jan 4, 2005
    #2
  3. M_Dobek

    LUCAS Guest

    ;;not for nested blk
    (defun C:TTT (/ BLK COUNT ENT)
    (vl-load-com)
    (setq BLK (car (entsel))
    COUNT 0
    )
    (vlax-for ENT
    (vla-item (vla-get-blocks
    (vla-get-activedocument (vlax-get-acad-object))
    )
    (vla-get-name (vlax-ename->vla-object BLK))
    )
    (if (= (vla-get-objectname ENT) "AcDbCircle")
    (setq COUNT (1+ COUNT))
    )
    )
    COUNT
    )
     
    LUCAS, Jan 4, 2005
    #3
  4. M_Dobek

    LUCAS Guest

    ;;For nested blk
    (defun C:TTTT (/ BLK BLKS COUNT ENT)
    (vl-load-com)

    (defun DO_IT ()
    (cond
    ((= (vla-get-objectname ENT) "AcDbCircle")
    (setq COUNT (1+ COUNT))
    )
    ((= (vla-get-objectname ENT) "AcDbBlockReference")
    (TTT1 ENT)
    )
    )
    )

    (defun TTT1 (BLK / ENT)
    (vlax-for ENT (vla-item BLKS (vla-get-name BLK))
    (DO_IT)
    )
    )

    (setq BLK (car (entsel "\nSelect Block: "))
    COUNT 0
    BLKS (vla-get-blocks
    (vla-get-activedocument (vlax-get-acad-object))
    )
    )
    (vlax-for ENT
    (vla-item BLKS (vla-get-name (vlax-ename->vla-object BLK)))
    (DO_IT)
    )
    (vlax-release-object BLKS)
    COUNT
    )
     
    LUCAS, Jan 4, 2005
    #4
  5. M_Dobek

    Adesu Guest

    Hi M_Dobek,try this

    ; co is stand for count object
    ; Design by Ade Suharna <>
    ; 4 January 2005
    ; Program no.156/01/2005
    ; Edit by
    (defun c:co (/ ob ss n)
    (while
    (setq ob (strcase (getstring T "\nENTER NAME OBJECT: ")))
    (setq ss (ssget "x" (list (cons 0 ob))))
    (setq n (sslength ss))
    (alert (strcat "\nTOTAL" " " ob " " "=" ( rtos n 2 0)))
    (princ)
    )
    )
     
    Adesu, Jan 4, 2005
    #5
  6. M_Dobek

    LUCAS Guest

    ;;For nested blk
    ;;(tttt <objectname>)
    ;;(tttt "AcDbCircle")
    ;;By LUCAS

    (defun TTTT (OBJECTNAME / BLK BLKS COUNT ENT)
    (vl-load-com)

    (defun TTT1 (BLK / ENT)
    (vlax-for ENT (vla-item BLKS (vla-get-name BLK))
    (cond
    ((= (vla-get-objectname ENT) OBJECTNAME)
    (setq COUNT (1+ COUNT))
    )
    ((= (vla-get-objectname ENT) "AcDbBlockReference")
    (TTT1 ENT)
    )
    )
    )
    )

    (setq BLK (car (entsel "\nSelect Block: "))
    COUNT 0
    BLKS (vla-get-blocks
    (vla-get-activedocument (vlax-get-acad-object))
    )
    BLK (vlax-ename->vla-object BLK)
    )
    (TTT1 BLK)
    (vlax-release-object BLKS)
    COUNT
    )
     
    LUCAS, Jan 4, 2005
    #6
  7. M_Dobek

    M_Dobek Guest

    This is what I need
    It works great!

    Thanks LUCAS

    Marcin_D
     
    M_Dobek, Jan 4, 2005
    #7
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.