Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
public static ModelCurve CreateModelLine(Document doc,
XYZ p,
XYZ q)
double _eps = 1.0e-9;
if (p.DistanceTo(q) < _eps) return null;
XYZ v = q - p;
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 temp = new XYZ(p.X,p.Y,0);
Plane plane = Autodesk.Revit.DB.Plane.CreateByNormalAndOrigin(norm, p);
SketchPlane sketchPlane = Autodesk.Revit.DB.SketchPlane.Create(doc, plane);
Line line = Line.CreateBound(p, q);
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