public void ByCurveAndEqualDivisions_ValidArgs() { // create spline var pts = new[] { Point.ByCoordinates(0, 0, 0), Point.ByCoordinates(1, 0, 0), Point.ByCoordinates(3, 0, 0), Point.ByCoordinates(10, 0, 0), Point.ByCoordinates(12, 0, 0) }; var spline = NurbsCurve.ByControlPoints(pts, 3); Assert.NotNull(spline); // build model curve from spline var modCurve = ModelCurve.ByCurve(spline); Assert.NotNull(modCurve); // build dividedPath var divPath = DividedPath.ByCurveAndDivisions(modCurve.ElementCurveReference, 5); Assert.NotNull(divPath); }
public void Points() { // create spline var pts = new[] { Point.ByCoordinates(0, 0, 0), Point.ByCoordinates(1, 0, 0), Point.ByCoordinates(3, 0, 0), Point.ByCoordinates(10, 0, 0), Point.ByCoordinates(12, 0, 0) }; var spline = NurbsCurve.ByControlPoints(pts, 3); Assert.NotNull(spline); // build model curve from spline var modCurve = ModelCurve.ByCurve(spline); Assert.NotNull(modCurve); // build dividedPath var divPath = DividedPath.ByCurveAndDivisions(modCurve.ElementCurveReference, 5); Assert.NotNull(divPath); foreach (var pt in divPath.Points) { Assert.IsTrue(pts.Any(x => x.ShouldBeApproximately(pt))); } }
public void ByCurveAndEqualDivisions_NullArgument() { // build dividedPath ElementCurveReference faceRef = null; Assert.Throws(typeof(ArgumentNullException), () => DividedPath.ByCurveAndDivisions(faceRef, 5)); Autodesk.DesignScript.Geometry.Curve surface = null; Assert.Throws(typeof(ArgumentNullException), () => DividedPath.ByCurveAndDivisions(surface, 5)); Revit.Elements.Element element = null; Assert.Throws(typeof(ArgumentNullException), () => DividedPath.ByCurveAndDivisions(element, 5)); }
public Result Execute(ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements) { UIDocument doc = commandData.Application.ActiveUIDocument; using (Transaction trans = new Transaction(doc.Document)) { trans.Start("Select model curves in revit document"); IList <Reference> refList = doc.Selection.PickObjects(Autodesk.Revit.UI.Selection.ObjectType.Element, "Please pick some model curves in revit document" ); DividedPath dpath = DividedPath.Create(doc.Document, refList); trans.Commit(); } return(Result.Succeeded); }
public void ByCurveAndEqualDivisions_InvalidDivisions() { // create spline var pts = new[] { Point.ByCoordinates(0, 0, 0), Point.ByCoordinates(1, 0, 0), Point.ByCoordinates(3, 0, 0), Point.ByCoordinates(10, 0, 0), Point.ByCoordinates(12, 0, 0) }; var spline = NurbsCurve.ByControlPoints(pts, 3); Assert.NotNull(spline); // build model curve from spline var modCurve = ModelCurve.ByCurve(spline); Assert.NotNull(modCurve); // build dividedPath Assert.Throws(typeof(Exception), () => DividedPath.ByCurveAndDivisions(modCurve.ElementCurveReference, 0)); }
public void Points() { // create spline var pts = new[] { Point.ByCoordinates(0, 0, 0), Point.ByCoordinates(1, 0, 0), Point.ByCoordinates(3, 0, 0), Point.ByCoordinates(10, 0, 0), Point.ByCoordinates(12, 0, 0) }; var spline = NurbsCurve.ByControlPoints(pts, 3); Assert.NotNull(spline); // build model curve from spline var modCurve = ModelCurve.ByCurve(spline); Assert.NotNull(modCurve); // build dividedPath var divPath = DividedPath.ByCurveAndDivisions(modCurve.ElementCurveReference, 5); Assert.NotNull(divPath); var divPathPts = divPath.Points; Assert.AreEqual(5, divPathPts.Count()); foreach (var pt in divPathPts) { // all of the points should be along the curve spline.DistanceTo(pt).ShouldBeApproximately(0); } }
public void ByCurveAndEqualDivisions_NullArgument() { // build dividedPath Assert.Throws(typeof(ArgumentNullException), () => DividedPath.ByCurveAndDivisions(null, 5)); }