.NET
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Way of getting all objects between two points.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hey all.
Is there any way of getting ALL objects a Line/ray intersects with?
I am thinking of something like:
*Pseudocode*
Ray ray = new Ray(); ray.To = dest; ray.From = start;
ray.Fire(); var obj = ray.GetFirstHitObject(); /* or null if nothing */ // continue here //
I don't even need the object, a simple true if it hits something, or false if not is enough for me.
Greetings from Austria,
Thomas
Solved! Go to Solution.
Re: Way of getting all objects between two points.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
The Entity class has an IntersectWith() method that tells if the entity intersects another Entity.
Re: Way of getting all objects between two points.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi,
If you are trying to select the objects intersected, you can use Editor.SelectFence(fencePoints, SomeFilter). If you need the intersection points, then use both fence selection to obtain the objects and TT suggestion of IntersectWith to get the points.
Regards,
Gaston Nunez
Re: Way of getting all objects between two points.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
DiningPhilosopher wrote:The Entity class has an IntersectWith() method that tells if the entity intersects another Entity.
Thank you, but that was not the question.
Re: Way of getting all objects between two points.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
e1028439 wrote:Thank you, but that was not the question.
It wasn't the question, it was one answer to how to do what the question asked.
You can also try Gaston's suggestion, assuming all the candidate objects are visible in the current view.
Re: Way of getting all objects between two points.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
e1028439 wrote:
DiningPhilosopher wrote:
The Entity class has an IntersectWith() method that tells if the entity intersects another Entity.
Thank you, but that was not the question.
Ok! You have to iterate ALL entities in current space (ModelSpace or PaperSpace) and find intersection of entities and yours line/ray. Method with Editor.SelectFence has so many restrictions...
Re: Way of getting all objects between two points.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Alexander.Rivilis wrote:Ok! You have to iterate ALL entities in current space (ModelSpace or PaperSpace) and find intersection of entities and yours line/ray. Method with Editor.SelectFence has so many restrictions...
Could you enlighten me about the restrictions of SelectFence()? the only thing i need is to know IF there is something in the way, neither what, nor how big it is.
And if i would give SelectFence a Point modell of a cube for example, would it get all objects that intersect with it?
Thanks again for all the answers ![]()
Re: Way of getting all objects between two points.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
e1028439 wrote:And if i would give SelectFence a Point modell of a cube for example, would it get all objects that intersect with it?
No. Editor.SelectFence allow to select entities:
1. Visible on active view.
2. Projection of those on active view has intersection with "fence".
3. If entity has not continuous linetype - it will be problem.
4. Zoom factor of current view also affect selection.
5. Allow select entities but not found intersection points - only fact of intersection.
6. Dependent of entities type.
7. Points have to be in UCS (not in WCS)
8. etc.,etc.,etc...
Re: Way of getting all objects between two points.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I think you need to create a "Virtual Line" (named vl in my code) and do a window selection based on youre 2 points.
The code beneath is not tested but I think it should look like this:
Private Sub MyIntersection()
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim ed As Editor = doc.Editor
Dim db As Database = doc.Database
Dim p3dc As Point3dCollection = Nothing
Dim ppo As New PromptPointOptions(vbCrLf & "Select point: ")
ppo.AllowNone = False
Dim pt1 As Point3d = ed.GetPoint(ppo).Value
Dim pt2 As Point3d = ed.GetPoint(ppo).Value
Dim psr As PromptSelectionResult = ed.SelectWindow(pt1, pt2)
Dim vl As New Line(pt1, pt2)
Dim oic As New ObjectIdCollection
If psr.Status = PromptStatus.OK Then
Using dl As DocumentLock = doc.LockDocument
Using tr As Transaction = db.TransactionManager.StartTransaction
For Each so As SelectedObject In psr.Value
p3dc = Nothing
Dim ent As Entity = TryCast(tr.GetObject(so.ObjectId, OpenMode.ForRead), Entity)
Try
vl.IntersectWith(ent, Intersect.ExtendBoth, p3dc, 0, 0)
If p3dc.Count > 0 Then
oic.Add(ent.ObjectId)
End If
Catch
End Try
Next
End Using
'Now youre intersecting objects are in the oic (objectIdCollection)
End Using
End If
End SubRegards
Peter
Re: Way of getting all objects between two points.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
RPeter wrote:I think you need to create a "Virtual Line" (named vl in my code) and do a window selection based on youre 2 points.
Regards
Peter
Dear Peter, i modified your code a little bit to use Editor.SelectCrossingWindow, and now it throws a eNotImplementedYet exeption on the following line >vl.IntersectWith()<.
I needed to change to SelectCrossingWindow because i need all objects i hit, not only the ones i completely surround.
Greetings
Thomas





