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

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

AllAddOns

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

CompleteRibbonLayout

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

DiscardedProxies

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

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

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

IsLoading

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

Libraries

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

LoadingExceptions

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

NoLoadExtension

#
public static string NoLoadExtension { get; }

ObjectProxies

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

ObjectProxyNames

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

TypeHints

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

Upgraders

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

Methods

AddAlias

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

AddCategoryIcon

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

AddCategoryShortName

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

AddCategorySymbolName

#
Add a single char category description.
public void AddCategorySymbolName(
fullCategoryName,
The full name of the category.
symbol
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.
[EditorBrowsable(EditorBrowsableState.Never)] public bool AddProxy(
proxy
Proxy to add.
)
True on success, false on failure.

AddProxyLibraryInfo

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

AliasTargets

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

Clear

#
Clear all caches.
public void Clear()

ClearStaleUserObjects

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

CompareProxies

#
Compare two object proxies. Names and exposures are taken into account.
public static int CompareProxies(
A,
First proxy to compare.
B
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

#
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.
public static string CopyFileToAppropriateFolder(
filepath,
The file to copy.
moveOriginalToBin
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()

DestroyLoadingUI

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

EmitGraph

#
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.
public IGH_Graph EmitGraph(
id
The graph type id to instantiate
)

EmitObject

#
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.
public IGH_DocumentObject EmitObject(
id
The component type id to instantiate
)

EmitObjectIcon

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

EmitObjectProxy

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

ExternalFiles

#
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.
public static List<GH_ExternalFile> ExternalFiles(
testGrasshopperCollisions,
If true, invalid duplicates of Grasshopper.dll will be tested for and warned about.
testExternalCollisions
If true, duplicates of GHA, GHUSER and GHCLUSTER files will be tested for and warned about.
)

FindAssembly

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

FindAssemblyByObject

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

FindAssemblyByObject

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

FindObjectByName

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

FindObjects

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

FindObjects

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

FindUpgrader

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

GetAlias

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

GetCategoryIcon

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

GetCategoryShortName

#
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.
public string GetCategoryShortName(
fullName
Full name of category.
)
The abbreviated name or the full name.

GetCategorySymbolName

#
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.
public string GetCategorySymbolName(
fullName
Full name of category.
)
The category char.

IsGraphCached

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

IsObjectCached

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

IsUpgrader

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

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.
public void LoadAliases()

LoadExternalFiles

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

LoadExternalFiles

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

NewUserObject

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

RemoveCachedGraph

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

RemoveCachedObject

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

RemoveCachedObject

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

SaveAliases

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

SetAlias

#
Sets the aliases for a given target.
public void SetAlias(
alias,
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
Component ID of object that is targeted by the alias.
)

UpdateRibbonUI

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

Events

GHAFileLoaded

#
Raised whenever a GHA file has been successfully loaded.