TheSwamp

Code Red => .NET => Topic started by: Proctor on July 29, 2009, 03:04:20 PM

Title: SelectCrossingWindow giving me more results than I want
Post by: Proctor on July 29, 2009, 03:04:20 PM
Hello: I am using selectCrossingWindow to locate all lines that are either inside or cross the window parameters being passed in; it's been working fine...so i thought...until I ran my code on the attached polygon. in the attached pic you can see how I draw a box using my paremeters so that i can verify that all lines are either inside or crossing it. in looking at the pic, you can see that only 2 lines should be in the result set; however, it gives me 4 and i can't figure out why???? the blue and the green lines represent the lines it's giving me.

also, the arrows represent the 2 points i'm passing in.

any ideas are truly appreciated. i've been scratching my head for a few days on this now.
thanks,
Proctor
Title: Re: SelectCrossingWindow giving me more results than I want
Post by: Proctor on July 29, 2009, 03:28:48 PM
I just tried making the box smaller, so only 1 line appears in it....and now it's getting a count of 2. the line that's green is the additional line it's picking up. i don't understand why it's doing this?

here's the line of code where i'm sending in the paramerts:
<code>resW = doc.Editor.SelectCrossingWindow(myYPt, myY2Pt, filter)</code>
the filter is for lines only.

thanks,
Proctor
Title: Re: SelectCrossingWindow giving me more results than I want
Post by: Dave R on July 29, 2009, 03:55:49 PM
Try using doc.Editor.SelectWindow instead.

I just tried making the box smaller, so only 1 line appears in it....and now it's getting a count of 2. the line that's green is the additional line it's picking up. i don't understand why it's doing this?

here's the line of code where i'm sending in the paramerts:
<code>resW = doc.Editor.SelectCrossingWindow(myYPt, myY2Pt, filter)</code>
the filter is for lines only.

thanks,
Proctor
Title: Re: SelectCrossingWindow giving me more results than I want
Post by: Proctor on July 29, 2009, 03:57:57 PM
hi Dave - thanks for your reply. doesn't selectWindow only give what's entirely in the window? i need it to give me for both what's inside and also what's crossing the window too.

proctor
Title: Re: SelectCrossingWindow giving me more results than I want
Post by: Dave R on July 29, 2009, 04:01:52 PM
Sorry. Flying by and didn't fully read your first post. Could it have something to do with the linetype of the green line perhaps? Looks like it may be a dashed linetype and that may be why the selection window is picking it up. Also check to see that the small line is not duplicated on top of itself.

hi Dave - thanks for your reply. doesn't selectWindow only give what's entirely in the window? i need it to give me for both what's inside and also what's crossing the window too.

proctor
Title: Re: SelectCrossingWindow giving me more results than I want
Post by: Proctor on July 29, 2009, 04:08:16 PM
I was just thinking....when i break down my procedure and ask for the user to select the line, the code works fine; however, in my code, i loop through a set of polygons.

for each polygon, i use SelectCrossingPolygon(myPtColl, filter) to give me a list of lines that are inside it.
for each line i then draw boxes for each end in order to find lines close to it. I  pass the crossing window params like this:

<code>
 Dim resW As PromptSelectionResult = Nothing
 resW = doc.Editor.SelectCrossingWindow(myVectorYStartPt, myVectorY2StartPt, filter)   
</code>

do you think that this has something to do w/ why it's not giving me the correct results?
thanks
proctor
Title: Re: SelectCrossingWindow giving me more results than I want
Post by: T.Willey on July 29, 2009, 04:14:01 PM
Use a normal Acad command, and select the same way, and see if you get more than the two objects.  If so, then maybe you have objects on top of objects.

/idea
Title: Re: SelectCrossingWindow giving me more results than I want
Post by: Proctor on July 29, 2009, 05:34:31 PM
Good idea T. Willey....I tried and i no hidden objects.  :-(
Title: Re: SelectCrossingWindow giving me more results than I want
Post by: wannabe on July 30, 2009, 06:18:17 AM
Is your command altering the UCS at all? So that the crossing window is actuallly skewed, relative to the UCS view, subsequently causing those lines to be inside the window??
Title: Re: SelectCrossingWindow giving me more results than I want
Post by: SEANT on July 30, 2009, 06:42:39 AM
Another possible factor is distance from World Origin.  SelectCrossingWindow may also suffer the limitations associated with floating point precision.

Edit:
Though, I suppose that would also show up during that normal Acad command . . . . nevermind.
Title: Re: SelectCrossingWindow giving me more results than I want
Post by: Bryco on July 30, 2009, 09:54:15 AM
Is each iteration of Editor.SelectCrossingWindow in its own transaction?
Title: Re: SelectCrossingWindow giving me more results than I want
Post by: Proctor on July 30, 2009, 12:24:42 PM
Hello: Bryco, to answer your question, i start the transaction before i begin looping and i end it after i finish looping.

wannable....i don't understand about UCS? can you please explain more?


thanks,
Proctor
Title: Re: SelectCrossingWindow giving me more results than I want
Post by: Proctor on July 30, 2009, 01:12:23 PM
Something weird happened when i tried my code first thing this morning. the first time debugging, it gave me a count of 2. The second time through, it gave me a count of 3 and after that each time, i get a count of 4. this is for the exact same drawing (same lines that are at the same exact position).

so, i tried to close autocad and reopen, but it still said 4. i then copied the poly onto a new drawing and it's giving me 2 each time (tried 4 times). i tried to copy the poly to the same drawing, but i still get a count of 4.

what's happening? i don't get it....

Proctor
Title: Re: SelectCrossingWindow giving me more results than I want
Post by: Spike Wilbury on July 30, 2009, 01:14:19 PM
does this method it is not affected from the zoom ?
Title: Re: SelectCrossingWindow giving me more results than I want
Post by: Proctor on July 30, 2009, 01:22:41 PM
Esquivel: it seems it actually might be. i zoomed way in on it and ran it and it gave me the correct number (2). after, i did the opposite, zoomed out and it returned 6.

do you know what i need to do to make it consistent? - to make it give me what i visually see inside the box?

thanks so much.
Proctor
Title: Re: SelectCrossingWindow giving me more results than I want
Post by: Spike Wilbury on July 30, 2009, 01:46:58 PM
Esquivel: it seems it actually might be. i zoomed way in on it and ran it and it gave me the correct number (2). after, i did the opposite, zoomed out and it returned 6.

do you know what i need to do to make it consistent? - to make it give me what i visually see inside the box?

thanks so much.
Proctor

i remember doing something, if i found it, will try to post back... (but don't recall if it was done using C#)
Title: Re: SelectCrossingWindow giving me more results than I want
Post by: Spike Wilbury on July 30, 2009, 02:57:52 PM
http://discussion.autodesk.com/forums/thread.jspa?threadID=625944

I did a function in C# that might be useful and posted on the link above, give it a try look for where reads:  getEntitiesInOrder and my name on it...

follow the steps and see if helps.
Title: Re: SelectCrossingWindow giving me more results than I want
Post by: Proctor on July 30, 2009, 03:03:35 PM
Esquivel: I'll take a look and see if i can make it work. Thanks for sending and also for figuring out what was going on. thank you very much!!!

Proctor
 
Title: Re: SelectCrossingWindow giving me more results than I want
Post by: jnelson31 on September 26, 2019, 10:10:49 AM
I see this thread is rather old (2009) but I'm coming across the same sort of issue getting more than what I define as my SelectCrossingWindow corners.  I made sure to define it not to include neighboring lines\entities, but depending on the current zoom, it selects objects outside my defined areas.  It is like there is some sort of 'padding' around the window.  I made sure to turn snaps off.  Is there some sort of rounding going on that I don't know about when the zoom display is way out?

Only work around I can think of is to store the current display area, zoom into my selectwindow area and do my thing, then restore back to previous zoom area.

Am I doing something wrong?
Thanks for any feedback.


Code: [Select]
Public Sub SelectObjectsByCrossingWindow()
        Dim acDocEd As Editor = Application.DocumentManager.MdiActiveDocument.Editor
            'capture and remove snapmodes
            Dim SnapStore As Int32 = Application.GetSystemVariable("OSMODE")
            Application.SetSystemVariable("OSMODE", 0) '0= none

Dim acSSPrompt As PromptSelectionResult
            dim pt1 as new Point3d(8.099309, 8.428606, 0)
            Dim pt2 as new Point3d(7.372191, 10.549490, 0)
        acSSPrompt = acDocEd.SelectCrossingWindow(pt1, pt2)
Using acTrans As Transaction = db.TransactionManager.StartTransaction()
            '' If the prompt status is OK, objects were selected
        If acSSPrompt.Status = PromptStatus.OK Then
            Dim acSSet As SelectionSet = acSSPrompt.Value
                For Each acSSObj As SelectedObject In acSSet
                    If Not IsDBNull(acSSObj) Then
                         Dim acEnt As Entity = acTrans.GetObject(acSSObj.ObjectId,OpenMode.ForWrite)
                         '   acEnt.Erase
                        acEnt.ColorIndex = 6

                    End If
                Next
            'save the the changes to the database
             acTrans.Commit()
               
               Application.ShowAlertDialog("Number of objects selected: " & _
                                   acSSet.Count.ToString())
            Else
                Application.ShowAlertDialog("Number of objects selected: 0")
        End If
        End Using

     Application.SetSystemVariable("OSMODE", SnapStore)

        End Sub