Last active
May 18, 2021 17:57
-
-
Save chuongmep/e846faf059eaf23df1a34f9871ec9430 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
//MessageBox.Show(plane.Origin.ToString()); | |
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