GH_ComponentServer

References
public sealed class GH_ComponentServer
Maintains proxies for all components, parameters and other object types as defined in all grasshopper assemblies.

Constructors

GH_ComponentServer

#
public GH_ComponentServer()

Properties

Aliases

#
public List<string> Aliases { get; }
Gets a list of all the defined aliases.

AllAddOns

#
[EditorBrowsable(EditorBrowsableState.Never)] public static List<string> AllAddOns { get; }
obsoleteThis property has been replaced by the ExternalFiles() Shared method
Gets a list of all the gha and ghuser files that will be loaded as Grasshopper add-ons.
A list of target file paths.

CompleteRibbonLayout

#
public GH_Layout CompleteRibbonLayout { get; }
Gets the default component layout featuring all non-hidden components and parameters.

DiscardedProxies

#
public int DiscardedProxies { get; }
Returns the total number of IGH_DocumentObjects that were discarded during assembly parsing. This includes both skipped and replaced proxies.

GHA_AppDataDirectory

#
[EditorBrowsable(EditorBrowsableState.Never)] public static string GHA_AppDataDirectory { get; }
obsoleteThis property has been replaced by Grasshopper.Folders.DefaultAssemblyFolder

GHA_Directories

#
[EditorBrowsable(EditorBrowsableState.Never)] public static List<string> GHA_Directories { get; }
obsoleteThis property has been replaced by Grasshopper.Folders.AssemblyFolders

GHUser_AppDataDirectory

#
[EditorBrowsable(EditorBrowsableState.Never)] public static string GHUser_AppDataDirectory { get; }
obsoleteThis property has been replaced by Grasshopper.Folders.GhUserAppDataFolder

GraphProxies

#
public IList<GH_GraphProxy> GraphProxies { get; }
Returns a list of all cached GH_GraphProxy instances.

IsLoading

#
public bool IsLoading { get; }
Gets whether the component server is currently executing its external-file load pass. True from entry to LoadExternalFiles until it returns.

Libraries

#
public ReadOnlyCollection<GH_AssemblyInfo> Libraries { get; }
Returns a list of Assembly Info objects describing all loaded assemblies.

LoadingExceptions

#
public List<GH_LoadingException> LoadingExceptions { get; }
Gets a list of all the exceptions that were recorded during the most recent loading sequence.

NoLoadExtension

#
public static string NoLoadExtension { get; }

ObjectProxies

#
public IList<IGH_ObjectProxy> ObjectProxies { get; }
Returns a list of all cached GH_ObjectProxy instances.

ObjectProxyNames

#
public AutoCompleteStringCollection ObjectProxyNames { get; }
Returns a specialized string collection of all component names.
Remarks: This property is used for autocompletion in textboxes.

TypeHints

#
public IList<Type> TypeHints { get; }
Gets a list of all IGH_TypeHint types in all loaded assemblies.
A list of System.Type containing all classes that implement IGH_TypeHint.

Upgraders

#
public IList<IGH_UpgradeObject> Upgraders { get; }
Gets a list of all the upgraders that have been cached.

Methods

AddAlias

#
public void AddAlias(string alias, Guid target)
Add an alias to a target.
alias (string)Alias to add. If the alias string contains spaces or commas, those will be used to harvest partial aliases.
target (Guid)Component ID of object that is targeted by the alias.

AddCategoryIcon

#
public void AddCategoryIcon(string fullCategoryName, Bitmap icon)
Add an icon for a tab category. 16x16 images are required.
fullCategoryName (string)The full name of the category.
icon (Bitmap)the icon to display on the tab (has to be a 16x16 image).

AddCategoryShortName

#
public void AddCategoryShortName(string fullCategoryName, string categoryAbbreviation)
Add an abbreviation for a tab category. 2~4 letter abbreviations are best.
fullCategoryName (string)The full name of the category.
categoryAbbreviation (string)The abbreviation to display on the tab.

AddCategorySymbolName

#
public void AddCategorySymbolName(string fullCategoryName, char symbol)
Add a single char category description.
fullCategoryName (string)The full name of the category.
symbol (char)The single char representing the category.

AddProxy

#
Add a proxy object to the component server. Expert user function, talk to David Rutten before calling it.
proxy (IGH_ObjectProxy)Proxy to add.
True on success, false on failure.

AddProxyLibraryInfo

#
[EditorBrowsable(EditorBrowsableState.Never)] public bool AddProxyLibraryInfo(GH_AssemblyInfo assemblyInfo)
Add a library info for a proxy object to the component server. Expert user function, talk to David Rutten before calling it.
assemblyInfo (GH_AssemblyInfo)Library info to add.
True on success, false on failure.

AliasTargets

#
public List<Guid> AliasTargets(string alias)
Get all the target Component IDs for a given alias.
alias (string)Alias to search for.

Clear

#
public void Clear()
Clear all caches.

ClearStaleUserObjects

#
public void ClearStaleUserObjects()
Remove all user objects that no longer point to existing files.

CompareProxies

#
public static int CompareProxies(IGH_ObjectProxy A, IGH_ObjectProxy B)
Compare two object proxies. Names and exposures are taken into account.
A (IGH_ObjectProxy)First proxy to compare.
B (IGH_ObjectProxy)Second proxy to compare.
-1 if A is valued lower than B, 0 if A and B are considered equal, +1 if A is valued higher than B.

CopyFileToAppropriateFolder

#
public static string CopyFileToAppropriateFolder(string filepath, bool moveOriginalToBin)
Copy a GHA or GHUSER file into the appropriate Roaming Application Data folder. Of the file is already in the top-level roaming folder it will not be copied.
filepath (string)The file to copy.
moveOriginalToBin (bool)If true, the original file will be placed in the recycle bin upon a successful copy.
The path of the copied file.

CreateComponentPalette

#
public Bitmap CreateComponentPalette(GH_ComponentPaletteStyle style)
style (GH_ComponentPaletteStyle)

DestroyLoadingUI

#
public void DestroyLoadingUI()
Destroy the loading UI (the banner and the progress bar).

EmitGraph

#
public IGH_Graph EmitGraph(Guid id)
Create a new instance of the IGH_Graph that matches the id. If no proxy can be matched to the id, a null reference will be returned.
id (Guid)The graph type id to instantiate

EmitObject

#
public IGH_DocumentObject EmitObject(Guid id)
Create a new instance of the IGH_DocumentObject that matches the id. If no proxy can be matched to the id, a null reference will be returned.
id (Guid)The component type id to instantiate

EmitObjectIcon

#
public Bitmap EmitObjectIcon(Guid id)
Get the icon that is associated with the given Object ID.
id (Guid)ID to search for.
Icon of object or null if object is not defined or if object does not have an icon.

EmitObjectProxy

#
public IGH_ObjectProxy EmitObjectProxy(Guid id)
Get the proxy that is associated with the given Object ID.
id (Guid)ID to search for.

ExternalFiles

#
public static List<GH_ExternalFile> ExternalFiles(bool testGrasshopperCollisions, bool testExternalCollisions)
Get lists of all the external files (GHA, GHUSER and GHCLUSTER) that will be loaded by Grasshopper. Note: this does not equal the files that may already have been loaded, just the files that we'll attempt to load if we were asked to load all plugins now. The list contains no duplicate file paths, but it may contain identical files which won't be filtered until actual loading.
testGrasshopperCollisions (bool)If true, invalid duplicates of Grasshopper.dll will be tested for and warned about.
testExternalCollisions (bool)If true, duplicates of GHA, GHUSER and GHCLUSTER files will be tested for and warned about.

FindAssembly

#
public GH_AssemblyInfo FindAssembly(Guid libraryId)
Gets the assembly that corresponds to the given library ID.
libraryId (Guid)Library ID to search for.
The library info, or null if the ID is not registered.

FindAssemblyByObject

#
public GH_AssemblyInfo FindAssemblyByObject(Guid objectId)
Gets the assembly that corresponds to the given library ID.
objectId (Guid)The object ComponentGuid.
The library info, or null if the ID is not registered.

FindAssemblyByObject

#
public GH_AssemblyInfo FindAssemblyByObject(IGH_DocumentObject object)
Gets the assembly that corresponds to the given library ID.
object (IGH_DocumentObject)Object.
The library info, or null if the ID is not registered.

FindObjectByName

#
public IGH_ObjectProxy FindObjectByName(string name, bool ignoreWhiteSpace, bool ignoreCapitalisation)
Find an object by name. Obsolete and hidden objects are ignored. Only exact matches are included.
name (string)Name to search for. Name may be prefixed by Category and Subcategory.
ignoreWhiteSpace (bool)If true, whitespace is ignored during matching.
ignoreCapitalisation (bool)If true, capitalisation is ignored during matching.
The proxy that matches the name, or null if no such object could be found.

FindObjects

#
public int FindObjects(string[] terms, int maximumResults, ref IGH_ObjectProxy[] results, ref double[] resultWeights)
Searches the list of cached object proxies for objects that might be implied by a search term.
terms (string[])Search terms to use.
maximumResults (int)Maximum number of allowed hits.
results (ref IGH_ObjectProxy[])
resultWeights (ref double[])
A sorted list of search results.

FindObjects

#
public List<IGH_ObjectProxy> FindObjects(Guid libraryID)
Find all the objects that are part of a certain library.
libraryID (Guid)ID of library to search for.
A list of all the objects that are defined in the specified library.

FindUpgrader

#
public IGH_UpgradeObject FindUpgrader(Guid target)
Find the upgrader that can convert from the given target.
target (Guid)ComponentID of object to upgrade.
Matching upgrader or null if no upgrader is defined.

GetAlias

#
public string GetAlias(Guid target)
Gets the alias display string for a given object.
target (Guid)Object id to retrieve aliases for.
A parsable display string of aliases.

GetCategoryIcon

#
public Bitmap GetCategoryIcon(string fullName)
Get the icon for a specific category. If the icon hasn't been defined, this method will return the default icon.
fullName (string)Full name of category.
The category icon.

GetCategoryShortName

#
public string GetCategoryShortName(string fullName)
Get the abbreviation (short name) for a specific category. If the short name hasn't been defined, this method will return the full name instead.
fullName (string)Full name of category.
The abbreviated name or the full name.

GetCategorySymbolName

#
public string GetCategorySymbolName(string fullName)
Get the single char representation for a specific category. If the char hasn't been defined, this method will return the first char of the full name instead.
fullName (string)Full name of category.
The category char.

IsGraphCached

#
public bool IsGraphCached(Guid id)
Tests the graph cache for an existing graph type ID.
id (Guid)The ID to test for.
True if the ID is cached, false if it aint.

IsObjectCached

#
public bool IsObjectCached(Guid id)
Tests the caches for an existing object type ID.
id (Guid)The ID to test for.
True if the ID is cached, false if it aint.

IsUpgrader

#
public bool IsUpgrader(IEnumerable<IGH_DocumentObject> objs)
Checks to see if at least one upgrader is defined for a collection of objects.
objs (IEnumerable<IGH_DocumentObject>)

LoadAliases

#
public void LoadAliases()
Load the Alias table from the settings directory. Only use this function if you suspect the alias table settings file has changed due to some external process.

LoadExternalFiles

#
public bool LoadExternalFiles()
obsoleteThis method has been replaced by an overload which takes a single boolean.
Attempt to parse all external files. This includes GHA libraries, GHUSER objects and GHCLUSTER files.
True on success, false on failure.

LoadExternalFiles

#
public bool LoadExternalFiles(bool loadOneByOne)
Attempt to parse all external files. This includes GHA libraries, GHUSER objects and GHCLUSTER files.
loadOneByOne (bool)Ask the user prior to loading each file. This helps narrowing down startup crashes.
True on success, false on failure.

NewUserObject

#
public static bool NewUserObject(IGH_DocumentObject obj)
Create a new UserObject and write it to the Grasshopper User Object folder.
obj (IGH_DocumentObject)Object to write.
True on success, false on failure.

RemoveCachedGraph

#
public bool RemoveCachedGraph(Guid id)
Remove a cache entry from the graph cache. This cannot be undone.
id (Guid)The id to remove.
True on success, false on failure.

RemoveCachedObject

#
public bool RemoveCachedObject(Guid id)
Remove a cache entry from the object cache. This cannot be undone.
id (Guid)The id to remove.
True on success, false on failure.

RemoveCachedObject

#
public bool RemoveCachedObject(string userObjectFilePath)
Remove the user object (if any) that loads itself from a specified *.ghuser file.
userObjectFilePath (string)File name path of user object proxy.
True if an object proxy was removed, false if not.

SaveAliases

#
public void SaveAliases()
Save the alias table to the settings directory. Use this function if you change the alias table while ignoring usual channels.

SetAlias

#
public void SetAlias(string alias, Guid target)
Sets the aliases for a given target.
alias (string)Alias to add. If the alias string contains spaces or commas, those will be used to harvest partial aliases. Use a zero-length alias to remove all aliases to the target.
target (Guid)Component ID of object that is targeted by the alias.

UpdateRibbonUI

#
public static void UpdateRibbonUI()
Forces an update of the Ribbon control on the Grasshopper main form.

Events

GHAFileLoaded

#
Raised whenever a GHA file has been successfully loaded.