Author Topic: Dynamic Block SSGET  (Read 15 times)

0 Members and 1 Guest are viewing this topic.

CADDOG

  • Newt
  • Posts: 83
  • wishbonesr
Dynamic Block SSGET
« on: Today at 12:02:49 AM »
Hey All (it's been a while),
Wondering if you had any ideas around using the standard ssget with filter for anonymous blocks.  I was so sure this would work, but selecting anonymous blocks with ssget always dumps:

Code: [Select]
Select objects: Specify opposite corner: 0 found, 0 total
I feed ssget filter <OR> around some regular block names, and wasn't able to select an anonymous block.  So I figured I needed to get all possible anonymous blocks names from the drawing that have an effectivename match and build the filter with them, but still am not able to select an anonymous block using ssget w/ filter.

Filter looks like:

Code: [Select]
((0 . "INSERT") (66 . 1) (-4 . "<or") (2 . "BORD-A") (2 . "iso") (2 . "ISO_BORDER_2") (2 . "IsoBorder_Bridle") (2 . "SHOP_BORDER") (2 . "LOCID") (2 . "*U1099") (2 . "*U1383") (2 . "*U1099") (2 . "*U1099") (-4 . "or>"))
It's a petty (traditional) reason to want this particular behavior where a count of objects is tallied during selection, and where only valid choices are highlighted, but none-the-less, it is preferred.

Function to get anonymous blocks names:

Code: [Select]
  (defun cd:getanonymousblocknames (blocks doc
    /
    allblocks
    layout
    ent
    )
    (setq allblocks blocks)
    (setq layout (vla-get-activelayout doc))
    (vlax-for ent (vla-get-block layout)
      (if (and (= "AcDbBlockReference" (vla-get-objectname ent))
       (setq blockname (vla-get-effectivename ent))
       (vl-some (function (lambda (x) (= (strcase x) (strcase blockname)))) blocks))
(setq allblocks (append allblocks (list (vla-get-name ent))))
)
      )
    allblocks
    )

Example Caller:

Code: [Select]
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(setq blocks '("BORD-A" "iso" "ISO_BORDER_2" "IsoBorder_Bridle" "SHOP_BORDER" "LOCID"))
(setq blocks (cd:getanonymousblocknames blocks doc))
(setq filter '((0 . "INSERT")(66 . 1)(-4 . "<or")))
(setq filter (append filter
       (mapcar
(function (lambda (block)
     (cons 2 block)))
blocks)))
(setq filter (append filter (list (cons 2 block))))
(setq ss (ssget filter))

btw - I know I can reduce the filter to '((0 . "INSERT")(66 . 1)), allow selection filtering to this this limited level and then build my own SS to filter further, but that will be last resort.  I really want the filtering to be real time though.