Create a plane based on CurveElement (Line)

Create a plane based on CurveElement (Line)

adam_konca
Enthusiast Enthusiast
407 Views
1 Reply
Message 1 of 2

Create a plane based on CurveElement (Line)

adam_konca
Enthusiast
Enthusiast

I am using ElementTransformUtils.MirrorElement method to mirror some elements and obviously I need a plane for that. The requirement is that the user selects a curve element (most likely a simple line) and I have to create a plane based on this line, so I do the following:

var startPoint = curveElement.GeometryCurve.GetEndPoint(0);
var endPoint = curveElement.GeometryCurve.GetEndPoint(1);
var plane = Plane.CreateByThreePoints(startPoint, endPoint, new XYZ(endPoint.X, endPoint.Y, endPoint.Z + 10));

This works just fine, but I am curious if there's a better way to do it. Technically, the user always operates on XY plane, so I always add something to Z (see the code above) in order to create the mirror plane, but what about the 3D view? I imagine that a simple line is not sufficient to create a mirror plane in 3D, but a line + source element to copy should probably be doable by using normal and origin? How would you approach this in the Revit API?

0 Likes
408 Views
1 Reply
Reply (1)
Message 2 of 2

jeremy_tammik
Alumni
Alumni

Yes, there is definitely a better approach. Your code will only work for a specific plane. This is not a Revit API question, but a purely geometric one. You need to ensure that the selected curve is planar and not twisted in 3D space, with bits sticking out of the 2D plane. Then you need to determine three non-collinear points in that 2D plane in space. The Building Coder has sample code that achieves this in module Creator.cs:

  

   

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes