Author Topic: confused on the name of ATTDYNBLOCKREF,please help  (Read 9511 times)

0 Members and 1 Guest are viewing this topic.

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: confused on the name of ATTDYNBLOCKREF,please help
« Reply #15 on: March 09, 2011, 02:26:03 AM »
oops my bad
Code: [Select]
(setq ss (ssget "_X" '((0 . "INSERT")(2 . "*U*,qq"))))
Should be
Code: [Select]
(setq ss (ssget "_X" '((0 . "INSERT")(2 . "`*U*,qq"))))or
Code: [Select]
(setq ss (ssget  '((0 . "INSERT")(2 . "`*U*,qq"))))
But anyway, i see you got it figured out

I think the  (2 . "`*U*,qq") would select all dynamic blocks without considering the name of the main block which

is (qq) and which is added to it as a filtration system . :-)

That's what I got while testing it.

snddd2000

  • Guest
Re: confused on the name of ATTDYNBLOCKREF,please help
« Reply #16 on: March 09, 2011, 07:59:58 PM »
oops my bad
Code: [Select]
(setq ss (ssget "_X" '((0 . "INSERT")(2 . "*U*,qq"))))
Should be
Code: [Select]
(setq ss (ssget "_X" '((0 . "INSERT")(2 . "`*U*,qq"))))or
Code: [Select]
(setq ss (ssget  '((0 . "INSERT")(2 . "`*U*,qq"))))
But anyway, i see you got it figured out

I think the  (2 . "`*U*,qq") would select all dynamic blocks without considering the name of the main block which

is (qq) and which is added to it as a filtration system . :-)

That's what I got while testing it.
yes,thank your testing
i found it also.
if this .dwg only have one kind of dynamic block, it is ok.
if not ,as now i am still use fun(if (/= ...)) in code to ssdel the ent.
Do you have better way to filter the block just use ssget?

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: confused on the name of ATTDYNBLOCKREF,please help
« Reply #17 on: March 09, 2011, 08:09:28 PM »
Another method:

Code: [Select]
(defun test ( block )
  (ssget
    (list
      (cons 0 "INSERT")
      (cons 2
        (
          (lambda ( s )
            (foreach anon (LM:AnonymousInstancesof block)
              (setq s (strcat s ",`" anon))
            )
            s
          )
          block
        )
      )
    )
  )
)

(defun LM:AnonymousInstancesof ( block / def rec nme ref lst )
  (while (setq def (tblnext "BLOCK" (null def)))
    (if (= 1 (logand 1 (cdr (assoc 70 def))))
      (progn
        (setq rec
          (entget
            (cdr
              (assoc 330
                (entget
                  (tblobjname "BLOCK" (setq nme (cdr (assoc 2 def))))
                )
              )
            )
          )
        )
        (while (setq ref (assoc 331 rec))
          (if
            (and
              (eq block (vla-get-effectivename (vlax-ename->vla-object (cdr ref))))
              (not (member nme lst))
            )
            (setq lst (cons nme lst))
          )
          (setq rec (cdr (member (assoc 331 rec) rec)))
        )
      )
    )
  )
  (reverse lst)
)

Code: [Select]
(test "qq")

snddd2000

  • Guest
Re: confused on the name of ATTDYNBLOCKREF,please help
« Reply #18 on: March 09, 2011, 09:29:08 PM »
Another method:

Code: [Select]
(defun test ( block )
  (ssget
    (list
      (cons 0 "INSERT")
      (cons 2
        (
          (lambda ( s )
            (foreach anon (LM:AnonymousInstancesof block)
              (setq s (strcat s ",`" anon))
            )
            s
          )
          block
        )
      )
    )
  )
)

(defun LM:AnonymousInstancesof ( block / def rec nme ref lst )
  (while (setq def (tblnext "BLOCK" (null def)))
    (if (= 1 (logand 1 (cdr (assoc 70 def))))
      (progn
        (setq rec
          (entget
            (cdr
              (assoc 330
                (entget
                  (tblobjname "BLOCK" (setq nme (cdr (assoc 2 def))))
                )
              )
            )
          )
        )
        (while (setq ref (assoc 331 rec))
          (if
            (and
              (eq block (vla-get-effectivename (vlax-ename->vla-object (cdr ref))))
              (not (member nme lst))
            )
            (setq lst (cons nme lst))
          )
          (setq rec (cdr (member (assoc 331 rec) rec)))
        )
      )
    )
  )
  (reverse lst)
)

Code: [Select]
(test "qq")
lee Mac
I’ve read a lot of your code at here,
thank your code.

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: confused on the name of ATTDYNBLOCKREF,please help
« Reply #19 on: March 10, 2011, 10:47:53 AM »
You're welcome  :-)

Enjoy  8-)

snddd2000

  • Guest
Re: confused on the name of ATTDYNBLOCKREF,please help
« Reply #20 on: May 31, 2011, 04:36:31 AM »
Another method:

Code: [Select]
(defun test ( block )
  (ssget
    (list
      (cons 0 "INSERT")
      (cons 2
        (
          (lambda ( s )
            (foreach anon (LM:AnonymousInstancesof block)
              (setq s (strcat s ",`" anon))
            )
            s
          )
          block
        )
      )
    )
  )
)

(defun LM:AnonymousInstancesof ( block / def rec nme ref lst )
  (while (setq def (tblnext "BLOCK" (null def)))
    (if (= 1 (logand 1 (cdr (assoc 70 def))))
      (progn
        (setq rec
          (entget
            (cdr
              (assoc 330
                (entget
                  (tblobjname "BLOCK" (setq nme (cdr (assoc 2 def))))
                )
              )
            )
          )
        )
        (while (setq ref (assoc 331 rec))
          (if
            (and
              (eq block (vla-get-effectivename (vlax-ename->vla-object (cdr ref))))
              (not (member nme lst))
            )
            (setq lst (cons nme lst))
          )
          (setq rec (cdr (member (assoc 331 rec) rec)))
        )
      )
    )
  )
  (reverse lst)
)

Code: [Select]
(test "qq")
something error
sometimes,it is ok,sometimes error msg is :ActiveX 服务器返回错误: 未知名称: EffectiveName
could you tell me why? thanks a lots

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: confused on the name of ATTDYNBLOCKREF,please help
« Reply #21 on: May 31, 2011, 06:08:24 AM »
The code will only work on versions in which the EffectiveName property is available. A check could be included for this property, but surely, if the property is not available, dynamic blocks are also not available meaning the code is redundant anyway?

Code: [Select]
(defun test ( block )
  (ssget
    (list
      (cons 0 "INSERT")
      (cons 2
        (
          (lambda ( s )
            (foreach anon (LM:AnonymousInstancesof block)
              (setq s (strcat s ",`" anon))
            )
            s
          )
          block
        )
      )
    )
  )
)

(defun LM:AnonymousInstancesof ( block / def rec nme ref lst )
  (while (setq def (tblnext "BLOCK" (null def)))
    (if (= 1 (logand 1 (cdr (assoc 70 def))))
      (progn
        (setq rec
          (entget
            (cdr
              (assoc 330
                (entget
                  (tblobjname "BLOCK" (setq nme (cdr (assoc 2 def))))
                )
              )
            )
          )
        )
        (while (setq ref (assoc 331 rec))
          (if
            (and
              (eq block
                (
                  (lambda ( obj )
                    (vlax-get-property obj
                      (if (vlax-property-available-p obj 'effectivename)
                        'effectivename
                        'name
                      )
                    )
                  )
                  (vlax-ename->vla-object (cdr ref))
                )
              )
              (not (member nme lst))
            )
            (setq lst (cons nme lst))
          )
          (setq rec (cdr (member (assoc 331 rec) rec)))
        )
      )
    )
  )
  (reverse lst)
)
« Last Edit: May 31, 2011, 06:15:01 AM by Lee Mac »

snddd2000

  • Guest
Re: confused on the name of ATTDYNBLOCKREF,please help
« Reply #22 on: May 31, 2011, 11:58:05 PM »
thank your reply
but i still do not know why,
now, i open a newdrawing,this drawing is blank, i key the command, it works
then i copy a part of drawings from the drawing the command does not work, the command works also,
but when i copy all of the drawing to the new drawing, the command does not work.
something make the command error, i still can not find it. :oops:

snddd2000

  • Guest
Re: confused on the name of ATTDYNBLOCKREF,please help
« Reply #23 on: June 01, 2011, 12:30:44 AM »
i find a reason , when the drawing include a table (R17.0), the command does not work.
any way can solute this?

snddd2000

  • Guest
Re: confused on the name of ATTDYNBLOCKREF,please help
« Reply #24 on: April 12, 2012, 02:23:10 AM »
(defun LM:AnonymousInstancesof (block / def rec nme ref lst)
  (while (setq def (tblnext "BLOCK" (null def)))
    (if   (= 1 (logand 1 (cdr (assoc 70 def))))
      (progn
   (setq rec
          (entget
       (cdr
         (assoc 330
           (entget
             (tblobjname "BLOCK" (setq nme (cdr (assoc 2 def))))
           )
         )
       )
          )
   )
   (while (setq ref (assoc 331 rec))
     (if (= "INSERT"
       (cdr (assoc 0 (entget (cdr ref))));_add this to filter out table.
         )

       (if
         (and
      (eq block
          (vla-get-effectivename
            (vlax-ename->vla-object (cdr ref))
          )
      )
      (not (member nme lst))
         )
          (setq lst (cons nme lst))
       )
     )
     (setq rec (cdr (member (assoc 331 rec) rec)))
   )
      )
    )
  )
  (reverse lst)
)
« Last Edit: April 12, 2012, 02:28:16 AM by snddd2000 »