Beispiel #1
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GeometryBase G = null;
            string       L = "预设值";
            List <Curve> H = new List <Curve>();
            Color        C = Color.Black;

            DA.GetData(0, ref G);
            DA.GetData(1, ref L);
            DA.GetDataList(2, H);
            DA.GetData(3, ref C);
            int NOAH_BAKE_INFO = 0;

            try
            {
                PythonScript script = PythonScript.Create();
                script.ExecuteScript("import scriptcontext as sc\nV=sc.sticky['NOAH_BAKE_INFO']");
                NOAH_BAKE_INFO = (int)script.GetVariable("V");
            } catch
            {
                NOAH_BAKE_INFO = 0;
            }

            if (NOAH_BAKE_INFO == 1)
            {
                if (G != null && H.Count == 0)
                {
                    //写入物件
                    ObjectAttributes att = getObjAttr(L, rhinoDoc, C);
                    switch (G.ObjectType)
                    {
                    case ObjectType.Brep:
                        rhinoDoc.Objects.AddBrep(G as Brep, att);
                        break;

                    case ObjectType.Curve:
                        rhinoDoc.Objects.AddCurve(G as Curve, att);
                        break;

                    case ObjectType.Point:
                        rhinoDoc.Objects.AddPoint((G as Rhino.Geometry.Point).Location, att);
                        break;

                    case ObjectType.Surface:
                        rhinoDoc.Objects.AddSurface(G as Surface, att);
                        break;

                    case ObjectType.Mesh:
                        rhinoDoc.Objects.AddMesh(G as Mesh, att);
                        break;

                    case ObjectType.PointSet:
                        rhinoDoc.Objects.AddPointCloud(G as Rhino.Geometry.PointCloud, att);     //This is a speculative entry
                        break;

                    default:
                        AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "不能识别的物体: " + G.GetType().FullName);
                        break;
                    }
                }
                else if (G == null && H.Count > 0)
                {
                    ObjectAttributes att     = getObjAttr(L, rhinoDoc, C);
                    Hatch[]          hatches = Hatch.Create(H, 0, 0, 1, 0);
                    foreach (Hatch hatch in hatches)
                    {
                        rhinoDoc.Objects.AddHatch(hatch, att);
                    }
                }
                else
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, "G和H只能输入一个");
                }
            }
            else
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, "等待写入");
            }
        }