Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello, I'm trying to find a point that specifies the intersection of two lines. I have seen that there is a curve.Intersect (curve) that returns a SetComparisonResult. There is a possibility of finding an XYZ of that intersection or how you could do it.
public Result Execute(ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
UIApplication uiApp = commandData.Application;
UIDocument uiDoc = uiApp.ActiveUIDocument;
Document doc = uiDoc.Document;
// Conduit selection
ElementId conduitElementId = uiDoc.Selection.PickObject(Autodesk.Revit.UI.Selection.ObjectType.Element).ElementId;
Element conduitElement = doc.GetElement(conduitElementId);
// Get curve conduit
LocationCurve conduitCurveLocation = conduitElement.Location as LocationCurve;
Curve conduitCurve = conduitCurveLocation.Curve;
// Get points conduit
XYZ startConduitCurvePoint = conduitCurve.GetEndPoint(0);
XYZ endConduitCurvePoint = conduitCurve.GetEndPoint(1);
// Beam selection
ElementId beamElementId = uiDoc.Selection.PickObject(Autodesk.Revit.UI.Selection.ObjectType.Element).ElementId;
Element beamElement = doc.GetElement(beamElementId);
// Get the beam inferior point y restar la mitad del diametro del elemento
double beamInferiorPoint = beamElement.get_BoundingBox(doc.ActiveView).Min.Z - conduitElement.get_Parameter(BuiltInParameter.RBS_CONDUIT_DIAMETER_PARAM).AsDouble() /2;
// Get curve beam
LocationCurve beamCurveLocation = beamElement.Location as LocationCurve;
Curve beamCurve = beamCurveLocation.Curve;
// Get points beam
XYZ startBeamCurvePoint = beamCurve.GetEndPoint(0);
XYZ endBeamCurvePoint = beamCurve.GetEndPoint(1);
// Get points Conduit
XYZ startConduitPoint = new XYZ(startConduitCurvePoint.X, startConduitCurvePoint.Y, beamInferiorPoint);
XYZ endConduitPoint = new XYZ(endConduitCurvePoint.X, endConduitCurvePoint.Y, beamInferiorPoint);
// Get points Beam
XYZ startBeamPoint = new XYZ(startBeamCurvePoint.X, startBeamCurvePoint.Y, beamInferiorPoint);
XYZ endBeamPoint = new XYZ(endBeamCurvePoint.X, endBeamCurvePoint.Y, beamInferiorPoint);
// Line to get the point (Z is equal for two Lines)
Line conduitLine = Line.CreateBound(startConduitPoint, endConduitPoint);
Line beamLine = Line.CreateBound(startBeamCurvePoint, endBeamCurvePoint);
// Get the intersection point
conduitLine.Intersect(beamLine);// TODO: Get the point
return Result.Succeeded;
}
Solved! Go to Solution.