コード例 #1
0
        public void ArrayOfLines_WithSliceNode()
        {
            var model = dynSettings.Controller.DynamoModel;

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

            model.Open(openPath);

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

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

            Autodesk.LibG.Geometry line = null;
            var getGeometry2            = model.CurrentWorkspace.NodeFromWorkspace <GetFromList>("b906acc6-cf91-48b5-95ce-25a6e13ce983");

            Assert.IsTrue(Utils.Convert(getGeometry2.GetValue(0), ref line));

            // Verification for "Length" , "StartPoint" and "EndPoint" of Line.
            Autodesk.LibG.Line line1 = line as Autodesk.LibG.Line;
            Assert.AreEqual(4, line1.start_point().x());
            Assert.AreEqual(4, line1.end_point().x());
            Assert.AreEqual(10.770329614269007, line1.length(), 0.000000001);
        }
コード例 #2
0
        public void LineArray()
        {
            var model = dynSettings.Controller.DynamoModel;

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

            model.Open(openPath);

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

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

            // Verification for Line node.
            Autodesk.LibG.Geometry geometry1 = null;
            var getGeometry1 = model.CurrentWorkspace.NodeFromWorkspace <GetFromList>("0f8214b5-b112-4056-b1a2-7ad0de5261e0");

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

            Autodesk.LibG.Line line = geometry1 as Autodesk.LibG.Line;
            Assert.AreNotEqual(null, line);
            Assert.AreEqual(60, line.start_point().x());
            Assert.AreEqual(10, line.end_point().z());
        }
コード例 #3
0
        public void LineTest()
        {
            var model = dynSettings.Controller.DynamoModel;

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

            model.Open(openPath);

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

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

            // Verification for X coordinate of Point node.
            Autodesk.LibG.Geometry geometry = null;
            var getGeometry = model.CurrentWorkspace.NodeFromWorkspace <Point3DNode>("18dce051-d02c-4e24-b852-8626af14b2ea");

            Assert.IsTrue(Utils.Convert(getGeometry.GetValue(0), ref geometry));

            Autodesk.LibG.Point point = geometry as Autodesk.LibG.Point;
            Assert.AreNotEqual(null, point);
            Assert.AreEqual(0, point.x());

            // Verification for Y coordinate of Point node.
            Autodesk.LibG.Geometry geometry1 = null;
            var getGeometry1 = model.CurrentWorkspace.NodeFromWorkspace <Point3DNode>("c231bff3-36d7-4171-bd28-21d5730ab230");

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

            Autodesk.LibG.Point point1 = geometry1 as Autodesk.LibG.Point;
            Assert.AreNotEqual(null, point1);
            Assert.AreEqual(10, point1.x());

            Autodesk.LibG.Geometry line = null;
            var getGeometry2            = model.CurrentWorkspace.NodeFromWorkspace <LineNode>("6e53d1b5-d85a-47d7-a299-7bd031281363");

            Assert.IsTrue(Utils.Convert(getGeometry2.GetValue(0), ref line));

            // Verification for "Length" , "StartPoint" and "EndPoint" of Line.
            Autodesk.LibG.Line line1 = line as Autodesk.LibG.Line;
            Assert.AreEqual(0, line1.start_point().x());
            Assert.AreEqual(10, line1.end_point().x());
            Assert.AreEqual(10, line1.length());
        }
コード例 #4
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
        }