Hello,
I’ve found a C# script which allows to select folder, and save the panel content into a folder as .txt
Unfortunately i don’t know coding. Is it possible to change the folder selection window to this
style
insted of this
Here is the code
using Rhino;
using Rhino.Geometry;
using Rhino.DocObjects;
using Rhino.Collections;
using GH_IO;
using GH_IO.Serialization;
using Grasshopper;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Data;
using Grasshopper.Kernel.Types;
using System;
using System.IO;
using System.Xml;
using System.Xml.Linq;
using System.Linq;
using System.Data;
using System.Drawing;
using System.Reflection;
using System.Collections;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Runtime.InteropServices;
///
/// This class will be instantiated on demand by the Script component.
///
public class Script_Instance : GH_ScriptInstance
{
#region Utility functions
///
/// String to print.
private void Print(string text) { /* Implementation hidden. / }
///
/// String format.
/// Formatting parameters.
private void Print(string format, params object[] args) { / Implementation hidden. / }
///
/// Object instance to parse.
private void Reflect(object obj) { / Implementation hidden. / }
///
/// Object instance to parse.
private void Reflect(object obj, string method_name) { / Implementation hidden. */ }
#endregion
#region Members
///
private readonly RhinoDoc RhinoDocument;
///
private readonly GH_Document GrasshopperDocument;
///
private readonly IGH_Component Component;
///
/// Gets the current iteration count. The first call to RunScript() is associated with Iteration==0.
/// Any subsequent call within the same solution will increment the Iteration count.
///
private readonly int Iteration;
#endregion
///
/// This procedure contains the user code. Input parameters are provided as regular arguments,
/// Output parameters as ref arguments. You don’t have to assign output parameters,
/// they will have a default value.
///
private void RunScript(bool select, string spNickname, ref object dir)
{
try
{
string startupPath = Application.StartupPath;
string folder = "";
if (select == true) {
using (FolderBrowserDialog dialog = new FolderBrowserDialog())
{
dialog.Description = "Open a folder ";
dialog.ShowNewFolderButton = true;
dialog.RootFolder = Environment.SpecialFolder.MyComputer;
if(dialog.ShowDialog() == DialogResult.OK)
{
folder = dialog.SelectedPath;
// set savepane
SetSavePanel(spNickname, folder);
}
}
}
}
catch (Exception)
{
MessageBox.Show("Folder selection failed!");
}
// get path from savepanel
dir = GetFromSavePanel(spNickname);
}
//
private void SetSavePanel(string panelNickname, string path)
{
for (int i = 0; i < GrasshopperDocument.Objects.Count; i++)
{
if (GrasshopperDocument.Objects[i].ToString() == “Grasshopper.Kernel.Special.GH_Panel”)
{
Grasshopper.Kernel.Special.GH_Panel panel = (Grasshopper.Kernel.Special.GH_Panel) GrasshopperDocument.Objects[i];
if (panel.NickName == panelNickname)
{
panel.SetUserText(path);
}
}
}
}
private string GetFromSavePanel(string panelNickname)
{
for (int i = 0; i < GrasshopperDocument.Objects.Count; i++)
{
if (GrasshopperDocument.Objects[i].ToString() == “Grasshopper.Kernel.Special.GH_Panel”)
{
Grasshopper.Kernel.Special.GH_Panel panel = (Grasshopper.Kernel.Special.GH_Panel) GrasshopperDocument.Objects[i];
if (panel.NickName == panelNickname)
{
return panel.UserText;
}
}
}
return "";
}
// </Custom additional code>
}
Thank you