HostUtils
Contains static methods to deal with the runtime environment.
Properties
Gets the serial number of the computer running Rhino.
Get the current operating system language.
Returns: A Windows LCID (on Windows and macOS). On Windows, this will be LCID value regardless of those languages that Rhino supports. On macOS, this only returns LCID values for languages that Rhino does support.
The DeviceId is a unique, stable ID that anonymously identifies the device that Rhino is running on. It is computed based on hardware information that should not change when the OS is upgraded, or if commonly modified hardware are added or removed from the computer. The machine-specific information is hashed using a cryptographic hash to make it anonymous.
Name of the computer running Rhino. If the computer is part of a Windows Domain, the computer name has "@[DOMAIN]" appended.
Returns true when Rhino build is Beta or WIP, false otherwise
Returns Operating System Build Number "11763" | "7601" | ... | "Unknown"
Returns Operating System Edition: "Professional" | "ServerDatacenter" | ... | "Unknown"
Returns Operating System Installation Type: "Client" | "Server" | "Unknown"
Returns Operating System Edition: "Professional" | "ServerDatacenter" | ... | "Unknown"
Returns Operating System Version "6.1" | "6.3" | ... | "Unknown"
Gets the Rhino system managed assembly directory.
Indicates whether Rhino is running inside another application. returns false if Rhino.exe is the top-level application. returns true if some other application is the top-level application.
Returns true if the host operating system is in dark mode and Rhino supports dark mode.
Tests if this process is currently executing under the Mono runtime.
Tests if this process is currently executing under the .NET Core runtime.
Tests if this process is currently executing under the .NET Framework runtime.
Tests if RhinoCommon is currently executing inside of the Rhino.exe process. There are other cases where RhinoCommon could be running; specifically inside of Visual Studio when something like a windows form is being worked on in the resource editor or running stand-alone when compiled to be used as a version of OpenNURBS.
Tests if this process is currently executing inside a Windows Container.
Tests if this process is currently executing on the iOS platform.
Tests if this process is currently executing on the Linux platform.
Tests if this process is currently executing on the Mac OSX platform.
Tests if this process is currently executing in a server-like installation environment: Windows Server, or an AWS Marketplace instance (OperatingSystemInstallationType = "MarketplaceAWS"). Both share the headless-server behavior model — RHINO_TOKEN-based auth, non-interactive licensing UI, no local license discovery.
Tests if this process is currently executing on the Windows platform.
Methods
Gets the auto install plug-in folder for machine or current user.
Parameters:
| currentUser (bool) | true if the query relates to the current user. |
Returns: The full path to the revelant auto install plug-in directory.
Don't change this function in ANY way unless you chat with Steve first! This function is called by Rhino on initial startup and the signature must be exact
Parameters:
| task (string) |
Determines if the RDK is loaded.
Parameters:
| throwOnFalse (bool) | if the RDK is not loaded, then throws a RdkNotLoadedException. |
| usePreviousResult (bool) | if true, then the last result can be used instaed of performing a full check. |
Returns: true if the RDK is loaded; false if the RDK is not loaded. Note that the RdkNotLoadedException will hinder the retrieval of any return value.
public static void ClearFpuExceptionStatus()
Clear FPU exception and busy flags (Intel assembly fnclex)
Parses a plugin and create all the commands defined therein.
Parses a plugin and create all the commands defined therein.
Parameters:
| plugin (PlugIn) | Plugin to harvest for commands. |
Instantiates a plug-in type and registers the associated commands and classes.
Gets the debug dumps. This is a text description of the geometric contents. DebugDump() is intended for debugging and is not suitable for creating high quality text descriptions of an object.
Parameters:
| bezierCurve (BezierCurve) | curve to evaluate |
Returns: A debug dump text.
Gets the debug dumps. This is a text description of the geometric contents. DebugDump() is intended for debugging and is not suitable for creating high quality text descriptions of an object.
Parameters:
| geometry (GeometryBase) | Some geometry. |
Returns: A debug dump text.
Prints a debug message to the Rhino Command Line. The message will only appear if the SendDebugToCommandLine property is set to true.
Prints a debug message to the Rhino Command Line. The message will only appear if the SendDebugToCommandLine property is set to true.
Parameters:
| msg (string) | Message to print. |
Returns a description that is similar to the one in the _What command, except for not mentioning units and other attribute data. This description is translated in the current Rhino version.
Parameters:
| geometry (GeometryBase) |
Defines if Ole alerts ("Server busy") alerts should be visualized.
This function makes no sense on Mono.
Parameters:
| display (bool) | Whether alerts should be visible. |
Informs RhinoCommon of an exception that has been handled but that the developer wants to screen.
Parameters:
| ex (Exception) | An exception. |
Informs RhinoCommon of an exception that has been handled but that the developer wants to screen.
Execute a named callback
Parameters:
| name (string) | |
| args (NamedParametersEventArgs) |
Strip file extension from file name and check to see if it is a valid Rhino backup file extension.
Parameters:
| fileName (string) | File name to check. |
Returns: Returns true if the file name has an extension like 3dmbak.
Strip file extension from file name and check to see if it is a valid Rhino file extension.
Parameters:
| fileName (string) | File name to check. |
Returns: Returns true if the file name has an extension like 3dm.
public static bool GetAbsolutePath(string relativePath, bool bRelativePathisFileName, string relativeTo, bool bRelativeToIsFileName, out string pathOut)
Call this method to convert a relative path to an absolute path relative to the specified path.
Parameters:
| relativePath (string) | Relative path to convert to an absolute path |
| bRelativePathisFileName (bool) | If true then lpsFrom is treated as a file name otherwise it is treated as a directory name |
| relativeTo (string) | File or folder the path is relative to |
| bRelativeToIsFileName (bool) | If true then lpsFrom is treated as a file name otherwise it is treated as a directory name |
| pathOut (out string) | Reference to string which will receive the computed absolute path |
Returns: Returns true if parameters are valid and lpsRelativePath is indeed relative to lpsRelativeTo otherwise returns false
Recurses through the auto install plug-in folders and returns the directories containing "active" versions of plug-ins.
Remarks: If the same package is installed in both the user and machine locations, the newest directory wins.
Recurses through the auto install plug-in folders and returns the directories containing "active" versions of plug-ins.
Parameters:
| currentUser (bool) | Current user (true) or machine (false). |
Returns list of directory names where additional assemblies (plug-ins, DLLs, Grasshopper components) may be located
Returns information about the current process. If Rhino is the top level process, processName is "Rhino". Otherwise, processName is the name, without extension, of the main module that is executing. For example, "compute.backend" or "Revit". processVersion is the System.Version of the running process. It is the FileVersion of the executable.
Used by compute to define custom endpoints
For internal use only. Loads an assembly for dependency injection via IPlatformServiceLocator.
Get the output resolution for a given printer.
public static bool GetPrinterFormMargins(string printerName, string formName, bool portrait, out double leftMillimeters, out double topMillimeters, out double rightMillimeters, out double bottomMillimeters)
Get limit margins for a given form (page size) and a given printer. This is the physical limit area that a printer can print on a given page
Get list of form names available for a given printer
Parameters:
| printerName (string) | name or printer to query |
public static bool GetPrinterFormSize(string printerName, string formName, out double widthMillimeters, out double heightMillimeters)
Get the size of a sheet for a given form name / printer combination
Get list of printers available on this system
Only works on Windows. Returns null on Mac.
Returns: An assembly.
Get the processor count on this hardware. It supports querying on CPUs with more than 64 processors (Windows).
Gets the system reference assemblies to use when compiling code dynamically with Roslyn. Includes RhinoCommon, Rhino.UI, and Eto.
Remarks: Note that this list of assemblies is not guaranteed to be loadable and should only be used when compiling code dynamically.
Returns: An enumeration of paths to each of the rhino system assemblies to be used for compilation
public static void InitializeRhinoCommon()
Makes sure all static RhinoCommon components is set up correctly. This happens automatically when a plug-in is loaded, so you probably won't have to call this method.
Remarks: Subsequent calls to this method will be ignored.
[MonoPInvokeCallback(HostUtils.InitializeRDKCallback)]
public static void InitializeRhinoCommon_RDK()
Makes sure all static RhinoCommon RDK components are set up correctly. This happens automatically when the RDK is loaded, so you probably won't have to call this method.
Remarks: Subsequent calls to this method will be ignored.
public static void InitializeZooClient()
Initializes the ZooClient and Rhino license manager, this should get called automatically when RhinoCommon is loaded so you probably won't have to call this method.
DO NOT USE UNLESS YOU ARE CERTAIN ABOUT THE IMPLICATIONS.
This is an expert user function which should not be needed in most cases. This function is similar to a const_cast in C++ to allow an object to be made temporarily modifiable without causing RhinoCommon to convert the class from const to non-const by creating a duplicate.
You must call this function with a true parameter, make your modifications, and then restore the const flag by calling this function again with a false parameter. If you have any questions, please contact McNeel developer support before using!
Parameters:
| geometry (GeometryBase) | Some geometry. |
| makeNonConst (bool) | A boolean value. |
Inspects a dll to see if it is compiled as native code or as a .NET assembly
Parameters:
| path (string) |
Check to see if the file extension is a valid Rhino file extension.
Parameters:
| fileExtension (string) |
Returns: Return true if fileExtension is ".3dmbak", "3dmbak", ".3dm.bak", "3dm.bak", ".3dx.bak" or "3dx.bak", ignoring case.
Check to see if the file extension is a valid Rhino file extension.
Parameters:
| fileExtension (string) |
Returns: Returns true if fileExtension is ".3dm", "3dm", ".3dx" or "3dx", ignoring case.
Calls Assembly.LoadFrom in .NET 4.8. May call a different routine under .NET Core
Parameters:
| path (string) |
Calls Assembly.Load(AssemblyName) in .NET 4.8. May call a different routine under .NET Core
Parameters:
| assemblyName (AssemblyName) |
Calls Assembly.Load(byte[]) in .NET 4.8. May call a different routine under .NET Core
Parameters:
| stream (Stream) |
Logs a debug event. The function will log the filename and line number from where this function is called, in addition to the input message.
Parameters:
| message (string) | The event message. |
Used to help record times at startup with the -stopwatch flag to help determine bottlenecks in start up speed
Parameters:
| description (string) |
Register a class that can participate as a compute endpoint
Adds a new dynamic command to Rhino.
public static void RegisterNamedCallback(string name, EventHandler<NamedParametersEventArgs> callback)
Register a named callback
Parameters:
| name (string) | |
| callback (EventHandler<NamedParametersEventArgs>) |
Statics do not get disposed of in .NET. If you have a static IDisposable that you want to be disposed during shutdown, add your disposable to this list.
Parameters:
| disposable (IDisposable) |
Remove a named callback from the dictionary of callbacks
Parameters:
| name (string) |
For internal use only!!! Unhanded exception handler, writes stack trace to RhinoDotNet.txt file
[MonoPInvokeCallback(HostUtils.SendLogMessageToCloudCallback)]
public static void SendLogMessageToCloudCallbackProc(LogMessageType msg_type, nint pwStringClass, nint pwStringDesc, nint pwStringMessage)
Informs RhinoCommon of an message that has been handled but that the developer wants to screen.
Parameters:
| msg_type (HostUtils.LogMessageType) | The messag type |
| pwStringClass (nint) | The top level message type. |
| pwStringDesc (nint) | Finer grained description of the message. |
| pwStringMessage (nint) | The message. |
public static void SetInShutDown()
Informs the runtime that the application is shutting down.
Makes sure all static RhinoCommon RDK components are de-initialized so they aren't calling into space when the RDK is unloaded.
Remarks: Subsequent calls to this method will be ignored.
Exception handler for exceptions occurring on the UI thread
Parameters:
| sender (object) | |
| e (ThreadExceptionEventArgs) |
Events
Is raised when an exception is reported with one of the ExceptionReport(Exception) method.
Is raised when an exception is reported with one of the method.