Search code examples
lispautocadautolisp

Auto Lisp How to select items inside block and get Volume


How to get Volume of 3D Solids inside a Block using Auto Lisp

                                   (setq Teset
                                      (ssget "X"
                                         (list (cons 8 Layerdname));;;;;;;;;;;;;Select the Blocks from the Main Layer
                                      )
                                   )




                                   (setq Tcntr 0)
                                   (setq Ttvm 0)

                                            (setq Ten (ssname Teset 0))
                                            (setq Tvlaobj (vlax-ename->vla-object Ten))

                                            (setq Tobjs (vla-Explode Tvlaobj))
                            ..............Help here Please.............

                                            (princ Tobjs)

                                        (princ)

In this Code adding the items on a layer to selection set and explode the first entity which is a block.

and i need to select all objects in that exploded block (all are 3d Solids) and print the volume

Thanks in Advance


Solution

  • After:

    (setq Tobjs (vla-explode block ) )
    

    You can get volume by:

    (setq ObjectsAsList (vlax-safearray->list (vlax-variant-value Tobjs ) ) )
    (foreach % ObjectsAsList    
        (setq volume (vlax-get-property % 'volume ) )   
        (print volume ) 
    )