
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Im trying to have the user select two lines and I want the Revit API to return the XYZ location of the intersection of those two lines that were selected. So far I have been able to get to the part where the user can select the model lines.
Reference referenceLine1 = choices.PickObject(ObjectType.Element,selFilter, "Please select a model line.");
Reference referenceLine2 = choices.PickObject(ObjectType.Element, selFilter, "Please select your other model line.");
Element elementLine1 = doc.GetElement(referenceLine1.ElementId);
Element elementLine2 = doc.GetElement(referenceLine2.ElementId);
How to I convert the referenceLine1 object to a Curve class so that I can use the Curve.Intersect method from the revit API to test if two lines intersect?
I am trying to do this:
IntersectionResultArray resultArray;
SetComparisonResult compareResult = Curve1.Intersect(Curve2);
I am pretty sure it involves some type of casting or a "getCurve" method of some sort, but I cannot figure out exactly how.
I saw on Jeremy Tammik post that he does this with a line object. If I have a model line, how do I do this with a Model Line that the user has selected? Here is the post where he does this.
http://thebuildingcoder.typepad.com/blog/2010/06/intersection-between-elements.html
private XYZ GetIntersection( Line line1, Line line2 ) { IntersectionResultArray results; SetComparisonResult result = line1.Intersect( line2, out results ); if( result != SetComparisonResult.Overlap ) throw new InvalidOperationException( "Input lines did not intersect." ); if( results == null || results.Size != 1 ) throw new InvalidOperationException( "Could not extract line intersection point." ); IntersectionResult iResult = results.get_Item( 0 ); return iResult.XYZPoint; }
Solved! Go to Solution.