public static void IntersectNow(string layerPath, string targetPath)
        {
            //initialize variables
            List <int>   layerIndexs;
            List <Curve> c;
            List <Curve> splitCurves;
            List <int>   layerIds;
            string       layerName;
            var          layerTable = Rhino.RhinoDoc.ActiveDoc.Layers;


            //get curves from the specific layer - rectangles
            c = LayerHelper.GetCurvesFromChild(layerPath, out layerIndexs);

            //split curves and bake to target layer
            splitCurves = Intersect.IntersectCurves(c, layerIndexs, out layerIds);
            for (int i = 0; i < splitCurves.Count; i++)
            {
                layerName = Rhino.RhinoDoc.ActiveDoc.Layers[layerIds[i]].Name;
                LayerHelper.BakeObjectToLayer(splitCurves[i], layerName, targetPath);

                // change color of layer
                System.Drawing.Color layerColor = layerTable.FindIndex(layerTable.FindByFullPath(layerPath + "::" + layerName, -1)).Color;
                LayerHelper.ConfirmLayerColor(layerColor, layerName, targetPath);
                Rhino.RhinoApp.WriteLine("baking split curve {0} to layer {1} ", splitCurves[i].ToString(), layerName);
            }

            Rhino.RhinoDoc.ActiveDoc.Views.Redraw();
        }
Example #2
0
        public void MakeRectanglesFromString(string parentLayerName, string input)
        {
            //if data is empty, return with nothing.. Add a note?

            Response    myResponseAsObjects     = Newtonsoft.Json.JsonConvert.DeserializeObject <Response>(input);
            List <Room> roomsSortedLargeToSmall = myResponseAsObjects.data.rooms.OrderBy(x => x.rectangleArea).ToList();


            //int drawHeightTest = 0;
            int i = 0;

            foreach (Room myRoom in roomsSortedLargeToSmall)
            {
                Plane basePlane = Plane.WorldXY;
                //Plane tempBasePlane = new Plane(new Point3d(0, 0, drawHeightTest), new Vector3d(0, 0, 1));
                //drawHeightTest += 24;

                Rectangle3d oneRectangle = new Rectangle3d(basePlane, myRoom.cornerA, myRoom.cornerB);

                LayerHelper.BakeObjectToLayer(oneRectangle.ToPolyline().ToPolylineCurve(), i + myRoom.room, parentLayerName);

                Color layerColor = System.Drawing.ColorTranslator.FromHtml(myRoom.roomColor);
                LayerHelper.ConfirmLayerColor(layerColor, i + myRoom.room, parentLayerName);
                i++;
            }

            RhinoDoc.ActiveDoc.Views.Redraw();
        }