See the top rated post in this thread. Click here

Results 1 to 10 of 10

Thread: test for anonymous block

  1. #1
    100 Club KevinBarnett's Avatar
    Join Date
    2001-10
    Location
    Pretoria, South Africa
    Posts
    119
    Login to Give a bone
    0

    Question test for anonymous block

    Is there a way in vba to test a block to see if its anonymous? Or, is the only way in LISP and test the value of group code 70?

    Thx,

    Kevin.

  2. #2
    All AUGI, all the time
    Join Date
    2015-12
    Location
    Central Oregon
    Posts
    591
    Login to Give a bone
    0

    Default Re: test for anonymous block

    I'm pretty sure that an anonymous block's name will always begin with "*U"

  3. #3
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,804
    Login to Give a bone
    0

    Default Re: test for anonymous block

    Quote Originally Posted by KevinBarnett
    Is there a way in vba to test a block to see if its anonymous? Or, is the only way in LISP and test the value of group code 70?

    Thx,

    Kevin.
    Something like this?

    Code:
    Sub temp()
     Dim obj As AcadEntity
      For Each obj In ThisDrawing.ModelSpace
          If obj.ObjectName = "AcDbBlockReference" Then
              tmp = obj.EffectiveName
              If InStr(1, tmp, "*U", vbTextCompare) Then
                  Debug.Print tmp
              End If
          End If
      Next obj
    End Sub
    R.K. McSwain | CAD Panacea |

  4. #4
    100 Club KevinBarnett's Avatar
    Join Date
    2001-10
    Location
    Pretoria, South Africa
    Posts
    119
    Login to Give a bone
    0

    Thumbs up Re: test for anonymous block

    Here we go again, hidden treasures in the object model. It's such a pity this property is in the BlockReference object and not the Block object. Out of curiosity, have you looked at VB.Net yet or are you still coding in VBA?

  5. #5
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,804
    Login to Give a bone
    0

    Default Re: test for anonymous block

    Quote Originally Posted by KevinBarnett
    Here we go again, hidden treasures in the object model. It's such a pity this property is in the BlockReference object and not the Block object. Out of curiosity, have you looked at VB.Net yet or are you still coding in VBA?

    VBA.

    The reason you have to test "EffectiveName" is that Dynamic block insertions become "anonymous" as soon as they are modified.
    R.K. McSwain | CAD Panacea |

  6. #6
    All AUGI, all the time
    Join Date
    2015-12
    Location
    Central Oregon
    Posts
    591
    Login to Give a bone
    0

    Default Re: test for anonymous block

    Quote Originally Posted by KevinBarnett
    Here we go again, hidden treasures in the object model. It's such a pity this property is in the BlockReference object and not the Block object.
    While it's true that the EffectiveName is a property of the BlockRef, you can still check if a BlockDef is anonymous by checking it's Name property. So I'm not sure what you mean by "Here we go again".

    Jeff

  7. #7
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,804
    Login to Give a bone
    0

    Default Re: test for anonymous block

    Quote Originally Posted by miff
    While it's true that the EffectiveName is a property of the BlockRef, you can still check if a BlockDef is anonymous by checking it's Name property.
    Technically true, but as mentioned, the Name property of a dynamic block changes as soon as it is modified using one of it's dynamic properties.

    At that point, if you only check the Name property for "*U", you could be looking at an anonymous block or a modified dynamic block.

    The EffectiveName property will reflect "*U" only for true anonymous blocks.
    R.K. McSwain | CAD Panacea |

  8. #8
    All AUGI, all the time
    Join Date
    2015-12
    Location
    Central Oregon
    Posts
    591
    Login to Give a bone
    0

    Default Re: test for anonymous block

    OK, let's back up a bit. Kevin asked about checking if a Block is anonymous, and since he mentioned the lisp method of checking the Group 70 code which is a part of the Block Definition and not the insert, it made sense to answer that. And since the Block object does NOT have an EffectiveName property I felt obliged to mention that the Name property of a Block, not BlockReference, can be used to determine anonymity.

    Jeff

  9. #9
    100 Club KevinBarnett's Avatar
    Join Date
    2001-10
    Location
    Pretoria, South Africa
    Posts
    119
    Login to Give a bone
    0

    Exclamation Re: test for anonymous block

    Jeff,
    The Name property is dangerous. All because a block is named "*U" it is not necessarily an anonymous block. I was unlucky enough to encounter drawing data made my a non Autodesk CAD system. Somehow they managed to use *'s in the block names an thats where my troubles began. I wrote code to remove the invalid characters, making the block names AutoCAD compliant - (yes I did AUDIT the drawing, the result was awful!). Thats why I need to test for anonymous. It would have been great if VBA in Acad included IsAnonymous, like IsLayout. But it does not. I solved it by a little LISP, testing the value of group code 70. Still, it was great to find that additional info - EffectiveName, will come in useful.

    Thanks guys.

  10. #10
    Woo! Hoo! my 1st post
    Join Date
    2015-10
    Posts
    1
    Login to Give a bone
    1

    Default Re: test for anonymous block

    Quote Originally Posted by rkmcswain View Post
    Something like this?

    Code:
    Sub temp()
     Dim obj As AcadEntity
      For Each obj In ThisDrawing.ModelSpace
          If obj.ObjectName = "AcDbBlockReference" Then
              tmp = obj.EffectiveName
              If InStr(1, tmp, "*U", vbTextCompare) Then
                  Debug.Print tmp
              End If
          End If
      Next obj
    End Sub
    This was just what I needed, thanks!!!

Similar Threads

  1. Anonymous Block Names Stumping SSX and BLOCKREPLACE...
    By swojtynek408932 in forum CAD Management - General
    Replies: 4
    Last Post: 2013-09-16, 07:52 PM
  2. Anonymous Block Name
    By nathano172904 in forum CAD Management - General
    Replies: 1
    Last Post: 2010-11-20, 07:22 PM
  3. Replies: 14
    Last Post: 2010-03-15, 02:42 PM
  4. Anonymous Block Created when exploding or pasting
    By limartin in forum AutoCAD General
    Replies: 4
    Last Post: 2009-10-08, 01:51 PM
  5. Anonymous block ?!!
    By Algyyys in forum AutoCAD General
    Replies: 3
    Last Post: 2009-05-18, 10:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •