Пример #1
0
        public void Point2D_ArrayOfPoint()
        {
            var model = dynSettings.Controller.DynamoModel;

            string openPath = Path.Combine(GetTestDirectory(), @"core\GeometryTestFiles\Point2D_ArrayOfPoint.dyn");

            model.Open(openPath);

            // check all the nodes and connectors are loaded
            Assert.AreEqual(6, model.CurrentWorkspace.Nodes.Count);
            Assert.AreEqual(5, model.CurrentWorkspace.Connectors.Count);

            // run the expression
            dynSettings.Controller.RunExpression(null);

            // Verification for Point
            Autodesk.LibG.Geometry geometry1 = null;
            var getGeometry1 = model.CurrentWorkspace.NodeFromWorkspace <GetFromList>("b33aad81-94cc-4f8f-9580-51870b7e9363");

            Assert.IsTrue(Utils.Convert(getGeometry1.GetValue(0), ref geometry1));

            Autodesk.LibG.Point point = geometry1 as Autodesk.LibG.Point;
            Assert.AreNotEqual(null, point);
            double xValue = point.x();
            double yValue = point.y();

            Assert.AreEqual(10, xValue);
            Assert.AreEqual(10, yValue);
        }
Пример #2
0
        public void Point3DTest()
        {
            var model = dynSettings.Controller.DynamoModel;

            string openPath = Path.Combine(GetTestDirectory(), @"core\GeometryTestFiles\Point3DTest.dyn");

            model.Open(openPath);

            // check all the nodes and connectors are loaded
            Assert.AreEqual(6, model.CurrentWorkspace.Nodes.Count);
            Assert.AreEqual(6, model.CurrentWorkspace.Connectors.Count);

            // run the expression
            dynSettings.Controller.RunExpression(null);

            // Verification for Point
            Autodesk.LibG.Geometry geometry1 = null;
            var getGeometry1 = model.CurrentWorkspace.NodeFromWorkspace <Point3DNode>("89653c21-d76b-45c6-ab5e-9160ea0a0e06");

            Assert.IsTrue(Utils.Convert(getGeometry1.GetValue(0), ref geometry1));

            Autodesk.LibG.Point point = geometry1 as Autodesk.LibG.Point;
            Assert.AreNotEqual(null, point);
            double xValue = point.x();
            double yValue = point.y();
            double zValue = point.z();

            Assert.AreEqual(0, xValue);
            Assert.AreEqual(3.14159265358979, yValue);
            Assert.AreEqual(3.14159265358979, zValue);

            // Property Node tests.
            var xProperty = model.CurrentWorkspace.NodeFromWorkspace <PointXNode>("935b53bb-535a-4b32-aff8-3b9dbf72869d");

            Assert.AreEqual(xValue, xProperty.GetValue(0).GetDoubleFromFSchemeValue());

            var yProperty = model.CurrentWorkspace.NodeFromWorkspace <PointYNode>("36de2412-ad63-465d-b19a-719a0eb7f648");

            Assert.AreEqual(yValue, yProperty.GetValue(0).GetDoubleFromFSchemeValue());

            var zProperty = model.CurrentWorkspace.NodeFromWorkspace <PointZNode>("175727bd-d9f4-4b54-bb2a-f608967e203d");

            Assert.AreEqual(zValue, zProperty.GetValue(0).GetDoubleFromFSchemeValue());
        }
Пример #3
0
        public void PointAtUVParameterTest()
        {
            var model = dynSettings.Controller.DynamoModel;

            string openPath = Path.Combine(GetTestDirectory(), @"core\GeometryTestFiles\PointAtUVParameterTest.dyn");

            model.Open(openPath);

            // check all the nodes and connectors are loaded
            Assert.AreEqual(51, model.CurrentWorkspace.Nodes.Count);
            Assert.AreEqual(69, model.CurrentWorkspace.Connectors.Count);

            // run the expression
            dynSettings.Controller.RunExpression(null);

            // Verification for Point which is created using PointAtUVParameter node.
            Autodesk.LibG.Geometry geometry1 = null;
            var getGeometry1 = model.CurrentWorkspace.NodeFromWorkspace <GetFromList>("f467baf4-2bac-4c6f-a31e-d33016571bf5");

            Assert.IsTrue(Utils.Convert(getGeometry1.GetValue(0), ref geometry1));

            Autodesk.LibG.Point point = geometry1 as Autodesk.LibG.Point;
            Assert.AreNotEqual(null, point);
            double xValue = point.x();
            double yValue = point.y();
            double zValue = point.z();

            Assert.AreEqual(-6.3977743135825484, xValue);
            Assert.AreEqual(-16.869544438947674, yValue);
            Assert.AreEqual(-10.633850246828377, zValue);

            //Autodesk.LibG.Geometry pointAtDistance = null;
            //var pointAtDistance1 = model.CurrentWorkspace.NodeFromWorkspace<PointAtUvParameterNode>("877369eb-1b97-4d05-a4d4-61d37b803562");
            //Assert.IsTrue(Utils.Convert(pointAtDistance1.GetValue(0), ref pointAtDistance));

            //Autodesk.LibG.Point point1 = pointAtDistance as Autodesk.LibG.Point;
        }
Пример #4
0
        public void PointAtDistanceTest()
        {
            var model = dynSettings.Controller.DynamoModel;

            string openPath = Path.Combine(GetTestDirectory(), @"core\GeometryTestFiles\PointAtDistanceTest.dyn");

            model.Open(openPath);

            // check all the nodes and connectors are loaded
            Assert.AreEqual(29, model.CurrentWorkspace.Nodes.Count);
            Assert.AreEqual(36, model.CurrentWorkspace.Connectors.Count);

            // run the expression
            dynSettings.Controller.RunExpression(null);

            // Verification for Point created using PointAtDistance node.
            Autodesk.LibG.Geometry geometry1 = null;
            var getGeometry1 = model.CurrentWorkspace.NodeFromWorkspace <GetFromList>("5f48e595-d2cd-485f-99a1-dc0abe364ed3");

            Assert.IsTrue(Utils.Convert(getGeometry1.GetValue(0), ref geometry1));

            Autodesk.LibG.Point point = geometry1 as Autodesk.LibG.Point;
            Assert.AreNotEqual(null, point);
            double xValue = point.x();
            double yValue = point.y();
            double zValue = point.z();

            Assert.AreEqual(10, xValue);
            Assert.AreEqual(5.5978213925456739, yValue);
            Assert.AreEqual(-2.506439789083756, zValue);

            //Autodesk.LibG.Geometry pointAtDistance = null;
            //var pointAtDistance1 = model.CurrentWorkspace.NodeFromWorkspace<PointAtDistanceNode>("877369eb-1b97-4d05-a4d4-61d37b803562");
            //Assert.IsTrue(Utils.Convert(pointAtDistance1.GetValue(0), ref pointAtDistance));

            //Autodesk.LibG.Point point1 = pointAtDistance as Autodesk.LibG.Point;
        }
Пример #5
0
        public override Value Evaluate(FSharpList <Value> args)
        {
            Autodesk.LibG.Geometry geometry = (Autodesk.LibG.Geometry)((Value.Container)args[0]).Item;

            Autodesk.LibG.Point point = geometry as Autodesk.LibG.Point;

            if (point != null)
            {
                XYZ xyz = new XYZ(point.x(), point.y(), point.z());

                if (_revitPoint == null)
                {
                    _revitPoint = this.UIDocument.Document.FamilyCreate.NewReferencePoint(xyz);
                    this.Elements.Add(_revitPoint.Id);
                }
                else
                {
                    _revitPoint.Position = xyz;
                }

                return(Value.NewContainer(_revitPoint));
            }

            Autodesk.LibG.Line line = geometry as Autodesk.LibG.Line;

            if (line != null)
            {
                ReferencePointArray refPoints = new ReferencePointArray();

                Autodesk.LibG.Point start_point = line.start_point();
                Autodesk.LibG.Point end_point   = line.end_point();

                if (_curveByPoints == null)
                {
                    _startPoint = ReferencePointFromPoint(start_point);
                    _endPoint   = ReferencePointFromPoint(end_point);

                    refPoints.Append(_startPoint);
                    refPoints.Append(_endPoint);

                    _curveByPoints = this.UIDocument.Document.FamilyCreate.NewCurveByPoints(refPoints);
                    this.Elements.Add(_curveByPoints.Id);
                }
                else
                {
                    _startPoint.Position = new XYZ(start_point.x(), start_point.y(), start_point.z());
                    _endPoint.Position   = new XYZ(end_point.x(), end_point.y(), end_point.z());
                }

                return(Value.Container.NewContainer(_curveByPoints));
            }

            //Autodesk.LibG.BSplineCurve bspline = geometry as Autodesk.LibG.BSplineCurve;

            //if (bspline != null)
            //{
            //    ReferencePointArray refPoints = new ReferencePointArray();

            //    for (int i = 0; i <= 15; ++i)
            //    {
            //        double param = (double)i / 15.0;
            //        Autodesk.LibG.Point p = bspline.point_at_parameter(param);
            //        ReferencePoint refPoint = ReferencePointFromPoint(p);
            //        refPoints.Append(refPoint);
            //    }

            //    if (_curveByPoints == null)
            //    {
            //        _curveByPoints = this.UIDocument.Document.FamilyCreate.NewCurveByPoints(refPoints);
            //        this.Elements.Add(_curveByPoints.Id);
            //    }
            //    else
            //    {
            //        _curveByPoints.SetPoints(refPoints);
            //    }

            //    foreach (ReferencePoint refPoint in refPoints)
            //    {
            //        refPoint.Visible = false;
            //    }

            //    return Value.Container.NewContainer(_curveByPoints);
            //}

            return(Value.Container.NewContainer(null));

            // Surface

            // Solid
        }
Пример #6
0
        private ReferencePoint ReferencePointFromPoint(Autodesk.LibG.Point point)
        {
            XYZ xyz = new XYZ(point.x(), point.y(), point.z());

            return(this.UIDocument.Document.FamilyCreate.NewReferencePoint(xyz));
        }