Esempio n. 1
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);
        }
Esempio n. 2
0
        public void ByTextSketchPlaneAndPosition_BadArgs()
        {
            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);

            Assert.Throws(typeof(System.ArgumentNullException), () => ModelText.ByTextSketchPlaneAndPosition(null, sketchPlane, 0, 0, 1, modelTextType));
            Assert.Throws(typeof(System.ArgumentNullException), () => ModelText.ByTextSketchPlaneAndPosition(text, null, 0, 0, 1, modelTextType));
            Assert.Throws(typeof(System.ArgumentNullException), () => ModelText.ByTextSketchPlaneAndPosition(text, sketchPlane, 0, 0, 1, null));
        }