Esempio n. 1
0
        public void GeneratePreViewObjectsI(GH_Structure <IGH_GeometricGoo> inGeoTree)
        {
            string key = "Leopard(" + this.InstanceGuid + ")";

            RhinoDoc.ActiveDoc.Layers.Add("Leopard_Preview", System.Drawing.Color.Maroon);
            int layer = RhinoDoc.ActiveDoc.Layers.Find("Leopard_Preview", true);

            Rhino.DocObjects.RhinoObject[] obj = RhinoDoc.ActiveDoc.Objects.FindByUserString(key, "*", true);

            if (obj.Length == 0) //if no preview item
            {
                int count = 0;
                foreach (IGH_GeometricGoo goo in inGeoTree.AllData(false))
                {
                    Rhino.DocObjects.ObjectAttributes att = new Rhino.DocObjects.ObjectAttributes();
                    att.SetUserString(key, count.ToString());
                    att.LayerIndex = layer;
                    count++;
                    if (goo is IGH_BakeAwareData)
                    {
                        IGH_BakeAwareData data = (IGH_BakeAwareData)goo;
                        Guid guid;
                        data.BakeGeometry(RhinoDoc.ActiveDoc, att, out guid);
                    }
                }
            }
        }
Esempio n. 2
0
        public void GeneratePreViewMeshVertices(GH_Structure <IGH_GeometricGoo> inGeoTree)
        {
            string key = "Leopard(" + this.InstanceGuid + ")";

            RhinoDoc.ActiveDoc.Layers.Add("Leopard_Preview", System.Drawing.Color.Maroon);
            int layer = RhinoDoc.ActiveDoc.Layers.Find("Leopard_Preview", true);

            Rhino.DocObjects.RhinoObject[] obj = RhinoDoc.ActiveDoc.Objects.FindByUserString(key, "*", true);

            if (obj.Length == 0) //if no preview item
            {
                int count = 0;
                foreach (IGH_GeometricGoo goo in inGeoTree.AllData(false))
                {
                    PlanktonMesh pMesh = new PlanktonMesh();
                    Mesh         mesh;
                    if (!goo.CastTo <Mesh>(out mesh))
                    {
                        RhinoApp.WriteLine("input invalid");
                    }

                    pMesh = mesh.ToPlanktonMesh();

                    PlanktonXYZ[]  xyz       = pMesh.Vertices.GetPositions();
                    List <Point3d> oVertices = new List <Point3d>();

                    for (int i = 0; i < xyz.Length; i++)
                    {
                        oVertices.Add(xyz[i].ToPoint3d());
                    }

                    count++;

                    int vCount = 0;

                    foreach (Point3d p in oVertices)
                    {
                        string keyV = "Leopard(" + this.InstanceGuid + vCount + ")";


                        Rhino.DocObjects.ObjectAttributes att = new Rhino.DocObjects.ObjectAttributes();
                        att.SetUserString(keyV, count.ToString());
                        att.LayerIndex = layer;

                        GH_Point point = new GH_Point(p);

                        if (goo is IGH_BakeAwareData)
                        {
                            IGH_BakeAwareData data = (IGH_BakeAwareData)point;
                            Guid guid;
                            data.BakeGeometry(RhinoDoc.ActiveDoc, att, out guid);
                        }

                        vCount++;
                    }
                }
            }
        }