Find which layout an AcadEntity is on

Discussion in 'AutoCAD' started by Norman Yuan, Feb 18, 2005.

  1. Norman Yuan

    Norman Yuan Guest

    When using SelectionSet.Select() to grab a bunch of entities, how do you
    know which layout each entity is on?

    I use following code to get all text into a SelectionSet

    Dim ss As AcadSelectionSet
    Dim gpCode(0) As Integer
    Dim dataValue(0) As Variant

    gpCode(0) = 0
    dataValue(0) = "Text"

    Set ss = mDwg.SelectionSets.Add("AllTexts")
    ss.Select acSelectionSetAll, , , gpCode, dataValue

    This returns all text entities in entire drawing (modelspace and paperspace
    of all layouts). I am only interested those on particular layout and need to
    know what layout a text entity belongs to.

    Of cource I can loop through PaperSpace for each layout to find the text
    entities I want, instead of using SelectionSet.Select. But using
    SelectionSet.Select() is a lot faster , if only I can tell which layout an
    entity in the SelectionSet belongs to. Any idea?
     
    Norman Yuan, Feb 18, 2005
    #1
  2. Norman Yuan

    Oberer Guest

    here's a snip of code someone from the group was nice enough to provide:

    Code:
    mySS.Select acSelectionSetAll, , , grpCode, dataVal
    ' CHANGE EACH OBJECT
    For Each oEnt In mySS
    strCurrentLayout = ThisDrawing.ObjectIdToObject(oEnt.OwnerID).Layout.Name
    If InStr(1, strLayouts, strCurrentLayout) = 0 Then
    strLayouts = strLayouts & strCurrentLayout & vbNewLine
    End If
    Next
    
     
    Oberer, Feb 18, 2005
    #2
  3. Also if you have 2005, then there is an
    unpublished property of the view object -- .LayoutID

    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Feb 18, 2005
    #3
  4. Norman Yuan

    Norman Yuan Guest

    Thanks, I forgot OwnerID is the one bit info pinting to an entity's Layout,
    which is what I need to use.
     
    Norman Yuan, Feb 18, 2005
    #4
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.