static RevSurface FromConicalSurface(DB.XYZ origin, DB.XYZ xDir, DB.XYZ yDir, DB.XYZ zDir, double halfAngle, DB.BoundingBoxUV bboxUV) { var ctol = Revit.ShortCurveTolerance; var atol = Revit.AngleTolerance * 10.0; var uu = new Interval(bboxUV.Min.U - atol, bboxUV.Max.U + atol); var vv = new Interval(bboxUV.Min.V - ctol, bboxUV.Max.V + ctol); var o = origin.ToRhino(); var x = (Vector3d)xDir.Normalize().ToRhino(); var z = (Vector3d)zDir.Normalize().ToRhino(); var axis = new Line(o, o + z); var dir = z + x * Math.Tan(halfAngle); dir.Unitize(); var curve = new LineCurve ( new Line ( o + (dir * vv.Min), o + (dir * vv.Max) ), vv.Min, vv.Max ); return(RevSurface.Create(curve, axis, uu.Min, uu.Max)); }
static RevSurface FromCylindricalSurface(DB.XYZ origin, DB.XYZ xDir, DB.XYZ yDir, DB.XYZ zDir, double radius, DB.BoundingBoxUV bboxUV) { var ctol = Revit.ShortCurveTolerance; var atol = Revit.AngleTolerance; var uu = new Interval(bboxUV.Min.U - atol, bboxUV.Max.U + atol); var vv = new Interval(bboxUV.Min.V - ctol, bboxUV.Max.V + ctol); var o = origin.ToRhino(); var x = (Vector3d)xDir.Normalize().ToRhino(); var z = (Vector3d)zDir.Normalize().ToRhino(); var axis = new Line(o, o + z); var curve = new LineCurve ( new Line ( o + (x * radius) + (z * vv.Min), o + (x * radius) + (z * vv.Max) ), vv.Min, vv.Max ); return(RevSurface.Create(curve, axis, uu.Min, uu.Max)); }
static PlaneSurface FromPlane(DB.XYZ origin, DB.XYZ xDir, DB.XYZ yDir, DB.XYZ zDir, DB.BoundingBoxUV bboxUV) { var ctol = Revit.ShortCurveTolerance; var uu = new Interval(bboxUV.Min.U - ctol, bboxUV.Max.U + ctol); var vv = new Interval(bboxUV.Min.V - ctol, bboxUV.Max.V + ctol); return(new PlaneSurface ( new Plane(origin.ToRhino(), (Vector3d)xDir.ToRhino(), (Vector3d)yDir.ToRhino()), uu, vv )); }
static RevSurface FromRevolvedSurface(DB.XYZ origin, DB.XYZ xDir, DB.XYZ yDir, DB.XYZ zDir, DB.Curve curve, DB.BoundingBoxUV bboxUV) { var ctol = Revit.ShortCurveTolerance; var atol = Revit.AngleTolerance; var uu = new Interval(bboxUV.Min.U - atol, bboxUV.Max.U + atol); var o = origin.ToRhino(); var z = (Vector3d)zDir.Normalize().ToRhino(); var axis = new Line(o, o + z); using (var ECStoWCS = new DB.Transform(DB.Transform.Identity) { Origin = origin, BasisX = xDir.Normalize(), BasisY = yDir.Normalize(), BasisZ = zDir.Normalize() }) { var c = curve.CreateTransformed(ECStoWCS).ToRhino().Extend(CurveEnd.Both, ctol, CurveExtensionStyle.Smooth); return(RevSurface.Create(c, axis, uu.Min, uu.Max)); } }
static Surface FromRuledSurface(IList <DB.Curve> curves, DB.XYZ start, DB.XYZ end, DB.BoundingBoxUV bboxUV) { var ctol = Revit.ShortCurveTolerance; var cs = curves.Select ( x => { var c = x.ToRhino(); c.Reverse(); return(c.Extend(CurveEnd.Both, ctol, CurveExtensionStyle.Smooth)); } ); Point3d p0 = start?.ToRhino() ?? Point3d.Unset, pN = end?.ToRhino() ?? Point3d.Unset; var lofts = Brep.CreateFromLoft(cs, p0, pN, LoftType.Straight, false); if (lofts.Length == 1 && lofts[0].Faces.Count == 1) { return(lofts[0].Faces[0].DuplicateSurface()); } return(null); }