SelectionSet

Discussion in 'AutoCAD' started by Martin Schmid, Sep 17, 2004.

  1. How do I create a selection set in VBA that has all MTEXT entities in the current layout (paperspace)?

    Thanks,
    MS
     
    Martin Schmid, Sep 17, 2004
    #1
  2. Martin Schmid

    Joe Sutphin Guest

    See pg. 267 of my 2000 book for an example.

    Joe
     
    Joe Sutphin, Sep 17, 2004
    #2
  3. No need for a selection set.

    Public Sub MoveExample()
    Dim basePoint(0 To 2) As Double
    basePoint(0) = 0: basePoint(1) = 0: basePoint(2) = 0


    Dim displacement(0 To 2) As Double
    displacement(0) = 5.25: displacement(1) = -4.25: displacement(2) = 0

    Dim ent As AcadEntity
    For Each ent In ThisDrawing.ActiveLayout.Block
    If TypeOf ent Is AcadMText Then
    ent.Move basePoint, displacement
    End If
    Next ent
    End Sub
     
    Bobby C. Jones, Sep 17, 2004
    #3
  4. Martin Schmid

    Joe Sutphin Guest

    This could be a very time consuming process. I think it be better to create
    a selection set and iterate through just the selection set.

    Joe
    --
     
    Joe Sutphin, Sep 17, 2004
    #4
  5. Hi Joe,
    I've been involved in some rather lengthy, and at times somewhat heated,
    discussions on this very topic right here in this newsgroup. If needed we
    can rehash all of the details again, although it is the end of the week and
    I really don't feel like it :) The thrust of my thoughts are:

    a) "time consuming" is a relative term. If a selection set performs the
    operation in X milliseconds and iteration via For Each performs it in 20X
    milliseconds, will the end user see a difference? (Note that 20 is a random
    factor that I pulled out of my...ummm...out of the air. Please see my
    thoughts in section b as to what can affect this factor)

    b) There are a plethora of variables involved that can affect the speed
    difference in these two approaches. Deciding up front to only and always
    use one is just not something that I'm willing to do. For example, it is
    entirely possible given the original poster's provided situation that the
    selection set method could actually take longer to run than iteration.
    (Please see section a for my thoughts on speed difference)

    c) All this typing is wearing me down, which is disconcerting considering
    the actual lack of typing that I've done. My number one thought on this is
    that I always code with readability, maintainability, and scalability in
    mind before algorithm execution time. Sometimes this means that selection
    sets are the way to go, but more often than not it means that iteration with
    For Each is what I choose.

    Have a good one!
     
    Bobby C. Jones, Sep 17, 2004
    #5
  6. Bobby,

    What you stated is true until you start working with big (and I mean really
    big) datasets. If your query additionaly relies on geometry (what is where),
    you will need to implement selection sets and it's filters. For me, the most
    time-consuming process is actually discovering how to override ACAD's
    internal errors and inconsistencies related to spatial queries (i.e.
    SelectByPolygon).

    Regards,
    Maksim Sestic
     
    Maksim Sestic, Sep 19, 2004
    #6
  7. Nice plug, but sorry, I don't have your book.

    I figured out one method:

    For Each entity In ssetObj
    If entity.OwnerID = ThisDrawing.PaperSpace.ObjectID Then
    entity.Move point1, point2
    End If
    Next

    In ARX there is a function acedXformSS() to transform asel-set by a transformation matrix, but I couldn't locate such a function in VBA... does it exist?
     
    Martin Schmid, Sep 19, 2004
    #7
  8. I think you're confusing what you perceive as 'internal errors and
    inconsistencies', with your failure to understand graphical object
    selection in AutoCAD.

    It is only accurate to 1 screen pixel. It is not a true spatial
    query in the analytical sense.
     
    Tony Tanzillo, Sep 19, 2004
    #8
  9. Tony,

    I know you're right, but I'm still wondering if Autodesk is ever going to
    solve this issue (graphical query vs. spatial query) on its basic platform.
    There is no word on "accuracy issues" in ACAD's developer's guide. I'm
    working with Map and it takes much more time to implement it's location
    queries (in coding sense) than filtering out simple selection set based on
    such query.

    Regards,
    Maksim Sestic
     
    Maksim Sestic, Sep 21, 2004
    #9
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.