Hi All,
I've run into a snag. I've searched high and low through the Revit SDK documentation as well as various forums and I haven't been able to find a solution. In the Revit family environment I am drawing two reference points (RefArrPts) and drawing a reference line (crv) that connects the two points. In the next step I extract the reference points from the reference line (CrvRefPts). In the last step I try to extract the XY plane (plnRef) from the reference points (CrvRefPts). The returned value is of type REFERENCE, the element id of plnRef is the same element id of the CrvStRefPt. The method GetCoordinatePlaneReferenceXY() states it returns a reference to the XY plane of the coordinate system, but it is returning a reference to the point. Would you happen to know what I'm doing wrong? Any guidance would be greatly appreciated.
You can generate those planes yourself like this:
XYZ p1 = first point XYZ q2 = second point XYZ v = p2 - p1 XYZ normal = v.Normalise Plane plane1 = Plane.Create( p1, normal ) Plane plane2 = Plane.Create( p2, normal )
It depends what you want to do with them, of course.
If you require a reference to an existing plane element in the model, you could search all of them for one with a matching origin and normal vector.
I hope this helps.
Cheers,
Jeremy
Hi Jeremy,
Thanks for the reply. Your solution would work, but my end goal is slightly different. The reason for extracting these planes is to then draw geometry on them (via the SDK) and then allow the user to move the line and have the constrained geometry update. The steps the user would execute are as follows:
1) User will run command that will draw the line and the geometry on the reference planes
2) User can move the line as they desire within the model, all geometry will update.
the planes you're after, are faces of the solid of the reference line (the solid in crv.get_geometry()). Unfortunately they don't have a reference. If you require a reference to host the geometry, then you'd have to host 2 extra reference points on the reference line and use the references from those.
ReferencePoint rPnt0 = null; ReferencePoint rPnt1 = null; using (SubTransaction st = new SubTransaction(RvtDoc)) { st.Start(); PointLocationOnCurve location = new PointLocationOnCurve(PointOnCurveMeasurementType.NormalizedCurveParameter, 0, PointOnCurveMeasureFrom.Beginning); PointOnEdge pointOnEdge = RvtDoc.Application.Create.NewPointOnEdge( crv.GeometryCurve.Reference, location); rPnt0 = RvtDoc.FamilyCreate.NewReferencePoint(pointOnEdge); location = new PointLocationOnCurve(PointOnCurveMeasurementType.NormalizedCurveParameter, 1, PointOnCurveMeasureFrom.Beginning); pointOnEdge = RvtDoc.Application.Create.NewPointOnEdge( crv.GeometryCurve.Reference, location); rPnt1 = RvtDoc.FamilyCreate.NewReferencePoint(pointOnEdge); st.Commit(); } ReferencePointArray CrvRefPts = new ReferencePointArray(); CrvRefPts.Append(rPnt0); CrvRefPts.Append(rPnt1); ReferencePoint CrvStRefPt = CrvRefPts.get_Item(0); plnRef = CrvStRefPt.GetCoordinatePlaneReferenceYZ();
Hi Fair59,
Thanks for your response. You worded it quite clear. I'm surprised a user cannot extract the end planes from the reference line. I always hesitate having to create more geometry on top of existing geometry to help keep the file size down and also simplify the code, but it seems there is no other way (yet). I will try to add this topic to future wish list for the Revit SDK. Your solution is a good alternative. Thanks for your help!
Cheers.