Author Topic: Unique Block Names  (Read 4741 times)

0 Members and 1 Guest are viewing this topic.

deegeecees

  • Guest
Re: Unique Block Names
« Reply #15 on: October 31, 2006, 07:40:58 PM »
Sorry, had another job interview. You guys are quite kind, thankyou.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10388
Re: Unique Block Names
« Reply #16 on: October 31, 2006, 10:39:38 PM »
Peter, I think you code is great & looking for another way to deal with the dynamic block names, I could only offer a variation of your method.
I suspect this version would be slower with a large number of blocks.
Code: [Select]
;;  a variant to include dynamic blocks
;;  retrurns only block names that have one block only in the dwg
(defun c:blkunique2 (/ ss lst itm result)
  (and
    (setq ss (ssget "x" (list (cons 0 "INSERT"))))
    (setq lst (mapcar '(lambda (x)
                   (if (vlax-property-available-p x 'EffectiveName)
                     (vla-get-EffectiveName x)
                     (vla-get-Name x)
                   ))
          (mapcar 'vlax-ename->vla-object (mapcar 'cadr (ssnamex ss))))
    )
    (while (setq itm (car lst))
      (setq len    (length lst)
            lst    (vl-remove itm lst)
            cnt    (- len (length lst))
      )
      (if (= cnt 1)
        (setq result (cons itm result)))
    )
  )
  (vl-sort result '<)
)
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.