public void ByParameterOnCurveReference_ShouldPlaceReferencePointCorrectly() { var l = Line.ByStartPointEndPoint(Point.ByCoordinates(0, 0, 0), Point.ByCoordinates(1, 0, 0)); var modelCurve = ModelCurve.ByCurve(l); var rp = ReferencePoint.ByParameterOnCurveReference(modelCurve.ElementCurveReference, 0.5); var pt = Point.ByCoordinates(0.5, 0, 0); rp.Point.ShouldBeApproximately(pt); InternalPosition(rp).ShouldBeApproximately(pt.InHostUnits()); }
public void ByLengthOnCurveReference_ShouldPlaceReferencePointCorrectly() { var l = Line.ByStartPointEndPoint(Point.ByCoordinates(0, 0, 0), Point.ByCoordinates(1, 0, 0)); var modelCurve = ModelCurve.ByCurve(l); var rp = ReferencePoint.ByLengthOnCurveReference(modelCurve.ElementCurveReference, 0.5); DocumentManager.Instance.CurrentDBDocument.Regenerate(); var pt = Point.ByCoordinates(0.5, 0, 0); rp.Point.ShouldBeApproximately(pt); InternalPosition(rp).ShouldBeApproximately(pt.InHostUnits()); }
public void ByPointsOnCurve_ProducesValidAdaptiveComponentAndLocations() { // create spline var pts = new Autodesk.DesignScript.Geometry.Point[] { 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); // obtain the family from the document var ft = FamilyType.ByName("3PointAC"); // build the AC var parms = new double[] { 0, 0.5, 1 }; var ac = AdaptiveComponent.ByParametersOnCurveReference(parms, modCurve.ElementCurveReference, ft); // with unit conversion foreach (var pt in ac.Locations) { spline.DistanceTo(pt).ShouldBeApproximately(0); } // without unit conversion var unconvertedPoints = GetInternalPoints((FamilyInstance)ac.InternalElement); foreach (var pt in unconvertedPoints) { spline.DistanceTo(pt.ToPoint()).ShouldBeApproximately(0); } Assert.NotNull(ac); }