Select.acSelectionSetCrossing problem...

Discussion in 'AutoCAD' started by Maksim Sestic, Mar 5, 2004.

  1. Dear all,

    As some of you noticed before, and it goes way back to R14, ACAD's
    Select.acSelectionSetCrossing (or by Fence, Point, Window, Polygon, etc.)
    doesn't return a valid selection set if given fence points are not VISIBLE
    on the screen (whoah!)... Is there any VBA/LISP solution to it? I'm using
    huge (but really huge) drawings of some 20 Mbs (of vector data) and
    performing a ThisDrawing.ZoomExtents before any mentioned Select is merely
    painful experience. Will it be of any help if I use VLAX class and
    EvaluateLispExpression for one line getting DXF codes of it's EndPoint
    vertex, in a way to get other point's StartPoint vertex?

    Regards,
    Maksim Sestic
     
    Maksim Sestic, Mar 5, 2004
    #1
  2. Maksim Sestic

    Jeff Mishler Guest

    Just an idea....

    Why not draw a temporary entity using the fence points as vertice's, get
    the bounding boxof the new entity, zoom window, using the bounding box
    coords, zoom out .9 to make sure everything's seen, delete the temp
    entity, do your selection. May not be the best, but it would be faster
    than a regen.

    Jeff
     
    Jeff Mishler, Mar 5, 2004
    #2
  3. Jeff,

    The point of it all is that we are making our own network topology functions
    (as Autodesk Map's doesn't work well here and there, and it's expensive
    after all) so we need to detect what lines containing specific XData are
    adjecent. There is between 2000 and 10.000 lines, so zooming around is out
    of question for the sake of user's health :) Anyway, thanks fro the tip, we
    already tried that approach and it just takes too much time.

    Regards,
    Maksim Sestic
     
    Maksim Sestic, Mar 5, 2004
    #3
  4. Maksim Sestic

    Jeff Mishler Guest

    OK, I've got another idea which you may have already tried, too.

    Create a temp. pline at the location of the fence; create a selection
    set of all drawing entities, but filtering for only those you want to
    work with (layers, lines, arcs); step through the ss and perform an
    "Intersectwith" on each one, with the temp. pline being the test object;
    check the xdata for a match; place the entity in a seperate ss if it
    matches; use the new ss as required......

    I just tried this in a drawing with around 15k lines, plus other
    entities, and it found the7 lines I was interested in no time at
    all.....

    Good Luck,
    Jeff
     
    Jeff Mishler, Mar 6, 2004
    #4
  5. Graphical selection methods are not usable for
    doing topological classification, but that's a
    common misconception.

    Graphical methods like fence, window/crossing
    operate on the display representation of entities,
    not on their mathematical definition. Hence, the
    result can be influenced by display magnification,
    as well as VIEWRES tesselletion (e.g., circles are
    drawn as a chain of short line segments, where the
    viewres setting determines the granularity of the
    tessellation).

    In fact, graphical selection is only accurate to
    one display pixel (or possibly a virtual display
    coordinate), so that means that you can zoom out
    far enough to cause a line that is close to, but
    not actually contained by a boundary to be selected
    by a fence derived from the boundary.

    Topological classification requires much more than
    that. You have to use analytical methods, such as
    a combination of intersection and point containment
    testing, line itegrals, the winding algorithim, etc.



    AcadX for AutoCAD 2004 Beta 1
    http://mysite.verizon.net/~vze2vjds/acadx/AcadX16.zip
     
    Tony Tanzillo, Mar 6, 2004
    #5
  6. Tony,

    I'm aware of common methods used in topological operations, but this one we
    are trying to implement is based on developing a simple 2D network topology.
    Basic ACAD's platform Map phylosophy relies on is "unreliable" for designing
    such networks - the problem lies in it's concept of holding and representing
    data, not to mention developed drawing tools (based on that concept). What
    happens at the common user who used to draw a network topology "by hand" (in
    analog form)? Well, it takes _a lot_ of training (snap here, snap there) and
    time (clean up the drawing, regenerate the network) to complete one simple
    task. It's a way different concept than the one Autodesk commercially
    propagates, it's more "CAD-based" and much less
    "Digitize-Topographic-Map-And-Generate-Network-Topology" one.

    Having that in mind, we designed simple tools for generating 2D network
    topology by drafting, "in one sweep" (with very limited use, though). As I'm
    dealing with infrastructure planning and design, I also had to design stable
    object (feature) classes and methodologies to support such classes in
    various ways. The final result is relatively simple but functional model of
    an infrastructure network that acts like a "real one". The only difference
    is that it runs on plain AutoCAD.

    Back to the current problem :) Basically, I'm trying to detect a "crossing"
    of two (or more) lines by investigating the endpoint of one line. If there
    is more than one adjecent line to inspected one, then it's a crossing. Funny
    thing is that two lines, one touching another (using OSNAP), do not have the
    same X and Y startpoint/endpoint. They differ somehow - say, DXF group code
    11 (End point (in WCS)) of one line and group code 10 (Start point (in WCS))
    of the other _are not the same_, so I just can't use selection set filters
    to detect the "crossing". Is there any solution to it?

    Regards,
    Maksim Sestic
     
    Maksim Sestic, Mar 6, 2004
    #6
  7. Jeff,

    The problem still remains - you just can't inspect SelectByIntersection
    selset if it's "out of visible part of the drawing". The result is
    (generally) empty selection set.

    Regards,
    Maksim Sestic
     
    Maksim Sestic, Mar 6, 2004
    #7
  8. Maksim Sestic

    Jeff Mishler Guest

    Maksim,
    I think you missed my point. I wasn't suggesting SelectByIntersection at
    all. I'm saying get ALL lines (or arcs, or polylines) on certain layers.
    Create a polyline using the "fence" points as the vertex data. Inspect
    each entity in the selection set to see if it intersects the polyline,
    if it does, place THAT into a new selection set.

    This does work for items outside the visible area.....

    Here's what I used to test with in drawing who's "status" shows:
    48441 objects in F:\99\111 - Brennan Acres\master.dwg
    Model space limits are X: 0.00 Y: 0.00 (Off)
    X: 1080.00 Y: 720.00
    Model space uses X: -8961.28 Y: -235.67 **Over
    X: 7242.35 Y: 2067.91 **Over
    Display shows X: -19658.04 Y: -9313.40
    X: 17019.14 Y: 8375.13
    Insertion base is X: 328.64 Y: 1819.93 Z: 0.00
    Snap resolution is X: 1.00 Y: 1.00
    Grid spacing is X: 0.00 Y: 0.00

    Current space: Model space
    Current layout: Model
    **********************************************
    Sub testXing()
    Dim ss As AcadSelectionSet
    Dim newSS As AcadSelectionSet
    Dim dxfCode(1) As Integer
    Dim dxfVal(1) As Variant
    Dim objEnt As AcadEntity
    Dim objLine As AcadLine
    Dim fence(5) As Double
    Dim pickPt As Variant
    Dim fenLine As AcadLWPolyline
    Dim Util As AcadUtility
    Dim i As Long

    Set Util = ThisDrawing.Utility
    dxfCode(0) = 0: dxfCode(1) = 8
    dxfVal(0) = "LINE": dxfVal(1) = "EGSRF-VIEW"
    On Error Resume Next
    Set ss = ThisDrawing.SelectionSets.Add("fences")
    If Err.Number <> 0 Then
    Err.Clear
    Set ss = ThisDrawing.SelectionSets.Item("fences")
    End If
    Set newSS = ThisDrawing.SelectionSets.Add("newss")
    If Err.Number <> 0 Then
    Err.Clear
    Set newSS = ThisDrawing.SelectionSets.Item("newss")
    End If
    On Error GoTo 0
    ss.Clear
    newSS.Clear
    ss.Select acSelectionSetAll, , , dxfCode, dxfVal

    fence(0) = -8560#: fence(1) = 1038#
    fence(2) = -1296#: fence(3) = 740#
    fence(4) = 5417: fence(5) = 1223#

    Set fenLine = ThisDrawing.ModelSpace.AddLightWeightPolyline(fence)
    For Each objEnt In ss
    Dim varInters As Variant
    Dim entSS(0) As AcadEntity
    varInters = objEnt.IntersectWith(fenLine, acExtendNone)
    If UBound(varInters) > 0 Then
    Set entSS(0) = objEnt
    newSS.AddItems (entSS)
    End If
    Next
    newSS.Highlight True
    fenLine.Delete
    End Sub
    ****************************************
    Afterwards, using a little lisp, my "newss" shows it has entities in it:
    (setq ss (vla-item (vla-get-selectionsets *doc*) "newss"))
    (vla-get-count ss)
    394
    I can replicate this no matter where I'm zoomed to in the drawing....

    HTH,
    Jeff
     
    Jeff Mishler, Mar 6, 2004
    #8
  9. It looks like you didn't read what I said.

    You can't use selection set methods to do what
    you want. They're only accurate to a pixel, and
    they don't work on objects outside of the view.



    AcadX for AutoCAD 2004 Beta 1
    http://mysite.verizon.net/~vze2vjds/acadx/AcadX16.zip
     
    Tony Tanzillo, Mar 6, 2004
    #9
  10. Tony,

    I solved a problem using VLAX class to obtain inspected line's
    strapoint/endpoint, and then selecting _all_ entities (equivalent to X
    switch used by LISP) while filtering it for DXF codes 10 <OR> 11 and <XOR>
    inspected entity's handle. I needed a set of all lines starting/ending at
    the endpoint of inspected line ("crossing").

    Regards,
    Maksim Sestic
     
    Maksim Sestic, Mar 7, 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.