Author Topic: Dynamic Blocks Only Selection Set.  (Read 8759 times)

0 Members and 1 Guest are viewing this topic.

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Re: Dynamic Blocks Only Selection Set.
« Reply #15 on: May 11, 2006, 06:16:25 PM »
There was supposed to be an "apologies to Jeff / All" in that post.
No need for that, MP. I enjoy examining your code samples, whether completely applicable or not. :-D

CAB, in a drawing with 1000's of inserts and only a few of them DynamicBlocks yours may give a significant performance hit. So a combination of yours and MP's (with the addition of blocks named "`*U*") to select ONLY DynamicBlocks and Anonymous blocks should be somewhat quicker.

Another approach might be to use 2 selection sets, one with only unmodified DynamicBlocks (they still have their name intact) and a second ss of just anonymous blocks that can be checked for IsDynamic and add it to the first if it is.

In fact, I just got pulled off my current project due to some "minor revisions coming down" so I'll go do a bit of testing.

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Re: Dynamic Blocks Only Selection Set.
« Reply #16 on: May 11, 2006, 07:43:19 PM »
Well, I don't have a drawing handy with a number of Dynamicblocks, both altered & unaltered, with a mix of standard blocks, so I can't properly test this at the moment. But here are the two methods I described previously.

Code: [Select]
(defun ssDynBlk1 (/ ent fltrlist fltrstring idx ss)
  (setq fltrstring "`*U*")
  (vlax-for x (vla-get-blocks
(vla-get-activedocument
   (vlax-get-acad-object)))
    (if (and (eq (vla-get-IsLayout x) :vlax-false)
     (eq (vla-get-IsDynamicBlock x) :vlax-true)
     )
      (setq fltrstring (strcat fltrstring "," (vla-get-name x)))
      )
    ) 
  (if (setq ss (ssget "x" (list '(0 . "INSERT") (cons 2 fltrstring))))
    (progn
      (setq idx 0)
      (while (setq ent (ssname ss idx))
(if (eq (vla-get-isdynamicblock (vlax-ename->vla-object ent)) :vlax-false)
  (ssdel ent ss)
  (setq idx (1+ idx))
  )
)
      )
    )
  ss
  )

(defun ssDynBlk2 (/ ent fltrlist fltrstring idx ss1 ss2)
  (vlax-for x (vla-get-blocks
(vla-get-activedocument
   (vlax-get-acad-object)))
    (if (and (eq (vla-get-IsLayout x) :vlax-false)
     (eq (vla-get-IsDynamicBlock x) :vlax-true)
     )
      (if (not fltrstring)
(setq fltrstring (vla-get-name x))
(setq fltrstring (strcat fltrstring "," (vla-get-name x)))
)
      )
    )
  (if fltrstring
    (setq ss1 (ssget "x" (list '(0 . "INSERT") (cons 2 fltrstring))))
    )
  (or ss1
      (setq ss1 (ssadd))
      )
  (if (setq ss2 (ssget "x" (list '(0 . "INSERT") (cons 2 "`*U*"))))
    (progn
      (while (setq ent (ssname ss2 0))
(if (eq (vla-get-isdynamicblock (vlax-ename->vla-object ent)) :vlax-true)
  (ssadd ent ss1)
  )
(ssdel ent ss2)
)
      )
    )
  ss1
  )