private void ScreenShot(int i)
        {
            Rhino.RhinoDoc.ActiveDoc.Views.Redraw();
            Rhino.Display.RhinoView view = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView;
            if (view == null)
            {
                return;
            }

            string fileName = @"" + MyComponent.SSDir + MyComponent.SSFilename + "-" + i + ".png";
            Bitmap image    = view.CaptureToBitmap();

            if (image == null)
            {
                return;
            }

            image.Save(fileName);
            image = null;
        }
Exemple #2
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            ETABS2013.cOAPI ETABS    = null;
            string          loadcase = null;

            if (!DA.GetData(0, ref ETABS))
            {
                return;
            }
            if (!DA.GetData(1, ref loadcase))
            {
                return;
            }

            Rhino.RhinoDoc RhinoDoc = Rhino.RhinoDoc.ActiveDoc;

            Rhino.Display.RhinoView view    = RhinoDoc.Views.ActiveView;
            System.Drawing.Bitmap   picture = view.CaptureToBitmap();
            picture.Save("H:\\printad.bmp");
        }
Exemple #3
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            //Message = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.Name;

            bool capture = false;

            DA.GetData("Capture", ref capture);

            if (!capture)
            {
                Message = "";
                return;
            }
            string dir = "", Name = "";

            if (!DA.GetData(0, ref dir))
            {
                return;
            }
            if (!DA.GetData(1, ref Name))
            {
                return;
            }
            if (string.IsNullOrWhiteSpace(dir))
            {
                return;
            }
            if (string.IsNullOrWhiteSpace(Name))
            {
                return;
            }

            // Make sure the directory ends with a \
            if (dir.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString()))
            {
                dir += System.IO.Path.DirectorySeparatorChar;
            }

            // Do not create directories, only use existing ones.
            if (!System.IO.Directory.Exists(dir))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Directory does not exist - use only existing directories");
                return;
            }

            //Add an incremental number to the name
            string[] nSplit = Name.Split('.');
            Name = nSplit[0] + "_{0}." + nSplit[1];

            // Assume index=0 for the first filename.
            string fileName = dir + string.Format(Name, 0.ToString("D3"));

            // Try to increment the index until we find a name which doesn't exist yet.
            if (System.IO.File.Exists(fileName))
            {
                for (int i = 1; i < int.MaxValue; i++)
                {
                    string localName = dir + string.Format(Name, i.ToString("D3"));
                    if (localName == fileName)
                    {
                        return;
                    }

                    if (!System.IO.File.Exists(localName))
                    {
                        fileName = localName;
                        break;
                    }
                }
            }
            string VP = "";

            DA.GetData(2, ref VP);
            if (string.IsNullOrWhiteSpace(VP))
            {
                VP = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.Name;
            }

            Message = VP;

            int[]  res = new int[1];
            Size   sz;
            string size = "";

            DA.GetData(3, ref size);
            double scale = 1.0;

            DA.GetData(4, ref scale);

            Rhino.Display.RhinoView view = Rhino.RhinoDoc.ActiveDoc.Views.Find(VP, false);

            if (!string.IsNullOrWhiteSpace(size))
            {
                res = size.Split(new[] { 'x' }).Select(x => (int)(Convert.ToInt32(x) * scale)).ToArray();
            }
            else
            {
                res    = new int[2];
                res[0] = (int)(view.Size.Width * scale);
                res[1] = (int)(view.Size.Height * scale);
            }

            sz = new Size(res[0], res[1]);

            Bitmap image;

            bool grid = false, axes = false, widget = false;

            DA.GetData(5, ref grid);
            DA.GetData(6, ref axes);
            DA.GetData(7, ref widget);

            if (res.Length == 1)
            {
                image = view.CaptureToBitmap(grid, widget, axes);
            }
            else
            {
                image = view.CaptureToBitmap(new Size(res[0], res[1]), grid, widget, axes);
            }

            image.Save(fileName);
            image.Dispose();
        }