XRef Block is In cuur doc or Not

Discussion in 'AutoCAD' started by manoj_vest, Aug 2, 2004.

  1. manoj_vest

    manoj_vest Guest

    Hi All,

    Is there a direct method to know whether a block whoes IsXRef property is directly inserted in the current document or is inserted in some other document which is inserted in this document.

    I know that this can be done by seeing the inserted block references and comparing for the same name. But I don't want to do that. Is there any method or property of Block object by which we can find out it.

    Thanks In advance

    Manoj
     
    manoj_vest, Aug 2, 2004
    #1
  2. manoj_vest

    AKS Guest

    Manoj,

    Maybe this is an answer, or maybe it is not. It is an exerpt of code
    from a routine where the user picks items to see info on that item
    much like the properties tool but with the information you really want
    to see.

    Here the entity is picked with GetSubEntity. The very first thing that
    must be determined is whether or not that picked item entity is from
    another document just like what you are asking. In this case the
    contextdata returned by GetSubEntity is what answers that question.
    The variable MamaItem becomes the "other document". Later on in the
    code (not shown here) the MamaItem.path is used to report that
    document's name.


    ThisDrawing.Utility.GetSubEntity PickedItem, pickedpoint,
    transmatrix, contextdata
    If Not (IsEmpty(contextdata)) Then
    Set OtherItem = ThisDrawing.ObjectIdToObject(contextdata(0))
    If UBound(contextdata) > 0 Then
    Set MamaItem =
    ThisDrawing.ObjectIdToObject(contextdata(UBound(contextdata)))
    End If
    Title = PickedItem.ObjectName & " part of " &
    OtherItem.ObjectName
    strStat = OtherItem.Layer & " = Insertion Layer"
    strStat = strStat & vbCr & vbCr & PickedItem.Layer & " =
    Layer in block definition"
    Else
    Title = PickedItem.ObjectName
    strStat = PickedItem.Layer & " = Layer"
    End If


    AKS
     
    AKS, Aug 2, 2004
    #2
  3. Check the OwnerId property. If it's xref'd into the current document,
    the OwnerId should match the ObjectId of the ModelSpace block (assuming
    a model space insert).
     
    Frank Oquendo, Aug 2, 2004
    #3
  4. manoj_vest

    manoj_vest Guest

    Hi frank,

    Thanks for your suggestion. I tried the same but the owner ID for all the blocks whether it is external reference, or simple block or a nested external reference, is same and the corresponding object is AcadBlocks object. So this won't be usefull for my problem.

    Is there any other way.

    Thanks again for your valuable effort.

    Manoj
     
    manoj_vest, Aug 3, 2004
    #4
  5. manoj_vest

    aks01 Guest

    Manoj,

    Maybe this is an answer, or maybe it is not. It is an exerpt of code from a routine where the user picks items to see info on that item much like the properties tool but with the information you really want to see.

    Here the entity is picked with GetSubEntity. The very first thing that must be determined is whether or not that picked item entity is from another document just like what you are asking. In this case the contextdata returned by GetSubEntity is what answers that question. The variable MamaItem becomes the "other document". Later on in the code (not shown here) the MamaItem.path is used to report that
    document's name.


    ThisDrawing.Utility.GetSubEntity PickedItem, pickedpoint, transmatrix, contextdata
    If Not (IsEmpty(contextdata)) Then
    Set OtherItem = ThisDrawing.ObjectIdToObject(contextdata(0))
    If UBound(contextdata) > 0 Then
    Set MamaItem =
    ThisDrawing.ObjectIdToObject(contextdata(UBound(contextdata)))
    End If
    Title = PickedItem.ObjectName & " part of " &
    OtherItem.ObjectName
    strStat = OtherItem.Layer & " = Insertion Layer"
    strStat = strStat & vbCr & vbCr & PickedItem.Layer & " =
    Layer in block definition"
    Else
    Title = PickedItem.ObjectName
    strStat = PickedItem.Layer & " = Layer"
    End If


    aks
     
    aks01, Aug 3, 2004
    #5
  6. You have to check the OwnerId property on the insert, not the block.
     
    Frank Oquendo, Aug 3, 2004
    #6
  7. Just look at the Database property of the Block object.




    reference, or simple block or a nested external reference, is same and the corresponding object is AcadBlocks
    object. So this won't be usefull for my problem.
     
    Tony Tanzillo, Aug 3, 2004
    #7
  8. manoj_vest

    manoj_vest Guest

    Hi Tony & ask,

    Thanks for your suggestion but as per your suggestion I need to pick the object on the screen interactivly, but I don't need to do that. I am iterating the block collection, if the block is external reference and is directly inserted in the current drawing then I need to reload the block so that any changes made in the block will be get reflected. So here there is no scop for picking the object on the screen.

    One method is that if the block reference is an external reference take its name, iterate block-reference collection and find is there a reference with the same name?, If yes, then it is an external reference inserted in the current drawing, otherwise the external reference is not in current drawing. But the problem is that some of my drawings have more than 2000 block reference. If there are 10 external reference blocks in the drawing then I will have to iterate upto 20000 times which I don't want. So Is there any other method.

    Hi tony you have suggested to look at Database property, but the database property will provide me the database of the external reference. What property will suggest that the block is directly inserted in the current drawing or is inserted in some other drawing which is inserted in this drawing?
     
    manoj_vest, Aug 4, 2004
    #8
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.