Folders

public static class Folders
Provides static properties for files and folders relevant to the Grasshopper process.

Fields

DocumentationWipFolderName

#
public const string DocumentationWipFolderName = "Documentation In Progress"
Gets the standard name for the documentation authoring folder.

Properties

CoreComponentsFolder

#
public static string CoreComponentsFolder { get; }
Gets the folder in which all core component assemblies are stored.

CoreSnippetsFolder

#
public static string CoreSnippetsFolder { get; }
Gets the Grasshopper native snippet folder.

DiagnosticsFolder

#
public static string DiagnosticsFolder { get; }
Gets the Grasshopper diagnostics folder for the roaming user. This is where logged data and other output useful for debugging is kept.

DisplayRulesFolder

#
public static string DisplayRulesFolder { get; }
Gets the Grasshopper folder for named display rules for the roaming user.

DisplayStylesFolder

#
public static string DisplayStylesFolder { get; }
Gets the Grasshopper folder for display styles for the roaming user.

DllAssembly

#
public static string DllAssembly { get; }
Gets the location of the Grasshopper2.dll file.

DocumentationAuthoringFolder

#
public static string DocumentationAuthoringFolder { get; set; }
Gets or sets the folder within which in-progress documenation content resides. When set, and when the folder exists, various UI elements providing access to documentation editing tools become visible.

DocumentationCacheFolder

#
public static string DocumentationCacheFolder { get; }
Gets the folder for storing cached content generated or downloaded for the documentation.

DocumentationCustomFolders

#
public static IEnumerable<string> DocumentationCustomFolders { get; }
Gets all enabled, user specified custom documentation folders. This property automatically selects the correct language subfolder if possible, so it does more work than DocumentationCustomFolderSet.

DocumentationCustomFolderSet

#
public static IEnumerable<(string folder, bool enabled)> DocumentationCustomFolderSet { get; }
Gets all specified custom folders including the 'enabled' state for each. This property will return all set folders, even if they do not exist on the disc.

DocumentationFolder

#
public static string DocumentationFolder { get; }
Gets the folder which holds the canonical documentation content. For a source build that is the 'Grasshopper2Documentation' folder in the repository; for an installed instance it is the 'Documentation' folder which ships alongside Grasshopper. Returns null when neither can be located.

GrasshopperPluginId

#
public static Guid GrasshopperPluginId { get; }
Gets the plugin ID of the Grasshopper 2 Rhino plugin.

LocalAppDataFolder

#
public static string LocalAppDataFolder { get; }
Gets the Grasshopper application data folder for the non-roaming user.

PluginFolder

#
public static string PluginFolder { get; }
Gets the folder that contains the installed grasshopper core files.

ResourcesFolder

#
public static string ResourcesFolder { get; }
Gets the folder that contains the installed grasshopper resources.

RhpAssembly

#
public static string RhpAssembly { get; }
Gets the location of the Grasshopper2.rhp file.

RoamingAppDataFolder

#
public static string RoamingAppDataFolder { get; }
Gets the Grasshopper application data folder for the roaming user. This is where resources and settings are stored since no elevated priviliges are required to access the appdata folder.

SettingsFolder

#
public static string SettingsFolder { get; }
Gets the Grasshopper settings folder for the roaming user.

SkinsFolder

#
public static string SkinsFolder { get; }
Gets the Grasshopper folder for canvas skins for the roaming user.

UnnamedFilesFolder

#
public static string UnnamedFilesFolder { get; }
Gets the folder under which autosave files for unnamed documents live. Named documents place their autosaves next to the original file on disk; unnamed documents have nowhere to put a sibling autosave, so they get a managed home under LocalAppDataFolder instead. Filenames within this folder are keyed by a short prefix of the document's runtime Document.Identity.

UserSnippetsFolder

#
public static string UserSnippetsFolder { get; }
Gets the Grasshopper snippet folder for the roaming user.

Methods

AddCustomDocumentationFolder

#
public static void AddCustomDocumentationFolder(string folder, bool enabled)
Add a custom documentation folder alongside the enabled state.
folder (string)
enabled (bool)

EditCustomDocumentationFolders

#
public static bool EditCustomDocumentationFolders()
Show the editor for adding and removing custom documentation folders.
True if a change to the custom folders as made.

EnsureDefaultResources

#
public static string[] EnsureDefaultResources()
Ensure that all required resource files exist. This method will copy resource files from the Grasshopper2.dll assembly resources into the Resources folder in the app data. Note however that it will only replace missing files, not invalid files.
Array of files that were re-instated.

GetResourceAsBitmap

#
public static Bitmap GetResourceAsBitmap(Assembly assembly, string location)
Try and get embedded resources from an assembly in image format.
assembly (Assembly)Assembly.
location (string)Resource location.
The image contents of the resource, or null if the resource cannot be found.

GetResourceAsBytes

#
public static byte[] GetResourceAsBytes(Assembly assembly, string location)
Try and get embedded resources from an assembly in byte array format.
assembly (Assembly)Assembly.
location (string)Resource location.
The byte contents of the resource, or null if the resource cannot be found.

GetResourceAsStream

#
public static Stream GetResourceAsStream(Assembly assembly, string location)
Try and get embedded resources from an assembly as a byte stream.
assembly (Assembly)Assembly.
location (string)Resource location.
The byte stream of the resource, or null if the resource cannot be found.

GetResourceAsString

#
public static string GetResourceAsString(Assembly assembly, string location)
Try and get embedded resources from an assembly in text format.
assembly (Assembly)Assembly.
location (string)Resource location.
The textual contents of the resource, or null if the resource cannot be found.

RemoveCustomDocumentationFolder

#
public static void RemoveCustomDocumentationFolder(string folder)
Remove a custom documentation folder.
folder (string)

RequestInternetAccess

#
public static bool RequestInternetAccess()
Check the RhinoApp.IsInternetAccessAllowed state and displays a message when it returns false.

ResourceFolder

#
public static string ResourceFolder(ResourceFolder folder)
Gets a specific resource folder.
folder (ResourceFolder)Folder type.
Folder path.

SanitizeFolder

#
public static string SanitizeFolder(string folder)
Ensure that a folder uri ends with the OS-specific directory separator.
folder (string)

ShowDirectoryInOsFileViewer

#
public static void ShowDirectoryInOsFileViewer(string directory)
Ask the OS to display a folder in its native viewer.
directory (string)

ShowFileInOsFileViewer

#
public static void ShowFileInOsFileViewer(string filePath)
Ask the OS to display a file in its native viewer.
filePath (string)

ShowUrlInOsBrowser

#
public static void ShowUrlInOsBrowser(string url)
Ask the OS to display a url in its standard browser.
url (string)

TryFindResourceUri

#
public static string TryFindResourceUri(Assembly assembly, string hint)
Try and find the uri of embedded resources within some assembly. The hint must name the resource in full, although the namespace prefix may be omitted and casing is not significant. Partial names are not matched, as suffix matching yields false positives.
assembly (Assembly)Assembly to examine.
hint (string)Name hint.

TryFindResourceUris

#
public static IEnumerable<string> TryFindResourceUris(Assembly assembly, string pattern)
Find all resources which match the given pattern.
assembly (Assembly)
pattern (string)

WatchFile

#
public static IDisposable WatchFile(string filePath, Action<string> changed, Action<string> created, Action<string> deleted, Action<string> renamed)
Start watching a file for changes.
filePath (string)
changed (Action<string>)
created (Action<string>)
deleted (Action<string>)
renamed (Action<string>)
Disposable object used to disable the watcher.