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); }
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()); }
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()); }
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; }
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; }
public void CircleTest() { var model = dynSettings.Controller.DynamoModel; string openPath = Path.Combine(GetTestDirectory(), @"core\GeometryTestFiles\CircleTest.dyn"); model.Open(openPath); // check all the nodes and connectors are loaded Assert.AreEqual(7, model.CurrentWorkspace.Nodes.Count); Assert.AreEqual(10, model.CurrentWorkspace.Connectors.Count); // run the expression dynSettings.Controller.RunExpression(null); // Verification for X coordinate of CenterPoint node. Autodesk.LibG.Geometry geometry1 = null; var getGeometry1 = model.CurrentWorkspace.NodeFromWorkspace <Point3DNode>("753356e5-4025-46b9-a688-8a2e20e482fc"); Assert.IsTrue(Utils.Convert(getGeometry1.GetValue(0), ref geometry1)); Autodesk.LibG.Point point1 = geometry1 as Autodesk.LibG.Point; Assert.AreNotEqual(null, point1); Assert.AreEqual(0, point1.x()); // Verification for Circle node. Autodesk.LibG.Geometry geometry = null; var getGeometry = model.CurrentWorkspace.NodeFromWorkspace <CircleNode>("3382f192-30e7-49bf-92f0-c24504d498b5"); Assert.IsTrue(Utils.Convert(getGeometry.GetValue(0), ref geometry)); Autodesk.LibG.Circle circle = geometry as Autodesk.LibG.Circle; Assert.AreNotEqual(null, circle); //Assert.AreEqual(point1, circle.center_point()); Assert.AreEqual(0, circle.center_point().x()); }
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 }
private ReferencePoint ReferencePointFromPoint(Autodesk.LibG.Point point) { XYZ xyz = new XYZ(point.x(), point.y(), point.z()); return(this.UIDocument.Document.FamilyCreate.NewReferencePoint(xyz)); }