コード例 #1
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            List <GH_PPolyline> pp = new List <GH_PPolyline>();

            DA.GetDataList("PPolyline", pp);

            PPolyline poly = new PPolyline();

            foreach (GH_PPolyline ppoly in pp)
            {
                poly.AddRange(ppoly.Value);
            }

            DA.SetData(0, new GH_PPolyline(poly));
        }
コード例 #2
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_PPolyline pp = null;

            DA.GetData("PPolyline", ref pp);

            if (pp == null)
            {
                return;
            }

            PPolyline flipped = new PPolyline(pp.Value);

            flipped.Reverse();

            DA.SetData("PPolyline", new GH_PPolyline(flipped));
        }
コード例 #3
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            List <object> obj_refs     = new List <object>();
            List <Plane>  planes       = new List <Plane>();
            List <Plane>  orientations = new List <Plane>();

            bool single = true;

            if (!DA.GetDataList(0, obj_refs))
            {
                return;
            }
            if (!DA.GetDataList(1, orientations))
            {
                orientations = new List <Plane> {
                    Plane.WorldXY
                }
            }
            ;

            if (orientations.Count >= obj_refs.Count)
            {
                single = false;
            }

            List <GH_PPolyline> gh_op = new List <GH_PPolyline>();

            for (int i = 0; i < obj_refs.Count; ++i)
            {
                if (obj_refs[i] is GH_Plane)
                {
                    planes.Add((obj_refs[i] as GH_Plane).Value);
                }
                else if (obj_refs[i] is GH_Point)
                {
                    if (single)
                    {
                        planes.Add(new Plane((obj_refs[i] as GH_Point).Value, orientations[0].XAxis, orientations[0].YAxis));
                    }
                    else
                    {
                        planes.Add(new Plane((obj_refs[i] as GH_Point).Value, orientations[i].XAxis, orientations[i].YAxis));
                    }
                }
                else if (obj_refs[i] is GH_Curve)
                {
                    Curve c = (obj_refs[i] as GH_Curve).Value;
                    if (c.IsPolyline())
                    {
                        Polyline p;
                        c.TryGetPolyline(out p);
                        PPolyline op = new PPolyline(p, orientations[0]);
                        gh_op.Add(new GH_PPolyline(op));
                    }
                    else
                    {
                        var      pc = c.ToPolyline(0, 0, 0.1, 1.0, 0, 0, 1.0, 0, true);
                        Polyline p;
                        pc.TryGetPolyline(out p);
                        PPolyline op = new PPolyline(p, orientations[0]);
                        gh_op.Add(new GH_PPolyline(op));
                    }
                }
            }

            if (planes.Count > 0)
            {
                gh_op.Add(new GH_PPolyline(new Types.PPolyline(planes)));
            }

            if (gh_op.Count > 0)
            {
                DA.SetDataList(0, gh_op);
            }
        }