Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
public static ModelCurve CreateModelLine(Document doc,
XYZ pmin,
XYZ pmax)
double _eps = 1.0e-9;
if (pmin.DistanceTo(pmax) < _eps) return null;
XYZ v = pmax - pmin;
double dxy = Math.Abs(v.X) + Math.Abs(v.Y);
XYZ w = (dxy > _eps)
? XYZ.BasisZ
: XYZ.BasisY;
XYZ norm = v.CrossProduct(w).Normalize();
XYZ tpmin = new XYZ(pmin.X,pmin.Y,0);
Plane plane = Autodesk.Revit.DB.Plane.CreateByNormalAndOrigin(norm, tpmin);
SketchPlane sketchPlane = Autodesk.Revit.DB.SketchPlane.Create(doc, plane);
Line line = Line.CreateBound(tpmin, pmax);
ModelCurve modelCurve = doc.Create.NewModelCurve(line, sketchPlane);
return modelCurve;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment