public void ByPoints_PointArray_ProducesValidAdaptiveComponentAndLocations() { var pts = new Point[][] { new Point[] { Point.ByCoordinates(0, 0, 0), Point.ByCoordinates(10, 0, 10), Point.ByCoordinates(20, 0, 0) } }; var fs = FamilyType.ByName("3PointAC"); var ac = AdaptiveComponent.ByPoints(pts, fs); var locs = ac.First().Locations; var pairs = locs.Zip(pts.First(), (point, point1) => new Tuple <Point, Point>(point, point1)); // compares after unit conversion foreach (var pair in pairs) { pair.Item1.ShouldBeApproximately(pair.Item2); } var unconvertedPairs = pts.First().Zip(GetInternalPoints((FamilyInstance)ac.First().InternalElement), (point, point1) => new Tuple <Point, XYZ>(point, point1)); foreach (var pair in unconvertedPairs) { pair.Item1.ShouldBeApproximately(pair.Item2 * UnitConverter.HostToDynamoFactor(SpecTypeId.Length)); } Assert.NotNull(ac); }
/// <summary> /// Converts the MultiPoint into an adaptive component of the specified type. /// </summary> /// <param name="familyType">Type of the family.</param> /// <returns></returns> public AdaptiveComponent ToAdaptiveComponent(FamilyType familyType) { Utils.Log(string.Format("MultiPoint.ToAdaptiveComponent started...", "")); AdaptiveComponent output = null; try { if (!SessionVariables.ParametersCreated) { UtilsObjectsLocation.CheckParameters(DocumentManager.Instance.CurrentDBDocument); } output = AdaptiveComponent.ByPoints(new Point[][] { this.ShapePoints.Points.Select(p => p.RevitPoint).ToArray() }, familyType)[0]; output.SetParameterByName(ADSK_Parameters.Instance.MultiPoint.Name, this.SerializeJSON()); output.SetParameterByName(ADSK_Parameters.Instance.Update.Name, 1); output.SetParameterByName(ADSK_Parameters.Instance.Delete.Name, 0); } catch (Exception ex) { Utils.Log(ex.Message); } Utils.Log(string.Format("MultiPoint.ToAdaptiveComponent completed.", "")); return(output); }
public void ByPoints_NullFamilySymbol() { var pts = new Point[] { Point.ByCoordinates(0, 0, 0), Point.ByCoordinates(10, 0, 10), Point.ByCoordinates(20, 0, 0) }; Assert.Throws(typeof(ArgumentNullException), () => AdaptiveComponent.ByPoints(pts, null)); }
public void ByPoints_NonMatchingNumberOfPoints() { var pts = new Point[] { Point.ByCoordinates(0, 0, 0), Point.ByCoordinates(10, 0, 10) }; var fs = FamilySymbol.ByName("3PointAC"); Assert.Throws(typeof(Exception), () => AdaptiveComponent.ByPoints(pts, fs)); }
public void ByPoints_ShouldThrowExceptionWithNonMatchingNumberOfPoints() { var pts = new Point[] { Point.ByCoordinates(0, 0, 0), Point.ByCoordinates(10, 0, 10) }; var ft = FamilyType.ByName("3PointAC"); Assert.Throws(typeof(ArgumentException), () => AdaptiveComponent.ByPoints(pts, ft)); }
public void ByPoints_ValidInput() { var pts = new Point[] { Point.ByCoordinates(0, 0, 0), Point.ByCoordinates(10, 0, 10), Point.ByCoordinates(20, 0, 0) }; var fs = FamilySymbol.ByName("3PointAC"); var ac = AdaptiveComponent.ByPoints(pts, fs); Assert.NotNull(ac); }
public void ByPoints_NullPts() { var fs = FamilySymbol.ByName("3PointAC"); Assert.Throws(typeof(ArgumentNullException), () => AdaptiveComponent.ByPoints(null, fs)); }