Problem Getting AcadBlockReference Object

Discussion in 'AutoCAD' started by dhaverstick, Oct 25, 2004.

  1. dhaverstick

    dhaverstick Guest

    Has anyone else had problems getting an AcadBlockReference object by setting it this way: Set AcadBlockRef = ModelSpaceObj.Item("AcadBlockRefName") where "AcadBlockRefName" is the name of the block reference object. Sometimes this method works and sometimes it doesn't. The only way I can get the BlockRef object 100% of the time is by iterating through all the items in Modelspace like this
    For Each EntityObj in ModelSpaceObj
    If TypeOf EntityObj is AcadBlockReference Then
    Set AcadBlockRef = EntityObj
    If AcadBlockRef.Name = "AcadBlockRefName" Then
    Exit For
    Endif
    Next


    Thanks,

    Darren
     
    dhaverstick, Oct 25, 2004
    #1
  2. Where did you get the idea that the Item method
    accepts the name of a block reference?

    It doesn't. Common sense would suggest that
    since there can be more than one insertion of a
    block of a given name, that you could not use the
    name as an index key.
     
    Tony Tanzillo, Oct 25, 2004
    #2
  3. In addition to any replies you might receive or already
    received, you may find more information or responses
    by posting future VBA related questions in the following
    discussion group:

    By NNTP discussion group reader at
    news://discussion.autodesk.com/autodesk.autocad.customization.vba

    By HTTP (web-based) interface at
    http://discussion.autodesk.com/forum.jspa?forumID=33



    --
    Autodesk Discussion Group Facilitator



    setting it this way: Set AcadBlockRef =
    ModelSpaceObj.Item("AcadBlockRefName") where "AcadBlockRefName" is the name
    of the block reference object. Sometimes this method works and sometimes it
    doesn't. The only way I can get the BlockRef object 100% of the time is by
    iterating through all the items in Modelspace like this
     
    Jason Piercey, Oct 25, 2004
    #3
  4. dhaverstick

    dhaverstick Guest

    1) In my particular case, all block reference objects have unique names. 2) I got the idea of setting object references using the Item method from this discussion group. I tried it and it worked in my test case.
     
    dhaverstick, Oct 25, 2004
    #4
  5. dhaverstick

    Doug Broad Guest

    You can use the name form of the item method on the block
    collection but I am sure the name form does not work in the
    modelspace collection. Why not use filtered selection sets?

    Regards,
    Doug

    idea of setting object references using the Item method from this discussion group. I
    tried it and it worked in my test case.
     
    Doug Broad, Oct 25, 2004
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.