예제 #1
0
        /// <summary>
        /// create a horizontal nurbspline instance with specified z coordinate value
        /// </summary>
        public NurbSpline CreateNurbSpline(double z)
        {
            // create control points with same z value
            List <XYZ> ctrPoints = new List <XYZ>();

            Autodesk.Revit.DB.XYZ xyz1 = new Autodesk.Revit.DB.XYZ(-41.887503610431267, -9.0290629129782189, z);
            Autodesk.Revit.DB.XYZ xyz2 = new Autodesk.Revit.DB.XYZ(-9.27600019217055, 0.32213521486563046, z);
            Autodesk.Revit.DB.XYZ xyz3 = new Autodesk.Revit.DB.XYZ(9.27600019217055, 0.32213521486563046, z);
            Autodesk.Revit.DB.XYZ xyz4 = new Autodesk.Revit.DB.XYZ(41.887503610431267, 9.0290629129782189, z);

            ctrPoints.Add(xyz1); ctrPoints.Add(xyz2); ctrPoints.Add(xyz3);
            ctrPoints.Add(xyz4);

            DoubleArray weights = new DoubleArray();
            double      w1 = 1, w2 = 1, w3 = 1, w4 = 1;

            weights.Append(ref w1); weights.Append(ref w2); weights.Append(ref w3);
            weights.Append(ref w4);

            DoubleArray knots = new DoubleArray();
            double      k0 = 0, k1 = 0, k2 = 0, k3 = 0, k4 = 34.425128, k5 = 34.425128, k6 = 34.425128, k7 = 34.425128;

            knots.Append(ref k0); knots.Append(ref k1); knots.Append(ref k2); knots.Append(ref k3);
            knots.Append(ref k4); knots.Append(ref k5); knots.Append(ref k6);
            knots.Append(ref k7);

            NurbSpline detailNurbSpline = m_revit.Application.Create.NewNurbSpline(ctrPoints, weights, knots, 3, false, true);

            m_revit.ActiveUIDocument.Document.Regenerate();

            return(detailNurbSpline);
        }
        public static DoubleArray ToDoubleArray(this double[] list)
        {
            var n = new DoubleArray();

            list.ToList().ForEach(x => n.Append(ref x));
            return(n);
        }
예제 #3
0
 /// <summary>
 /// Convert array of points to list of xyz's
 /// </summary>
 /// <param name="list">The list to convert</param>
 /// <returns></returns>
 public static DoubleArray ToDoubleArray(this double[] list)
 {
     var n = new DoubleArray();
     list.ToList().ForEach(x => n.Append(ref x));
     return n;
 }
예제 #4
0
        public override Value Evaluate(FSharpList<Value> args)
        {
            var pts = ((Value.List)args[0]).Item.Select(
               e => ((ReferencePoint)((Value.Container)e).Item).Position
            ).ToList();

            foreach (ElementId el in this.Elements)
            {
                Element e;
                if (dynUtils.TryGetElement(el, out e))
                {
                    DeleteElement(el);
                    ns = null;
                    c = null;
                }

            }

            if (pts.Count <= 1)
            {
                throw new Exception("Not enough reference points to make a curve.");
            }

            if (ns == null)
            {
                //make a curve
                ns = this.UIDocument.Application.Application.Create.NewNurbSpline(
                    pts, Enumerable.Repeat(1.0, pts.Count).ToList());
            }
            else
            {
                DoubleArray arr = new DoubleArray();

                var weights = Enumerable.Repeat(1.0, pts.Count).ToList();
                foreach (double weight in weights)
                {
                    double d = weight;
                    arr.Append(ref d);
                }

                //update the existing curve
                ns.SetControlPointsAndWeights(pts, arr);
            }

            if (c == null)
            {
                double rawParam = ns.ComputeRawParameter(.5);
                Transform t = ns.ComputeDerivatives(rawParam, false);

                XYZ norm = t.BasisZ;

                if (norm.GetLength() == 0)
                {
                    norm = XYZ.BasisZ;
                }

                Plane p = new Plane(norm, t.Origin);
                SketchPlane sp = this.UIDocument.Document.FamilyCreate.NewSketchPlane(p);
                //sps.Add(sp);

                c = (ModelNurbSpline) this.UIDocument.Document.FamilyCreate.NewModelCurve(ns, sp);

                this.Elements.Add(c.Id);
            }
            else
            {
                c.GeometryCurve = ns;
            }

            return Value.NewContainer(c);
        }
예제 #5
0
파일: CurvedBeam.cs 프로젝트: AMEE/revit
        /// <summary>
        /// create a horizontal nurbspline instance with specified z coordinate value
        /// </summary>
        public NurbSpline CreateNurbSpline(double z)
        {
            // create control points with same z value
            List<XYZ> ctrPoints = new List<XYZ>();
            Autodesk.Revit.DB.XYZ xyz1 = new Autodesk.Revit.DB.XYZ (-41.887503610431267, -9.0290629129782189, z);
            Autodesk.Revit.DB.XYZ xyz2 = new Autodesk.Revit.DB.XYZ (-9.27600019217055, 0.32213521486563046, z);
            Autodesk.Revit.DB.XYZ xyz3 = new Autodesk.Revit.DB.XYZ (9.27600019217055, 0.32213521486563046, z);
            Autodesk.Revit.DB.XYZ xyz4 = new Autodesk.Revit.DB.XYZ (41.887503610431267, 9.0290629129782189, z);

            ctrPoints.Add(xyz1); ctrPoints.Add(xyz2); ctrPoints.Add(xyz3);
            ctrPoints.Add(xyz4);

            DoubleArray weights = new DoubleArray();
            double w1 = 1, w2 = 1, w3 = 1, w4 = 1;
            weights.Append(ref w1); weights.Append(ref w2); weights.Append(ref w3);
            weights.Append(ref w4);

            DoubleArray knots = new DoubleArray();
            double k0 = 0, k1 = 0, k2 = 0, k3 = 0, k4 = 34.425128, k5 = 34.425128, k6 = 34.425128, k7 = 34.425128;

            knots.Append(ref k0); knots.Append(ref k1); knots.Append(ref k2); knots.Append(ref k3);
            knots.Append(ref k4); knots.Append(ref k5); knots.Append(ref k6);
            knots.Append(ref k7);

            NurbSpline detailNurbSpline = m_revit.Application.Create.NewNurbSpline(ctrPoints, weights, knots, 3, false, true);
            m_revit.ActiveUIDocument.Document.Regenerate();

            return detailNurbSpline;
        }