- Admin
- Revit API
- Hits: 46
Revit. Aspect of Solid.IntersectWithCurve method: Origin of the result Line
Earlier we had a post about Origin in PlanarFace, where we wrote that Origin may not be within the PlanarFace plane contour boundaries. And recently we came across another undocumented aspect of Revit API, which in some cases can lead to incorrect operation of the intended algorithm. And this aspect is the Origin property of a Line obtained by the Solid.IntersectWithCurve method.
Let's describe it by example: let's create an element with a solid body in an empty project and take its Solid:
var uiDoc = commandData.Application.ActiveUIDocument;
var doc = uiDoc.Document;
var element = doc.GetElement(uiDoc.Selection.PickObject(ObjectType.Element));
var solid = (Solid)element
.get_Geometry(new Options { DetailLevel = ViewDetailLevel.Fine })
.GetTransformed(Transform.Identity)
.First(e => e is Solid { Volume: > 0 });
Since we used a column for the example, we know for sure that it has an insertion point. Let's take this point and use it to create a long auxiliary Line:
var pt = ((LocationPoint)element.Location).Point;
var helpLine = Line.CreateBound(
pt - (XYZ.BasisZ * 1000),
pt + (XYZ.BasisZ * 1000));
Then we use the Solid.IntersectWithCurve method and get a Line located inside the Solid of our element:
var result = solid.IntersectWithCurve(
helpLine,
new SolidCurveIntersectionOptions { ResultType = SolidCurveIntersectionMode.CurveSegmentsInside });
var insideLine = (Line)result.GetCurveSegment(0);
So, if we now look at the properties of this Line, we see that its Origin remains the same as the original auxiliary Line! And if you take the parameters of this Line at the beginning and at the end, you will get not the most expected values:
While there are not many cases where this can negatively affect the algorithm, there are still cases. Therefore, it is better to know about this feature in advance