Selecting External References

Discussion in 'AutoCAD' started by manoj_vest, Jun 11, 2004.

  1. manoj_vest

    manoj_vest Guest

    Hi all,

    I need to select only external references in the drawing. Is there i direct method to to this. Can any body suggest me the filter value for this. Or am I need to select block references and in block references find the external references. But I a very large drawing there are very few external references and thousands of block references and I need to serch thousands item to get one.

    Thanks in advance

    manoj
     
    manoj_vest, Jun 11, 2004
    #1
  2. Use a function to iterate thru the Blocks collection gathering the names of
    XRefs into a single string usable as a block name filter for the selection
    set filter.



    --
    R. Robert Bell


    Hi all,

    I need to select only external references in the drawing. Is there i direct
    method to to this. Can any body suggest me the filter value for this. Or am
    I need to select block references and in block references find the external
    references. But I a very large drawing there are very few external
    references and thousands of block references and I need to serch thousands
    item to get one.

    Thanks in advance

    manoj
     
    R. Robert Bell, Jun 11, 2004
    #2
  3. Iterate through the blocks collection, and look at each
    block's IsXRef property. If it's true, add the name of the
    block to a collection.

    Then, with a collection containing the names of all XRef
    blocks, you build a filter list that consists of this:

    FilterType FilterData
    ----------------------------
    0 "INSERT"
    -4 "<OR"
    2 <BlockName1>
    2 <BlockName2>
    2 <BlockNameN>.....
    -4 "OR>"

    Where the number of elements with FilterType = 2 is
    equal to the number of blocks in your collection.

    --
    http://www.caddzone.com

    AutoCAD based Security Planning Solutions:
    http://www.caddzone.com/securityplanning

    AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005
    http://www.acadxtabs.com


    the filter value for this. Or am I need to select block references and in block references find the external references.
    But I a very large drawing there are very few external references and thousands of block references and I need to serch
    thousands item to get one.
     
    Tony Tanzillo, Jun 11, 2004
    #3
  4. manoj_vest

    manoj_vest Guest

    What happen if a drawing contains too many blocks? I have a drawing which contains only one external reference but 750 blocks. To get one external reference I need to iterate 750 items which is not economical. So is there any other method?

    Manoj
     
    manoj_vest, Jun 14, 2004
    #4
  5. manoj_vest

    manoj_vest Guest

    Hi Tony,

    I tried your suggestion keeping in mind that not always but in most of the cases I will need to iterate less No of items. So I put the following code

    Public Sub aaaa()
    Dim i As Integer
    For i = 0 To ThisDrawing.Blocks.Count - 1
    If ThisDrawing.Blocks(i).IsXRef Then
    'Debug.Print ThisDrawing.Blocks(i).Name
    End If
    Next
    Dim nFilTyp(0 To 4) As Integer
    Dim vFil(0 To 4) As Variant

    nFilTyp(0) = 0
    vFil(0) = "INSERT"
    vFil(1) = -4
    vFil(1) = "<OR"
    vFil(2) = 2
    vFil(2) = "8th floor plan"
    vFil(3) = 2
    vFil(3) = "Circle"
    vFil(4) = -4
    vFil(4) = "OR>"

    Dim vTyp As Variant, vData As Variant
    vTyp = nFilTyp
    vData = vFil

    Dim ss As AcadSelectionSet
    Set ss = ThisDrawing.SelectionSets.Add("SSS")
    ss.Select acSelectionSetAll, , , vTyp, vData
    MsgBox ss.Count
    ss.Delete

    End Sub

    in my current drawing "8th floor plan" and "Circle" are two external references. If I am running the sample I am geting 0 item in my selectionset. So am I doing any thing wrong?

    Manoj
     
    manoj_vest, Jun 14, 2004
    #5
  6. manoj_vest

    Joe Sutphin Guest

    vTyp must be an integer.

    cases I will need to iterate less No of items. So I put the following code
    references. If I am running the sample I am geting 0 item in my
    selectionset. So am I doing any thing wrong?
     
    Joe Sutphin, Jun 14, 2004
    #6
  7. Why are you not passing the values of the two filter arrays
    directly to the Select method?

    There is no reason for the other two variables (vTyp and vData).
    Just pass the nFilTyp and vFil variables to Select()

    --
    http://www.caddzone.com

    AutoCAD based Security Planning Solutions:
    http://www.caddzone.com/securityplanning

    AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005
    http://www.acadxtabs.com


    items. So I put the following code
    geting 0 item in my selectionset. So am I doing any thing wrong?
     
    Tony Tanzillo, Jun 14, 2004
    #7
  8. manoj_vest

    manoj_vest Guest

    Hi Tony,

    Even if I am passing the two filter arrays directly, I am not getting any thing and the selectionset count returns 0;
     
    manoj_vest, Jun 14, 2004
    #8
  9. manoj_vest

    Joe Sutphin Guest

    Give this a try, please pardon the incidental cleanups. Per your description
    of the current drawing you have open, this worked fine for me.


    Public Sub aaaa()
    Dim i As Long

    For i = 0 To ThisDrawing.Blocks.Count - 1
    If ThisDrawing.Blocks(i).IsXRef Then
    Debug.Print ThisDrawing.Blocks(i).Name
    End If
    Next i

    Dim nFilTyp(0 To 4) As Integer
    Dim vFil(0 To 4) As Variant

    nFilTyp(0) = 0: vFil(0) = "INSERT"
    nFilTyp(1) = -4: vFil(1) = "<OR"
    nFilTyp(2) = 2: vFil(2) = "8th floor plan"
    nFilTyp(3) = 2: vFil(3) = "Circle"
    nFilTyp(4) = -4: vFil(4) = "OR>"

    Dim ss As AcadSelectionSet

    Set ss = ThisDrawing.SelectionSets.Add("SSS")
    ss.Select acSelectionSetAll, , , nFilTyp, vFil

    MsgBox ss.Count
    ss.Delete
    End Sub


    thing and the selectionset count returns 0;
     
    Joe Sutphin, Jun 14, 2004
    #9
  10. manoj_vest

    manoj_vest Guest

    Hi Joe,

    Thanks for your sample, its working fine for me. I have done a very stupid mistake in my sample and is not expacted in this discussion group. Any way Thanks again

    Manoj
     
    manoj_vest, Jun 15, 2004
    #10
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.