예제 #1
0
        public override void Draw()
        {
            //dynDouble x = Inputs[0] as dynDouble;
            //dynDouble y = Inputs[1] as dynDouble;
            //dynDouble z = Inputs[2] as dynDouble;

            //if (x != null && y != null && z != null)
            //{
            //    point = new XYZ(x.D, y.D, z.D);
            //}
            //else
            //{
            //    point = null;
            //}

            if (point != null)
            {

                //generate the planes
                xyPlane = this.Settings.Revit.Application.Create.NewPlane(up, point);
                yzPlane = this.Settings.Revit.Application.Create.NewPlane(xAxis, point);
                xzPlane = this.Settings.Revit.Application.Create.NewPlane(yAxis, point);

                //generate the tick lines
                Line l1 = this.Settings.Revit.Application.Create.NewLineBound(point, point + up);
                Line l2 = this.Settings.Revit.Application.Create.NewLineBound(point, point + xAxis);
                Line l3 = this.Settings.Revit.Application.Create.NewLineBound(point, point + yAxis);

                //generate the sketch planes
                topSketch = this.Settings.Doc.Document.Create.NewSketchPlane(xyPlane);
                lrSketch = this.Settings.Doc.Document.Create.NewSketchPlane(yzPlane);
                fbSketch = this.Settings.Doc.Document.Create.NewSketchPlane(xzPlane);

                ll1 = this.Settings.Doc.Document.Create.NewModelCurve(l1, lrSketch) as ModelLine;
                ll2 = this.Settings.Doc.Document.Create.NewModelCurve(l2, topSketch) as ModelLine;
                ll3 = this.Settings.Doc.Document.Create.NewModelCurve(l3, topSketch) as ModelLine;

                if (xyPlane_out != null && yzPlane_out != null && xzPlane_out != null)
                {
                    //update the outputs
                    xyPlane_out.P = xyPlane;
                    yzPlane_out.P = yzPlane;
                    xzPlane_out.P = xzPlane;
                }
            }
        }
예제 #2
0
        public void Process(DataTreeBranch b, DataTreeBranch currentBranch)
        {
            List<XYZ> ptArr = new List<XYZ>();
            List<double> weights = new List<double>();

            foreach (object o in b.Leaves)
            {
                ReferencePoint pt = o as ReferencePoint;
                ptArr.Add(pt.Position);
                weights.Add(1);
            }

            //only make a curve if
            //there's enough points
            if (ptArr.Count > 1)
            {
                //make a curve
                NurbSpline ns = dynElementSettings.SharedInstance.Doc.Application.Application.Create.NewNurbSpline(ptArr, weights);
                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 = dynElementSettings.SharedInstance.Doc.Document.FamilyCreate.NewSketchPlane(p);
                sps.Add(sp);

                ModelNurbSpline c = (ModelNurbSpline)dynElementSettings.SharedInstance.Doc.Document.FamilyCreate.NewModelCurve(ns, sp);

                //add the element to the collection
                //so it can be deleted later
                Elements.Append(c);

                //create a leaf node on the local branch
                currentBranch.Leaves.Add(c);
            }

            foreach (DataTreeBranch b1 in b.Branches)
            {
                //every time you read a branch
                //create a branch
                DataTreeBranch newBranch = new DataTreeBranch();
                this.Tree.Trunk.Branches.Add(newBranch);

                Process(b1, newBranch);
            }
        }
예제 #3
0
 //override the destroy method for all point objects
 public override void Destroy()
 {
     try
     {
         if (ll1 != null)
         {
             Settings.Doc.Document.Delete(ll1);
             Settings.Doc.Document.Delete(ll2);
             Settings.Doc.Document.Delete(ll3);
             Settings.Doc.Document.Delete(topSketch);
             Settings.Doc.Document.Delete(fbSketch);
             Settings.Doc.Document.Delete(lrSketch);
             ll1 = null;
             ll2 = null;
             ll3 = null;
             topSketch = null;
             fbSketch = null;
             lrSketch = null;
         }
         if (xyPlane != null)
         {
             point = null;
             xyPlane = null;
             yzPlane = null;
             xzPlane = null;
         }
     }
     catch
     {
         ll1 = null;
         ll2 = null;
         ll3 = null;
         topSketch = null;
         fbSketch = null;
         lrSketch = null;
         point = null;
         xyPlane = null;
         yzPlane = null;
         xzPlane = null;
     }
 }