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

0 Members and 1 Guest are viewing this topic.

snddd2000

  • Guest
confused on the name of ATTDYNBLOCKREF,please help
« on: March 08, 2011, 02:38:47 AM »
now i have a block list as below
((-1 . <图元名: 7efc0300>) (0 . "INSERT") (5 . "B9B8") (102 . "{ACAD_XDICTIONARY") (360 . <图元名: 7ed09318>) (102 . "}") (330 . <图元名: 7efa9cf8>) (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "细实线") (100 . "AcDbBlockReference") (66 . 1) (2 . "*U661") (10 3672.0 784.0 0.0) (41 . 8.0) (42 . 8.0) (43 . 8.0) (50 . 0.0) (70 . 0) (71 . 0) (44 . 0.0) (45 . 0.0) (210 0.0 0.0 1.0))

the  (2 . "*U661") should be the name ,but when i defined this block the name is "qq",not "*U661"
why? confuesd long time
thanks
please help me!
my english is not good
 :-o

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: confused on the name of ATTDYNBLOCKREF,please help
« Reply #1 on: March 08, 2011, 02:54:17 AM »
I guess this would give the real name of it .

Code: [Select]
(setq ss (ssget "_+.:S" '((0 . "INSERT"))))
(setq BlkName (vla-get-effectivename  (vlax-ename->vla-object (ssname ss 0))))

Regards,

Tharwat

snddd2000

  • Guest
Re: confused on the name of ATTDYNBLOCKREF,please help
« Reply #2 on: March 08, 2011, 03:15:19 AM »
the real name ? means what? :oops:

thanks

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: confused on the name of ATTDYNBLOCKREF,please help
« Reply #3 on: March 08, 2011, 03:18:58 AM »
Your Block name before going to become a Dynamic Block

Try the codes and you will find it out .

this block the name is "qq",not "*U661"

snddd2000

  • Guest
Re: confused on the name of ATTDYNBLOCKREF,please help
« Reply #4 on: March 08, 2011, 03:21:56 AM »
when i copy this block to another dwg.
the *U661 would be changed ,and the "qq"  not changed.
press ctrl+1 the name "qq" in the list of properties

snddd2000

  • Guest
Re: confused on the name of ATTDYNBLOCKREF,please help
« Reply #5 on: March 08, 2011, 03:22:52 AM »
yes the block is Dynamic Block
Dynamic Block name must like this?

thanks

Jeff H

  • Needs a day job
  • Posts: 6151
Re: confused on the name of ATTDYNBLOCKREF,please help
« Reply #6 on: March 08, 2011, 03:24:31 AM »
You do understand with dynamic blocks anytime you change a dynamic property it will create a anonymous block?

snddd2000

  • Guest
Re: confused on the name of ATTDYNBLOCKREF,please help
« Reply #7 on: March 08, 2011, 03:26:46 AM »
thanks a lot
it works

one question
(setq ss (ssget "_+.:S" '((0 . "INSERT"))))
why add "_+.:" before :S?  :lol:

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: confused on the name of ATTDYNBLOCKREF,please help
« Reply #8 on: March 08, 2011, 03:29:55 AM »
thanks a lot
it works

one question
(setq ss (ssget "_+.:S" '((0 . "INSERT"))))
why add "_+.:" before :S?  :lol:

Because the ssget function is multi-selection set and to add "_+.:S" would force it for single selection set only ( one selection set).

Good luck.



snddd2000

  • Guest
Re: confused on the name of ATTDYNBLOCKREF,please help
« Reply #9 on: March 08, 2011, 03:31:28 AM »
You do understand with dynamic blocks anytime you change a dynamic property it will create a anonymous block?
but why select two diffrent block ,the name is same?

命令: (vlax-get-property (vlax-ename->vla-object  (car (entsel))) 'name)

选择对象: "*U661"

命令: (vlax-get-property (vlax-ename->vla-object  (car (entsel))) 'name)

选择对象: "*U661"

snddd2000

  • Guest
Re: confused on the name of ATTDYNBLOCKREF,please help
« Reply #10 on: March 08, 2011, 03:35:39 AM »
thanks a lot
it works

one question
(setq ss (ssget "_+.:S" '((0 . "INSERT"))))
why add "_+." before :S?  :lol:

Because the ssget function is multi-selection set and to add "_+.:S" would force it for single selection set only ( one selection set).

Good luck.

how can i filter this name block by ssget?
thanks

pBe

  • Bull Frog
  • Posts: 402
Re: confused on the name of ATTDYNBLOCKREF,please help
« Reply #11 on: March 08, 2011, 06:54:42 AM »
right after this: (as tharwats suggestion)
Code: [Select]
(setq ss (ssget "_+.:S" '((0 . "INSERT"))))
Before you processed the block, run this as a test for block name
Code: [Select]
(setq BlkName (vla-get-effectivename  (vlax-ename->vla-object (ssname ss 0))))
it will you give you name of the block for your test/cond
(if (eq BlkName "qq") (.... <----- test
But if you're going to select on screen as the example suggest, you dont really need to do this as you already know you're selecting the correct block, but if you have the need for the blockname then you should run the test.

Now if you select the entire database using "_X" (meaning no prompt for selection on the screen)
Code: [Select]
(setq ss (ssget "_X" '((0 . "INSERT")(2 . "*U*,qq"))))Then you need to run it through the test before you worked on the block

That is just how Dynamic Block behaves (Autodesk needs to do something about this I guess), converting it to an anonymous name

Hope this helps
« Last Edit: March 08, 2011, 07:12:56 AM by pBe »

snddd2000

  • Guest
Re: confused on the name of ATTDYNBLOCKREF,please help
« Reply #12 on: March 08, 2011, 08:14:05 PM »
right after this: (as tharwats suggestion)
Code: [Select]
(setq ss (ssget "_+.:S" '((0 . "INSERT"))))
Before you processed the block, run this as a test for block name
Code: [Select]
(setq BlkName (vla-get-effectivename  (vlax-ename->vla-object (ssname ss 0))))
it will you give you name of the block for your test/cond
(if (eq BlkName "qq") (.... <----- test
But if you're going to select on screen as the example suggest, you dont really need to do this as you already know you're selecting the correct block, but if you have the need for the blockname then you should run the test.

Now if you select the entire database using "_X" (meaning no prompt for selection on the screen)
Code: [Select]
(setq ss (ssget "_X" '((0 . "INSERT")(2 . "*U*,qq"))))Then you need to run it through the test before you worked on the block

That is just how Dynamic Block behaves (Autodesk needs to do something about this I guess), converting it to an anonymous name

Hope this helps

thanks a lot but this (setq ss (ssget "_X" '((0 . "INSERT")(2 . "*U*,qq")))) does not work
canot select any blocks,
now i use below way to do
Code: [Select]
(setq ss1 (ssget '((0 . "INSERT"))) )
(setq count  (sslength ss1)
      n       0
      n1      0
      zl1     0
      zzl1    0
)
(repeat count
 (if (/= "qq" (vla-get-effectivename (vlax-ename->vla-object (ssname ss1 n))))
  (progn
    (ssdel (ssname ss1 n) ss1)
    (setq n (1- n))
  )
 )
 (setq n (1+ n))
)
i do not know any better way.

thanks all

pBe

  • Bull Frog
  • Posts: 402
Re: confused on the name of ATTDYNBLOCKREF,please help
« Reply #13 on: March 08, 2011, 10:35:29 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
« Last Edit: March 08, 2011, 11:05:30 PM by pBe »

snddd2000

  • Guest
Re: confused on the name of ATTDYNBLOCKREF,please help
« Reply #14 on: March 08, 2011, 10:48:30 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"))))
But anyway, i see you got it figured out
Great, it is right , i like your way
thank you very much

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 »