Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
'Find Nearest' Method searching by ray in 3D.
Is there a way to searching by ray in 2D ?
Solved! Go to Solution.
'Find Nearest' Method searching by ray in 3D.
Is there a way to searching by ray in 2D ?
Solved! Go to Solution.
No it uses a 3D view.
What type of flat element are you looking to find by aiming a 2D vector at? If you describe the problem there may be a solution in terms of either converting it to 3D so it can be used or solving it in 2D.
i have ray from 'pipe 1' and i need retrieve 'pipe 2'
it's works if two pipes has same hight, else i can't retrieve 'pipe 2'
The slope of one of the pipes has to change to suit the other i.e. how do you know in the first place that pipe 1 intersects with pipe 2 along it's length?
My approach (if that is the intension) would be to find the intersection in 2D i.e. you have a linear equation for each line and two unknows (two equations and two unknowns). This forms a simultaneous equation that can be solved to find X,Y intersection.
Should also note that yours is a form of intersection where you would observe the intersection must be at the X coordinate of the vertical line ends and the Y of the horizontal line ends i.e. only the horizontal conforms with y = mx + c (where m is 0) but vertical line can be observed as being vertical (meaning you know from observation where x is). Most people would use matrix algebra anyway to solve I guess.
Once you have the 2D point you have to decide which pipe slope you will change if they don't already intersect. You would work out the 2D distance from the pipe end you want to keep and the intersection. Then multiply this by slope of pipe you want to keep to find target level on other pipe alignment. Then lastly adjust other slope to meet that 3D intersection i.e. difference between level of end on second pipe (you want to keep) and 3D intersection divided by 2D distance of those things (this is the slope of second pipe from the fixed end). Once you have that slope you can again work from the fixed end and extend through to the second end at the given slope.
There is probably a solution using a solid whereby you create a solid with face aligned with one of the pipe centre lines and then use Face.Intersect(curve, IntersectionResultArray) with curve of the other pipe.
There is a far simpler way:
To find pipes nearest to a pipe just flatten the pipe curves and make them unbound. Then use Curve.Intersect(curve).
Find intersections nearest to your pipe end and see if that relates to a pipe you are interested in by level. You would create a class structure containing the pipe id and the unbound 2d line that originated from it to link the two things. Or could use Dictionary(of ElementId, Line)
As a starting point you have to filter the pipes you are looking for into level bands. You don't want to be matching against all pipes on all levels. e.g. from the pipe you are interested in get the bounding box Z values and add a tolerance + to max - to min. Then use that to find other pipes with end points within that limit.