public void Arc_Tilted()
        {
            var p1 = Point.ByCoordinates(4.3957, 7.96146, 0);
            var p2 = Point.ByCoordinates(6.49355, 5.98396, 2.28352);
            var p3 = Point.ByCoordinates(7.11897, 2.70101, 3.81878);


            var arc = Arc.ByThreePoints(p1, p2, p3);

            var revitCurve = arc.ToRevitType(false);

            Assert.NotNull(revitCurve);

            Assert.IsAssignableFrom <Autodesk.Revit.DB.Arc>(revitCurve);

            var revitArc = (Autodesk.Revit.DB.Arc)revitCurve;

            revitArc.Center.X.ShouldBeApproximately(2, 0.0001);
            revitArc.Center.Y.ShouldBeApproximately(2, 0.0001);
            revitArc.Center.Z.ShouldBeApproximately(0, 0.0001);

            arc.CenterPoint.ShouldBeApproximately(revitArc.Center.ToPoint(false));
            arc.Radius.ShouldBeApproximately(revitArc.Radius);
            Math.Abs(arc.Normal.Dot(revitArc.Normal.ToVector())).ShouldBeApproximately(1);
        }
Exemple #2
0
        public void NurbsCurve()
        {
            HostFactory.Instance.StartUp();

            // create spline
            var pts = new Autodesk.DesignScript.Geometry.Point[]
            {
                Autodesk.DesignScript.Geometry.Point.ByCoordinates(0, 0, 0),
                Autodesk.DesignScript.Geometry.Point.ByCoordinates(1, 0, 0),
                Autodesk.DesignScript.Geometry.Point.ByCoordinates(3, 0, 0),
                Autodesk.DesignScript.Geometry.Point.ByCoordinates(10, 0, 0)
            };

            var spline = Autodesk.DesignScript.Geometry.NurbsCurve.ByControlPoints(pts, 3);

            Assert.NotNull(spline);
            Assert.AreEqual(3, spline.Degree);
            var eval0 = spline.PointAtParameter(0);
            var eval1 = spline.PointAtParameter(1);

            var expectedPoint0 = Point.ByCoordinates(0, 0, 0);
            var expectedPoint1 = Point.ByCoordinates(10, 0, 0);

            Assert.AreEqual(0, expectedPoint0.DistanceTo(eval0), 1e-6);
            Assert.AreEqual(0, expectedPoint1.DistanceTo(eval1), 1e-6);

            var closestPoint0 = spline.GetClosestPoint(expectedPoint0);

            Assert.AreEqual(0, expectedPoint0.DistanceTo(closestPoint0), 1e-6);

            HostFactory.Instance.ShutDown();
        }
Exemple #3
0
        public void ByTextSketchPlaneAndPosition_ValidArgs()
        {
            var origin = Point.ByCoordinates(1, 2, 3);
            var normal = Vector.ByCoordinates(0, 0, 1);
            var plane  = Plane.ByOriginNormal(origin, normal);
            var text   = "Snickers - why wait?";

            var name          = "Model Text 1";
            var modelTextType = ModelTextType.ByName(name);

            var sketchPlane = SketchPlane.ByPlane(plane);
            var depth       = 1;
            var x           = 10;
            var y           = 3;
            var mt          = ModelText.ByTextSketchPlaneAndPosition(text, sketchPlane, x, y, depth, modelTextType);

            Assert.NotNull(mt);
            Assert.NotNull(mt.InternalElement);
            Assert.IsTrue(DocumentManager.Instance.ElementExistsInDocument(
                              new ElementUUID(mt.InternalElement.UniqueId)));

            mt.Depth.ShouldBeApproximately(depth);

            // with unit conversion
            InternalDepth(mt).ShouldBeApproximately(depth * UnitConverter.DynamoToHostFactor);

            var expectedInternalLoc =
                origin.InHostUnits()
                .Add(Vector.XAxis().Scale(x * UnitConverter.DynamoToHostFactor))
                .Add(Vector.YAxis().Scale(y * UnitConverter.DynamoToHostFactor));

            InternalLocation(mt).ShouldBeApproximately(expectedInternalLoc);
        }
        /// <summary>
        /// This node will select grids along a model curve element ordered based on the start of the model curve.
        /// This works in the active view. So whatever plan representation your grids have, that is what is used.
        /// </summary>
        /// <param name="modelCurve">Revit model curve to select grids along.</param>
        /// <returns name="orderedGrids">The intersecting grids ordered from beginning to end of the line.</returns>
        public static List <global::Revit.Elements.Grid> IntersectingGridsByModelCurve(global::Revit.Elements.ModelCurve modelCurve)
        {
            ModelCurve mCurve = modelCurve.InternalElement as ModelCurve;

            Autodesk.Revit.DB.Document doc = DocumentManager.Instance.CurrentDBDocument;

            List <global::Revit.Elements.Grid> intersectingGrids = new List <global::Revit.Elements.Grid>();

            IList <Autodesk.Revit.DB.Element> grids = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Grids).WhereElementIsNotElementType().ToElements();

            foreach (var grid in grids)
            {
                Grid  g  = grid as Grid;
                Curve c  = g.GetCurvesInView(DatumExtentType.ViewSpecific, doc.ActiveView).First();
                Curve c2 = mCurve.GeometryCurve;

                Point pt1 = Point.ByCoordinates(0, 0, c.GetEndPoint(0).Z);
                Point pt2 = Point.ByCoordinates(0, 0, c2.GetEndPoint(0).Z);
                XYZ   vec = Vector.ByTwoPoints(pt2, pt1).ToRevitType();

                var transformed = c2.CreateTransformed(Transform.CreateTranslation(vec));

                SetComparisonResult test = c.Intersect(transformed);

                if (test == SetComparisonResult.Overlap ||
                    test == SetComparisonResult.Subset ||
                    test == SetComparisonResult.Superset ||
                    test == SetComparisonResult.Equal)
                {
                    intersectingGrids.Add(g.ToDSType(true) as global::Revit.Elements.Grid);
                }
            }

            return(intersectingGrids.OrderBy(g => g.Curve.DistanceTo(modelCurve.Curve.StartPoint)).ToList());
        }
        public void ByPointsOnCurve_ValidInput()
        {
            // 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 fs = FamilySymbol.ByName("3PointAC");

            // build the AC
            var parms = new double[]
            {
                0, 0.5, 1
            };

            var ac = AdaptiveComponent.ByParametersOnCurveReference(parms, modCurve.ElementCurveReference, fs);

            Assert.NotNull(ac);
        }
        /// <summary>
        /// Synchronize the manipulator position with the node's value.
        /// </summary>
        protected override void UpdatePosition()
        {
            Active = false;
            if (Node == null || !indexedAxisNodePairs.Any())
            {
                return;
            }

            if (origin == null)
            {
                origin = Point.Origin(); //First time initialization
            }

            //Node output could be a collection, consider the first item as origin.
            Point pt = GetFirstValueFromNode(Node) as Point;

            if (null == pt)
            {
                return;             //The node output is not Point, could be a function object.
            }
            //Don't cache pt directly here, we need to create a copy, because
            //pt may be GC'ed by VM.
            origin = Point.ByCoordinates(pt.X, pt.Y, pt.Z);

            Active = true;
        }
        public void CurvesAreSimilar_NurbsCurve()
        {
            var a1 = Point.ByCoordinates(0, 0);
            var a2 = Point.ByCoordinates(1, 1);
            var a3 = Point.ByCoordinates(2, -1);
            var a4 = Point.ByCoordinates(3, 0);

            var b1 = Point.ByCoordinates(0, 0);
            var b2 = Point.ByCoordinates(1, -1);
            var b3 = Point.ByCoordinates(2, 1);
            var b4 = Point.ByCoordinates(3, 0);

            var c1 = Point.ByCoordinates(3, 0);
            var c2 = Point.ByCoordinates(2, 1);
            var c3 = Point.ByCoordinates(1, -1);
            var c4 = Point.ByCoordinates(0, 0);

            var nurbs1 = NurbsCurve.ByPoints(new[] { a1, a2, a3, a4 });
            var nurbs2 = NurbsCurve.ByPoints(new[] { b1, b2, b3, b4 });
            var nurbs3 = NurbsCurve.ByPoints(new[] { c1, c2, c3, c4 });

            var revitNurbs1 = nurbs1.ToRevitType();
            var revitNurbs2 = nurbs2.ToRevitType();
            var revitNurbs3 = nurbs3.ToRevitType();

            Assert.True(CurveUtils.CurvesAreSimilar(revitNurbs1, revitNurbs1));
            Assert.False(CurveUtils.CurvesAreSimilar(revitNurbs1, revitNurbs2));
            Assert.False(CurveUtils.CurvesAreSimilar(revitNurbs2, revitNurbs3));
        }
Exemple #8
0
        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);
        }
        public void EllipseArc_Basic()
        {
            var o          = Point.ByCoordinates(1, 2, 3);
            var n          = Vector.ByCoordinates(2, 3, 4, true);
            var pl         = Autodesk.DesignScript.Geometry.Plane.ByOriginNormal(o, n);
            var ellipseArc = EllipseArc.ByPlaneRadiiStartAngleSweepAngle(pl, 10, 5, 45, 90);

            var revitCurve = ellipseArc.ToRevitType();

            Assert.NotNull(revitCurve);
            Assert.IsAssignableFrom <Autodesk.Revit.DB.Ellipse>(revitCurve);

            var revitEllipse = (Autodesk.Revit.DB.Ellipse)revitCurve;

            revitEllipse.GetEndParameter(0).ToDegrees().AssertShouldBeApproximately(ellipseArc.StartAngle);
            revitEllipse.GetEndParameter(1).ToDegrees().AssertShouldBeApproximately(ellipseArc.StartAngle + ellipseArc.SweepAngle);
            revitEllipse.GetEndPoint(0).AssertShouldBeApproximately(ellipseArc.StartPoint);
            revitEllipse.GetEndPoint(1).AssertShouldBeApproximately(ellipseArc.EndPoint);

            revitEllipse.Length.AssertShouldBeApproximately(ellipseArc.Length);

            // ClosestPointTo fails in ProtoGeometry
            var tessPts = revitEllipse.Tessellate();

            //assert the tesselation is very close to original curve
            //what's the best tolerance to use here?
            foreach (var pt in tessPts)
            {
                var closestPt = ellipseArc.GetClosestPoint(pt.ToPoint());
                Assert.Less(closestPt.DistanceTo(pt.ToPoint()), 1e-6);
            }
        }
        public void Rotate_ZAxis()
        {
            var famSym  = FamilyType.ByName("Box");
            var pt      = Point.ByCoordinates(0, 1, 2);
            var famInst = FamilyInstance.ByPoint(famSym, pt);

            Assert.NotNull(famInst);

            var transform = famInst.InternalFamilyInstance.GetTransform();

            double[] rotationAngles;
            TransformUtils.ExtractEularAnglesFromTransform(transform, out rotationAngles);
            Assert.AreEqual(0.0, rotationAngles[0]);

            RevitServices.Persistence.DocumentManager.Instance.CurrentDBDocument.Regenerate();

            famInst.SetRotation(30);
            transform = famInst.InternalFamilyInstance.GetTransform();
            TransformUtils.ExtractEularAnglesFromTransform(transform, out rotationAngles);
            Assert.AreEqual(30.0, rotationAngles[0] * 180 / Math.PI, 1.0e-6);

            famInst.SetRotation(60);
            transform = famInst.InternalFamilyInstance.GetTransform();
            TransformUtils.ExtractEularAnglesFromTransform(transform, out rotationAngles);
            Assert.AreEqual(60.0, rotationAngles[0] * 180 / Math.PI, 1.0e-6);
        }
Exemple #11
0
        public void ByNameNumberTitleBlockAndViews_BadArgs()
        {
            ElementBinder.IsEnabled = false;

            var famSymName = "E1 30x42 Horizontal";
            var famName    = "E1 30 x 42 Horizontal";
            var titleBlock = FamilySymbol.ByFamilyAndName(Family.ByName(famName), famSymName);

            var famSym  = FamilySymbol.ByName("Kousa Dogwood - 10'");
            var pt      = Point.ByCoordinates(0, 1, 2);
            var famInst = FamilyInstance.ByPoint(famSym, pt);

            var pt2      = Point.ByCoordinates(100, 100, 0);
            var famInst2 = FamilyInstance.ByPoint(famSym, pt2);

            var view  = SectionView.ByBoundingBox(famInst.BoundingBox);
            var view2 = SectionView.ByBoundingBox(famInst2.BoundingBox);

            var sheetName   = "Poodle";
            var sheetNumber = "A1";

            Assert.Throws(typeof(ArgumentNullException), () => Sheet.ByNameNumberTitleBlockAndViews(null, sheetNumber, titleBlock, new[] { view, view2 }));
            Assert.Throws(typeof(ArgumentNullException), () => Sheet.ByNameNumberTitleBlockAndViews(sheetName, null, titleBlock, new[] { view, view2 }));
            Assert.Throws(typeof(ArgumentNullException), () => Sheet.ByNameNumberTitleBlockAndViews(sheetName, sheetNumber, null, new[] { view, view2 }));
            Assert.Throws(typeof(ArgumentNullException), () => Sheet.ByNameNumberTitleBlockAndViews(sheetName, sheetNumber, titleBlock, null));
        }
        public void NurbsCurve_Basic()
        {
            var pts = new[]
            {
                Point.ByCoordinates(10, 2, 3)
                , Point.ByCoordinates(0, 2, 2)
                , Point.ByCoordinates(10, 4, 8)
                , Point.ByCoordinates(10, 2, 8)
                , Point.ByCoordinates(5, 5, 5)
            };

            var bspline = NurbsCurve.ByControlPoints(pts, 3);

            var revitCurve = bspline.ToRevitType();

            Assert.NotNull(revitCurve);
            Assert.IsAssignableFrom <Autodesk.Revit.DB.NurbSpline>(revitCurve);

            var revitSpline = (Autodesk.Revit.DB.NurbSpline)revitCurve;

            Assert.AreEqual(bspline.Degree, revitSpline.Degree);
            Assert.AreEqual(bspline.ControlPoints().Count(), revitSpline.CtrlPoints.Count);

            // ClosestPointTo fails in ProtoGeometry

            var tessPts = revitSpline.Tessellate();

            //assert the tesselation is very close to original curve
            //what's the best tolerance to use here?
            foreach (var pt in tessPts)
            {
                var closestPt = bspline.GetClosestPoint(pt.ToPoint());
                Assert.Less(closestPt.DistanceTo(pt.ToPoint()), 1e-6);
            }
        }
        public void ByGeometryAndView_ProviedesExpectedConversion()
        {
            // construct the cuboid in meters
            var c0     = Point.ByCoordinates(-1, -1, -1);
            var c1     = Point.ByCoordinates(1, 1, 1);
            var cuboid = Cuboid.ByCorners(c0, c1);

            // set the view into which the ImportInstance will be imported
            var elevation = 100;
            var level     = Revit.Elements.Level.ByElevation(elevation);

            Assert.NotNull(level);
            var view = Revit.Elements.Views.FloorPlanView.ByLevel(level);

            // import
            var import = Revit.Elements.ImportInstance.ByGeometryAndView(cuboid, view);
            // extract geometry
            var importGeometry = import.Geometry().First();

            Assert.IsAssignableFrom(typeof(Autodesk.DesignScript.Geometry.Solid), importGeometry);

            var solidImport = (Autodesk.DesignScript.Geometry.Solid)importGeometry;

            var c2      = Point.ByCoordinates(-1, -1, -1 + elevation);
            var c3      = Point.ByCoordinates(1, 1, 1 + elevation);
            var cuboid2 = Cuboid.ByCorners(c2, c3);

            cuboid2.Volume.ShouldBeApproximately(solidImport.Volume);
            cuboid2.BoundingBox.MinPoint.ShouldBeApproximately(solidImport.BoundingBox.MinPoint);
            cuboid2.BoundingBox.MaxPoint.ShouldBeApproximately(solidImport.BoundingBox.MaxPoint);
        }
        public void NurbsCurve_Basic()
        {
            var pts = new[]
            {
                Point.ByCoordinates(10, 2, 3)
                , Point.ByCoordinates(0, 2, 2)
                , Point.ByCoordinates(10, 4, 8)
                , Point.ByCoordinates(10, 2, 8)
                , Point.ByCoordinates(5, 5, 5)
            };

            var bspline = NurbsCurve.ByControlPoints(pts, 3);

            var revitCurve = bspline.ToRevitType(false);

            Assert.NotNull(revitCurve);
            Assert.IsAssignableFrom <Autodesk.Revit.DB.NurbSpline>(revitCurve);

            var revitSpline = (Autodesk.Revit.DB.NurbSpline)revitCurve;

            Assert.AreEqual(bspline.Degree, revitSpline.Degree);
            Assert.AreEqual(bspline.ControlPoints().Count(), revitSpline.CtrlPoints.Count);

            var tessPts = revitSpline.Tessellate().Select(x => x.ToPoint(false));

            //assert the tesselation is very close to original curve
            foreach (var pt in tessPts)
            {
                var closestPt = bspline.ClosestPointTo(pt);
                Assert.Less(closestPt.DistanceTo(pt), 1e-6);
            }
        }
        public void NurbsCurve_ProvidesGoodApproximationForDegree2Curve()
        {
            var pts = new[]
            {
                Point.ByCoordinates(0, 0, 0)
                , Point.ByCoordinates(0, 1, 1)
                , Point.ByCoordinates(0, 1, 0)
            };

            var bspline    = NurbsCurve.ByPoints(pts, 2);
            var revitCurve = bspline.ToRevitType(false);

            Assert.IsAssignableFrom <Autodesk.Revit.DB.NurbSpline>(revitCurve);

            var revitSpline = (Autodesk.Revit.DB.NurbSpline)revitCurve;

            Assert.AreEqual(3, revitSpline.Degree);
            var tessPts = revitSpline.Tessellate().Select(x => x.ToPoint(false));

            //assert the tesselation is very close to original curve
            foreach (var pt in tessPts)
            {
                var closestPt = bspline.ClosestPointTo(pt);
                Assert.Less(closestPt.DistanceTo(pt), 1e-6);
            }

            revitCurve.GetEndPoint(0).ShouldBeApproximately(bspline.StartPoint);
            revitCurve.GetEndPoint(1).ShouldBeApproximately(bspline.EndPoint);
        }
Exemple #16
0
 /// <summary>
 /// Create a Reference Point by x, y, and z coordinates.
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="z"></param>
 /// <returns></returns>
 public static ReferencePoint ByCoordinates(double x = 0, double y = 0, double z = 0)
 {
     if (!Document.IsFamilyDocument)
     {
         throw new Exception("ReferencePoint Elements can only be created in a Family Document");
     }
     return(ByPoint(Point.ByCoordinates(x, y, z)));
 }
Exemple #17
0
        private static Line LineBetweenPoints(Point origin, double scale, System.Windows.Point a, System.Windows.Point b)
        {
            var pt1 = Point.ByCoordinates((a.X * scale) + origin.X, ((-a.Y + 1) * scale) + origin.Y, origin.Z);
            var pt2 = Point.ByCoordinates((b.X * scale) + origin.X, ((-b.Y + 1) * scale) + origin.Y, origin.Z);
            var crv = Line.ByStartPointEndPoint(pt1, pt2);

            return(crv);
        }
Exemple #18
0
 /// <summary>
 /// Create a Reference Point by x, y, and z coordinates.
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="z"></param>
 /// <returns></returns>
 public static ReferencePoint ByCoordinates(double x = 0, double y = 0, double z = 0)
 {
     if (!Document.IsFamilyDocument)
     {
         throw new Exception(Properties.Resources.ReferencePointCreationFailure);
     }
     return(ByPoint(Point.ByCoordinates(x, y, z)));
 }
Exemple #19
0
        public void ByPoint_ShouldPlaceReferencePointCorrectly()
        {
            var p  = Point.ByCoordinates(0, -10, 23.1);
            var rp = ReferencePoint.ByPoint(p);

            rp.Point.ShouldBeApproximately(p);

            InternalPosition(rp).ShouldBeApproximately(p.InHostUnits());
        }
        public void IsLineLike_Curve_CorrectlyIdentifiesArc()
        {
            var arc = Arc.ByThreePoints(
                Point.Origin(),
                Point.ByCoordinates(1, 1),
                Point.ByCoordinates(0, 1));

            Assert.False(CurveUtils.IsLineLike(arc.ToRevitType(false)));
        }
Exemple #21
0
        public void ByPointVectorDistance_NullInput1()
        {
            var v = Vector.ByCoordinates(1, 0, 0);

            Assert.Throws(typeof(System.ArgumentNullException), () => ReferencePoint.ByPointVectorDistance(null, v, 0));
            var p = Point.ByCoordinates(0, -10, 23.1);

            Assert.Throws(typeof(System.ArgumentNullException), () => ReferencePoint.ByPointVectorDistance(p, null, 0.5));
        }
        public void IsLineLike_Curve_CorrectlyIdentifiesLine()
        {
            var line = Line.ByStartPointEndPoint(
                Point.Origin(),
                Point.ByCoordinates(12, 3, 2));

            var revitCurve = line.ToRevitType(false);

            Assert.True(CurveUtils.IsLineLike(revitCurve));
        }
Exemple #23
0
        public void ByEyePointAndTarget_BadArgs0()
        {
            var eye    = Point.ByCoordinates(100, 100, 100);
            var target = Point.ByCoordinates(0, 1, 2);
            var name   = "treeView";

            Assert.Throws(typeof(ArgumentNullException), () =>
            {
                AxonometricView.ByEyePointAndTarget(eye, target, null, name, false);
            });
        }
        public void CurvesAreSimilar_Ellipse()
        {
            var a = Autodesk.DesignScript.Geometry.Ellipse.ByOriginRadii(Point.ByCoordinates(0, 0, 0), 1.0, 2.0);
            var b = Autodesk.DesignScript.Geometry.Ellipse.ByOriginRadii(Point.ByCoordinates(0, 0, 0), 2.0, 1.0);

            var revitEllipse1 = a.ToRevitType();
            var revitEllipse2 = b.ToRevitType();

            Assert.True(CurveUtils.CurvesAreSimilar(revitEllipse1, revitEllipse1));
            Assert.False(CurveUtils.CurvesAreSimilar(revitEllipse1, revitEllipse2));
        }
Exemple #25
0
        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 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_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));
        }
Exemple #28
0
        /// <summary>
        /// Place a Revit FamilyInstance given the FamilyType (also known as the FamilySymbol in the Revit API) and its coordinates in world space
        /// </summary>
        /// <param name="familyType">Family Type. Also called Family Symbol.</param>
        /// <param name="x">X coordinate in meters</param>
        /// <param name="y">Y coordinate in meters</param>
        /// <param name="z">Z coordinate in meters</param>
        /// <returns></returns>
        public static FamilyInstance ByCoordinates(FamilyType familyType, double x = 0, double y = 0, double z = 0)
        {
            if (familyType == null)
            {
                throw new ArgumentNullException("familyType");
            }

            var pt = Point.ByCoordinates(x, y, z);

            return(ByPoint(familyType, pt));
        }
Exemple #29
0
        public void ByEyePointAndTarget_BadArgs1()
        {
            var eye    = Point.ByCoordinates(100, 100, 100);
            var target = Point.ByCoordinates(0, 1, 2);
            var name   = "treeView";

            Assert.Throws(typeof(ArgumentException), () =>
            {
                PerspectiveView.ByEyePointAndTarget(eye, target, eye, name, false);
            });
        }
Exemple #30
0
        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));
        }