### GetPoint Example Source: https://github.com/mcneel/rhinocommon-api-docs/blob/gh-pages/api/RhinoCommon/html/T_Rhino_Input_Custom_GetNumber.htm Demonstrates how to get a point input from the user. This method is called when Get() returns GetResult.Point. ```C# protected override Result Get() { Result result = base.Get(); if (result == Result.Point) { Point3d point = Point; // Use the point here } return result; } ``` -------------------------------- ### GetOption Example: Retrieving the Result Source: https://github.com/mcneel/rhinocommon-api-docs/blob/gh-pages/api/RhinoCommon/html/T_Rhino_Input_Custom_GetOption.htm Explains how to get the result of a Get*() call, indicating the type of input received. ```C# GetResult result = get.Result(); ``` -------------------------------- ### SetUpPreview Method Source: https://github.com/mcneel/rhinocommon-api-docs/blob/gh-pages/api/RhinoCommon/html/Methods_T_Rhino_Render_PreviewLighting.htm Sets up the preview lighting environment. ```APIDOC ## SetUpPreview Method ### Description Sets up the preview lighting environment. ### Method Public method ### Endpoint N/A (SDK Method) ### Parameters None explicitly documented. ### Response No specific return value documented. ``` -------------------------------- ### ManifestTable.FindId(Guid) Source: https://github.com/mcneel/rhinocommon-api-docs/blob/gh-pages/api/RhinoCommon/html/M_Rhino_FileIO_ManifestTable_FindId__1.htm Uses the guid to find a model component. Deleted objects cannot be found by id. The guid is the value that is stored in the .Id property. In a single document, no two active objects have the same guid. If an object is replaced with a new object, then the guid persists. For example, if the _Move command moves an object, then the moved object inherits its guid from the starting object. If the Copy command copies an object, then the copy gets a new guid. This guid persists through file saving/opening operations. This function will not find grip objects. ```APIDOC ## ManifestTable.FindId(Guid) ### Description Uses the guid to find a model component. Deleted objects cannot be found by id. The guid is the value that is stored in the .Id property. In a single document, no two active objects have the same guid. If an object is replaced with a new object, then the guid persists. For example, if the _Move command moves an object, then the moved object inherits its guid from the starting object. If the Copy command copies an object, then the copy gets a new guid. This guid persists through file saving/opening operations. This function will not find grip objects. ### Method public T FindId( Guid id ) where T : ModelComponent ### Parameters #### Path Parameters * **id** (Guid) - Required - Index of model component to search for. #### Type Parameters * **T** - The type, derived from ModelComponent or ModelComponent itself. ### Return Value Type: T - Reference to the rhino object or null if no such object could be found. ``` -------------------------------- ### FindId Method Source: https://github.com/mcneel/rhinocommon-api-docs/blob/gh-pages/api/RhinoCommon/html/M_Rhino_FileIO_CommonComponentTable_1_FindId.htm Uses the guid to find a model component. Deleted objects cannot be found by id. The guid is the value that is stored in the .Id property. In a single document, no two active objects have the same guid. If an object is replaced with a new object, then the guid persists. For example, if the _Move command moves an object, then the moved object inherits its guid from the starting object. If the Copy command copies an object, then the copy gets a new guid. This guid persists through file saving/opening operations. This function will not find grip objects. ```APIDOC ## FindId(id) ### Description Uses the guid to find a model component. Deleted objects cannot be found by id. The guid is the value that is stored in the .Id property. In a single document, no two active objects have the same guid. If an object is replaced with a new object, then the guid persists. For example, if the _Move command moves an object, then the moved object inherits its guid from the starting object. If the Copy command copies an object, then the copy gets a new guid. This guid persists through file saving/opening operations. This function will not find grip objects. ### Method `FindId` ### Parameters #### Path Parameters - **id** (Guid) - Required - ID of model component to search for. ### Return Value Type: T - Reference to the rhino object with the objectId or null if no such object could be found. ``` -------------------------------- ### PreviewBackground.SetUpPreview Method Signature Source: https://github.com/mcneel/rhinocommon-api-docs/blob/gh-pages/api/RhinoCommon/html/M_Rhino_Render_PreviewBackground_SetUpPreview.htm This C# signature shows how to call the SetUpPreview method, which is used to initialize the preview background. It requires a pointer to the scene server and a GUID. ```APIDOC ## SetUpPreview Method ### Description Initializes the preview background for rendering using a scene server pointer and a GUID. ### Method Signature ```csharp public void SetUpPreview(IntPtr sceneServerPointer, Guid guid) ``` ### Parameters #### Path Parameters * **sceneServerPointer** (IntPtr) - Description is missing in the source. * **guid** (Guid) - Description is missing in the source. ### See Also * [PreviewBackground Class](T_Rhino_Render_PreviewBackground.htm) * [Rhino.Render Namespace](N_Rhino_Render.htm) ``` -------------------------------- ### SetUpPreview Method Source: https://github.com/mcneel/rhinocommon-api-docs/blob/gh-pages/api/RhinoCommon/html/Methods_T_Rhino_Render_PreviewGeometry.htm Sets up the preview for the given geometry. ```APIDOC ## SetUpPreview Method ### Description Sets up the preview for the given geometry. ### Method Public method ### Endpoint N/A (SDK Method) ### Parameters None explicitly documented. ### Request Example N/A ### Response Indicates success or failure of the preview setup. ``` -------------------------------- ### ManifestTable.FindId Method (Guid, ModelComponentType) Source: https://github.com/mcneel/rhinocommon-api-docs/blob/gh-pages/api/RhinoCommon/html/M_Rhino_FileIO_ManifestTable_FindId_1.htm Uses the guid to find a model component. Deleted objects cannot be found by id. The guid is the value that is stored in the .Id property. In a single document, no two active objects have the same guid. If an object is replaced with a new object, then the guid persists. For example, if the _Move command moves an object, then the moved object inherits its guid from the starting object. If the Copy command copies an object, then the copy gets a new guid. This guid persists through file saving/opening operations. This function will not find grip objects. ```APIDOC ## ManifestTable.FindId(Guid id, ModelComponentType type) ### Description Uses the guid to find a model component. Deleted objects cannot be found by id. The guid is the value that is stored in the .Id property. In a single document, no two active objects have the same guid. If an object is replaced with a new object, then the guid persists. For example, if the _Move command moves an object, then the moved object inherits its guid from the starting object. If the Copy command copies an object, then the copy gets a new guid. This guid persists through file saving/opening operations. This function will not find grip objects. ### Method public abstract ModelComponent FindId( Guid id, ModelComponentType type ) ### Parameters #### Path Parameters * **id** (Guid) - Required - ID of model component to search for. * **type** (ModelComponentType) - Required - The type to be searched. If this is Unset then all types are searched. ### Return Value Type: ModelComponent - Reference to the rhino object with the objectId or null if no such object could be found. ``` -------------------------------- ### SetUpPreview Source: https://github.com/mcneel/rhinocommon-api-docs/blob/gh-pages/api/RhinoCommon/html/Methods_T_Rhino_Render_PreviewBackground.htm Configures the preview background settings. ```APIDOC ## SetUpPreview ### Description Configures the preview background settings. ### Method Public Method ### Endpoint N/A (Method Signature) ### Parameters None explicitly documented. ### Response None explicitly documented. ### Request Example N/A ### Response Example N/A ``` -------------------------------- ### FindId Method Source: https://github.com/mcneel/rhinocommon-api-docs/blob/gh-pages/api/RhinoCommon/html/M_Rhino_DocObjects_Tables_ObjectTable_FindId.htm Uses the object guid to find a rhino object. Deleted objects cannot be found by id. The guid is the value that is stored on RhinoObject.Id. In a single document, no two active objects have the same guid. If an object is replaced with a new object, then the guid persists. For example, if the _Move command moves an object, then the moved object inherits it's guid from the starting object. If the Copy command copies an object, then the copy gets a new guid. This guid persists through file saving/opening operations. This function will not find grip objects. ```APIDOC ## FindId Method ### Description Uses the object guid to find a rhino object. Deleted objects cannot be found by id. The guid is the value that is stored on RhinoObject.Id. ### Method `FindId` ### Parameters #### Path Parameters - **id** (Guid) - Description: The GUID of the object to find. ### Response #### Success Response - **RhinoObject** - The found Rhino object, or null if not found. ``` -------------------------------- ### FindId Source: https://github.com/mcneel/rhinocommon-api-docs/blob/gh-pages/api/RhinoCommon/html/Methods_T_Rhino_FileIO_File3dmInstanceDefinitionTable.htm Uses the guid to find a model component. Deleted objects cannot be found by id. The guid is the value that is stored in the .Id property. In a single document, no two active objects have the same guid. If an object is replaced with a new object, then the guid persists. For example, if the _Move command moves an object, then the moved object inherits its guid from the starting object. If the Copy command copies an object, then the copy gets a new guid. This guid persists through file saving/opening operations. This function will not find grip objects. This method is inherited from CommonComponentTable. ```APIDOC ## FindId ### Description Uses the GUID to find a model component. Deleted objects cannot be found by ID. The GUID persists through file saving/opening operations. This function will not find grip objects. ### Method Public method ### Endpoint N/A (SDK Method) ### Parameters * **guid** (Guid) - Description of the GUID parameter is not explicitly provided, but it is used to find a model component. ### Response Description of the return value is not explicitly provided, but it is expected to be the found model component or null if not found. ``` -------------------------------- ### SetUpPreview Method Source: https://github.com/mcneel/rhinocommon-api-docs/blob/gh-pages/api/RhinoCommon/html/M_Rhino_Render_PreviewLighting_SetUpPreview.htm Sets up the preview lighting for a given scene server pointer. This method is available since Rhino version 6.0. ```APIDOC ## SetUpPreview Method ### Description Sets up the preview lighting for a given scene server pointer. ### Method Signature public void SetUpPreview(IntPtr sceneServerPointer) ### Parameters #### sceneServerPointer - **sceneServerPointer** (System.IntPtr) - Description is missing in the documentation. ``` -------------------------------- ### Python GetPoint Dynamic Draw Setup Source: https://github.com/mcneel/rhinocommon-api-docs/blob/gh-pages/api/RhinoCommon/html/M_Rhino_Input_Custom_GetPoint_OnDynamicDraw.htm Shows the initial setup in Python for a GetPoint command, including setting prompts and constraints, before the dynamic draw logic would be implemented. ```Python from Rhino import * from Rhino.Geometry import * from Rhino.Commands import * from Rhino.Input.Custom import * from scriptcontext import doc from System.Drawing import * def RunCommand(): gp = GetPoint() gp.SetCommandPrompt("Center point") gp.Get() if gp.CommandResult() <> Result.Success: return gp.CommandResult() center_point = gp.Point() if center_point == Point3d.Unset: return Result.Failure gcp = GetCircleRadiusPoint(center_point) gcp.SetCommandPrompt("Radius") gcp.ConstrainToConstructionPlane(False) gcp.SetBasePoint(center_point, True) gcp.DrawLineFromPoint(center_point, True) gcp.Get() if gcp.CommandResult() <> Result.Success: return gcp.CommandResult() radius = center_point.DistanceTo(gcp.Point()) cplane = doc.Views.ActiveView.ActiveViewport.ConstructionPlane() ``` -------------------------------- ### RhinoApp.GetPlugInObject(Guid) Source: https://github.com/mcneel/rhinocommon-api-docs/blob/gh-pages/api/RhinoCommon/html/M_Rhino_RhinoApp_GetPlugInObject.htm Gets the plug-in object associated with a specific plug-in identifier. The plug-in must be installed in Rhino for this method to succeed. ```APIDOC ## RhinoApp.GetPlugInObject(Guid) ### Description Gets the object that is returned by PlugIn.GetPlugInObject for a given plug-in. This function attempts to find and load a plug-in with a given Id. When a plug-in is found, its GetPlugInObject function is called and the result is returned. Note the plug-in must have already been installed in Rhino or the plug-in manager will not know where to look for a plug-in with a matching id. ### Method static Object GetPlugInObject(Guid pluginId) ### Parameters #### Path Parameters - **pluginId** (Guid) - Required - Guid for a given plug-in. ### Return Value Type: Object - Result of PlugIn.GetPlugInObject for a given plug-in on success. ``` -------------------------------- ### Python GetPoint with Command Line Options Setup Source: https://github.com/mcneel/rhinocommon-api-docs/blob/gh-pages/api/RhinoCommon/html/M_Rhino_Input_Custom_GetBaseClass_AddOptionInteger_2.htm Initializes a GetPoint object and sets up integer, double, and boolean options. The list option setup is incomplete in the provided source. ```python import Rhino import scriptcontext def CommandLineOptions(): # For this example we will use a GetPoint class, but all of the custom # "Get" classes support command line options. gp = Rhino.Input.Custom.GetPoint() gp.SetCommandPrompt("GetPoint with options") # set up the options intOption = Rhino.Input.Custom.OptionInteger(1, 1, 99) dblOption = Rhino.Input.Custom.OptionDouble(2.2, 0, 99.9) boolOption = Rhino.Input.Custom.OptionToggle(True, "Off", "On") listValues = "Item0", "Item1", "Item2", "Item3", "Item4" ``` -------------------------------- ### Get Curve Length and Point at Length (VB) Source: https://github.com/mcneel/rhinocommon-api-docs/wiki/M_Rhino_Geometry_Curve_GetLength This VB.NET example demonstrates how to get the length of a selected curve and then find a point on the curve at a specified distance from its start. It includes user input for curve selection and length input. ```VB Partial Class Examples Public Shared Function ArcLengthPoint(ByVal doc As Rhino.RhinoDoc) As Rhino.Commands.Result Dim objref As Rhino.DocObjects.ObjRef = Nothing Dim rc As Rhino.Commands.Result = Rhino.Input.RhinoGet.GetOneObject("Select curve", True, Rhino.DocObjects.ObjectType.Curve, objref) If rc <> Rhino.Commands.Result.Success Then Return rc End If Dim crv As Rhino.Geometry.Curve = objref.Curve() If crv Is Nothing Then Return Rhino.Commands.Result.Failure End If Dim crv_length As Double = crv.GetLength() Dim length As Double = 0 rc = Rhino.Input.RhinoGet.GetNumber("Length from start", True, length, 0, crv_length) If rc <> Rhino.Commands.Result.Success Then Return rc End If Dim pt As Rhino.Geometry.Point3d = crv.PointAtLength(length) If pt.IsValid Then doc.Objects.AddPoint(pt) doc.Views.Redraw() End If Return Rhino.Commands.Result.Success End Function End Class ``` -------------------------------- ### Get Rhino 5 ID in VB Source: https://github.com/mcneel/rhinocommon-api-docs/wiki/P_Rhino_RhinoApp_Rhino5Id Use this property to retrieve the Guid for Rhino 5. No setup or imports are required beyond standard RhinoCommon usage. ```VB Public Shared ReadOnly Property Rhino5Id As Guid Get End Property ``` -------------------------------- ### SetupScriptContext Method Source: https://github.com/mcneel/rhinocommon-api-docs/blob/gh-pages/api/RhinoCommon/html/M_Rhino_Runtime_PythonScript_SetupScriptContext.htm Sets up the script context. Use a RhinoDoc instance unless unsure. ```APIDOC ## PythonScript.SetupScriptContext Method ### Description Sets up the script context. Use a RhinoDoc instance unless unsure. ### Method public virtual void SetupScriptContext(Object doc) ### Parameters #### Path Parameters - **doc** (Object) - Required - Document. ### See Also - [PythonScript Class](T_Rhino_Runtime_PythonScript.htm) - [Rhino.Runtime Namespace](N_Rhino_Runtime.htm) ``` -------------------------------- ### Get Rhino 3 ID in VB.NET Source: https://github.com/mcneel/rhinocommon-api-docs/wiki/P_Rhino_RhinoApp_Rhino3Id Use this property to retrieve the Guid for Rhino 3. No specific setup or imports are required beyond the RhinoCommon assembly. ```VB Public Shared ReadOnly Property Rhino3Id As Guid Get End Property ``` -------------------------------- ### C# Example for Mesh.CreateFromBrep Source: https://github.com/mcneel/rhinocommon-api-docs/wiki/M_Rhino_Geometry_Mesh_CreateFromBrep_1 Example demonstrating how to use Mesh.CreateFromBrep in C# to mesh a selected Brep object with specific meshing parameters. ```APIDOC ## C# Example: Create Mesh from Brep ### Description This example shows how to select a Brep object from the document and then create a mesh from it using the `Mesh.CreateFromBrep` method with `MeshingParameters.Smooth`. ### Code ```csharp using Rhino; using Rhino.Commands; using Rhino.Input; using Rhino.Geometry; using Rhino.DocObjects; public class CreateMeshFromBrepCommand : Command { public override string EnglishName { get { return "csCreateMeshFromBrep"; } } protected override Result RunCommand(RhinoDoc doc, RunMode mode) { ObjRef obj_ref; var rc = RhinoGet.GetOneObject("Select surface or polysurface to mesh", true, ObjectType.Surface | ObjectType.PolysrfFilter, out obj_ref); if (rc != Result.Success) return rc; var brep = obj_ref.Brep(); if (null == brep) return Result.Failure; var smooth_and_slower = MeshingParameters.Smooth; var meshes = Mesh.CreateFromBrep(brep, smooth_and_slower); if (meshes == null || meshes.Length == 0) return Result.Failure; var brep_mesh = new Mesh(); foreach (var mesh in meshes) brep_mesh.Append(mesh); doc.Objects.AddMesh(brep_mesh); doc.Views.Redraw(); return Result.Success; } } ``` ``` -------------------------------- ### C# Example for Brep.CreateFromLoft Source: https://github.com/mcneel/rhinocommon-api-docs/wiki/M_Rhino_Geometry_Brep_CreateFromLoft This C# code example demonstrates how to use the Brep.CreateFromLoft method to loft a selection of curves in Rhino. ```APIDOC ## C# Example: Lofting Curves ### Description This example shows how to prompt the user to select curves, then loft them using `Brep.CreateFromLoft` and add the resulting Breps to the document. ### Method ```csharp using System.Linq; using Rhino; using Rhino.Input.Custom; using Rhino.DocObjects; using Rhino.Commands; using Rhino.Geometry; public class LoftCommand : Command { public override string EnglishName { get { return "csLoft"; } } protected override Result RunCommand(RhinoDoc doc, RunMode mode) { // select curves to loft var gs = new GetObject(); gs.SetCommandPrompt("select curves to loft"); gs.GeometryFilter = ObjectType.Curve; gs.DisablePreSelect(); gs.SubObjectSelect = false; gs.GetMultiple(2, 0); if (gs.CommandResult() != Result.Success) return gs.CommandResult(); var curves = gs.Objects().Select(obj => obj.Curve()).ToList(); var breps = Brep.CreateFromLoft(curves, Point3d.Unset, Point3d.Unset, LoftType.Tight, false); foreach (var brep in breps) doc.Objects.AddBrep(brep); doc.Views.Redraw(); return Result.Success; } } ``` ``` -------------------------------- ### Get Rhino 5 ID in C# Source: https://github.com/mcneel/rhinocommon-api-docs/wiki/P_Rhino_RhinoApp_Rhino5Id Use this property to retrieve the Guid for Rhino 5. No setup or imports are required beyond standard RhinoCommon usage. ```C# public static Guid Rhino5Id { get; } ``` -------------------------------- ### Get Rhino 3 ID in C# Source: https://github.com/mcneel/rhinocommon-api-docs/wiki/P_Rhino_RhinoApp_Rhino3Id Use this property to retrieve the Guid for Rhino 3. No specific setup or imports are required beyond the RhinoCommon assembly. ```C# public static Guid Rhino3Id { get; } ``` -------------------------------- ### Rhino Command Line Options Example Source: https://github.com/mcneel/rhinocommon-api-docs/blob/gh-pages/api/RhinoCommon/html/M_Rhino_Input_Custom_OptionInteger__ctor_2.htm Demonstrates setting up and using various command line options (Integer, Double, Boolean, List) with Rhino's GetPoint class. This example shows how to add options, retrieve their values, and handle user input. ```Python import Rhino import scriptcontext def CommandLineOptions(): # "Get" classes support command line options. gp = Rhino.Input.Custom.GetPoint() gp.SetCommandPrompt("GetPoint with options") # set up the options intOption = Rhino.Input.Custom.OptionInteger(1, 1, 99) dblOption = Rhino.Input.Custom.OptionDouble(2.2, 0, 99.9) boolOption = Rhino.Input.Custom.OptionToggle(True, "Off", "On") listValues = "Item0", "Item1", "Item2", "Item3", "Item4" gp.AddOptionInteger("Integer", intOption) gp.AddOptionDouble("Double", dblOption) gp.AddOptionToggle("Boolean", boolOption) listIndex = 3 opList = gp.AddOptionList("List", listValues, listIndex) while True: # perform the get operation. This will prompt the user to # input a point, but also allow for command line options # defined above get_rc = gp.Get() if gp.CommandResult()!=Rhino.Commands.Result.Success: return gp.CommandResult() if get_rc==Rhino.Input.GetResult.Point: point = gp.Point() scriptcontext.doc.Objects.AddPoint(point) scriptcontext.doc.Views.Redraw() print "Command line option values are" print " Integer =", intOption.CurrentValue print " Double =", dblOption.CurrentValue print " Boolean =", boolOption.CurrentValue print " List =", listValues[listIndex] elif get_rc==Rhino.Input.GetResult.Option: if gp.OptionIndex()==opList: listIndex = gp.Option().CurrentListOptionIndex continue break return Rhino.Commands.Result.Success if __name__ == "__main__": CommandLineOptions() ``` -------------------------------- ### Python Example for Mesh.CreateFromBrep Source: https://github.com/mcneel/rhinocommon-api-docs/wiki/M_Rhino_Geometry_Mesh_CreateFromBrep_1 Example demonstrating how to use Mesh.CreateFromBrep in Python to mesh a selected Brep object with specific meshing parameters. ```APIDOC ## Python Example: Create Mesh from Brep ### Description This example shows how to select a Brep object from the document and then create a mesh from it using the `Mesh.CreateFromBrep` method with `MeshingParameters.Smooth`. ### Code ```python import Rhino from Rhino.Geometry import * from Rhino.Input import RhinoGet from Rhino.Commands import Result from Rhino.DocObjects import ObjectType import rhinoscriptsyntax as rs from scriptcontext import doc def RunCommand(): rc, objRef = RhinoGet.GetOneObject("Select surface or polysurface to mesh", True, ObjectType.Surface | ObjectType.PolysrfFilter) if rc <> Result.Success: return rc brep = objRef.Brep() if None == brep: return Result.Failure smoothAndSlower = MeshingParameters.Smooth meshes = Mesh.CreateFromBrep(brep, smoothAndSlower) if meshes == None or meshes.Length == 0: return Result.Failure brepMesh = Mesh() for mesh in meshes: brepMesh.Append(mesh) doc.Objects.AddMesh(brepMesh) doc.Views.Redraw() if __name__ == "__main__": RunCommand() ``` ``` -------------------------------- ### Get Rhino 2 ID in VB Source: https://github.com/mcneel/rhinocommon-api-docs/wiki/P_Rhino_RhinoApp_Rhino2Id Use this property to obtain the Guid associated with Rhino 2. No specific setup or imports are required beyond standard RhinoCommon usage. ```VB Public Shared ReadOnly Property Rhino2Id As Guid Get End Property ``` -------------------------------- ### Get Rhino 2 ID in C# Source: https://github.com/mcneel/rhinocommon-api-docs/wiki/P_Rhino_RhinoApp_Rhino2Id Use this property to obtain the Guid associated with Rhino 2. No specific setup or imports are required beyond standard RhinoCommon usage. ```C# public static Guid Rhino2Id { get; } ``` -------------------------------- ### Python Example: Initializing GetString Source: https://github.com/mcneel/rhinocommon-api-docs/blob/gh-pages/api/RhinoCommon/html/M_Rhino_Input_Custom_GetString__ctor.htm This Python snippet shows the basic initialization of a GetString object and setting a command prompt and default string. It is a starting point for more complex user input scenarios. ```Python import Rhino import scriptcontext import System.Guid, System.Drawing.Color def AddLayer(): # Cook up an unused layer name unused_name = scriptcontext.doc.Layers.GetUnusedLayerName(False) # Prompt the user to enter a layer name gs = Rhino.Input.Custom.GetString() gs.SetCommandPrompt("Name of layer to add") gs.SetDefaultString(unused_name) gs.AcceptNothing(True) gs.Get() if gs.CommandResult()!=Rhino.Commands.Result.Success: return gs.CommandResult() # Was a layer named entered? ``` -------------------------------- ### Example: Creating a Mesh from a Brep and Appending Source: https://github.com/mcneel/rhinocommon-api-docs/wiki/M_Rhino_Geometry_Mesh_Append This example demonstrates how to create a mesh from a Brep, then append multiple generated meshes into a single mesh object. ```APIDOC ## Examples **VB** ```vb Imports Rhino Imports Rhino.Commands Imports Rhino.Geometry Imports Rhino.DocObjects Namespace examples_vb Public Class CreateMeshFromBrepCommand Inherits Command Public Overrides ReadOnly Property EnglishName() As String Get Return "vbCreateMeshFromBrep" End Get End Property Protected Overrides Function RunCommand(doc As RhinoDoc, mode As RunMode) As Result Dim objRef As ObjRef = Nothing Dim rc = Rhino.Input.RhinoGet.GetOneObject("Select surface or polysurface to mesh", True, ObjectType.Surface Or ObjectType.PolysrfFilter, objRef) If rc <> Result.Success Then Return rc End If Dim brep = objRef.Brep() If brep Is Nothing Then Return Result.Failure End If ' you could choose any one of these for example Dim jaggedAndFaster = MeshingParameters.Coarse Dim smoothAndSlower = MeshingParameters.Smooth Dim defaultMeshParams = MeshingParameters.Default Dim minimal = MeshingParameters.Minimal Dim meshes = Mesh.CreateFromBrep(brep, smoothAndSlower) If meshes Is Nothing OrElse meshes.Length = 0 Then Return Result.Failure End If Dim brepmesh = New Mesh() For Each facemesh As Mesh In meshes brepmesh.Append(facemesh) Next doc.Objects.AddMesh(brepmesh) doc.Views.Redraw() Return Result.Success End Function End Class End Namespace ``` **C#** ```csharp using Rhino; using Rhino.Commands; using Rhino.Input; using Rhino.Geometry; using Rhino.DocObjects; namespace examples_cs { public class CreateMeshFromBrepCommand : Command { public override string EnglishName { get { return "csCreateMeshFromBrep"; } } protected override Result RunCommand(RhinoDoc doc, RunMode mode) { ObjRef obj_ref; var rc = RhinoGet.GetOneObject("Select surface or polysurface to mesh", true, ObjectType.Surface | ObjectType.PolysrfFilter, out obj_ref); if (rc != Result.Success) return rc; var brep = obj_ref.Brep(); if (null == brep) return Result.Failure; // you could choose anyone of these for example var jagged_and_faster = MeshingParameters.Coarse; var smooth_and_slower = MeshingParameters.Smooth; var default_mesh_params = MeshingParameters.Default; var minimal = MeshingParameters.Minimal; var meshes = Mesh.CreateFromBrep(brep, smooth_and_slower); if (meshes == null || meshes.Length == 0) return Result.Failure; var brep_mesh = new Mesh(); foreach (var mesh in meshes) brep_mesh.Append(mesh); doc.Objects.AddMesh(brep_mesh); doc.Views.Redraw(); return Result.Success; } } } ``` **Python** ```python import Rhino from Rhino.Geometry import * from Rhino.Input import RhinoGet from Rhino.Commands import Result from Rhino.DocObjects import ObjectType import rhinoscriptsyntax as rs from scriptcontext import doc def RunCommand(): rc, objRef = RhinoGet.GetOneObject("Select surface or polysurface to mesh", True, ObjectType.Surface | ObjectType.PolysrfFilter) if rc <> Result.Success: return rc brep = objRef.Brep() if None == brep: return Result.Failure jaggedAndFaster = MeshingParameters.Coarse smoothAndSlower = MeshingParameters.Smooth defaultMeshParams = MeshingParameters.Default minimal = MeshingParameters.Minimal meshes = Mesh.CreateFromBrep(brep, smoothAndSlower) if meshes == None or meshes.Length == 0: return Result.Failure brepMesh = Mesh() for mesh in meshes: brepMesh.Append(mesh) doc.Objects.AddMesh(brepMesh) doc.Views.Redraw() if __name__ == "__main__": RunCommand() ``` ``` -------------------------------- ### Find Max Z Coordinate using Point Projection (Python) Source: https://github.com/mcneel/rhinocommon-api-docs/wiki/M_Rhino_Geometry_Intersect_Intersection_CurveBrep This Python example demonstrates finding the maximum Z coordinate on a Brep surface at a given X, Y point using point projection. It utilizes rhinoscriptsyntax and Rhino.Geometry to select a surface, get its Brep representation, and then project points to find the Z value. The code snippet is incomplete, showing only the initial setup and the start of the projection call. ```python import rhinoscriptsyntax as rs from Rhino.Geometry import Intersect, Point3d, Vector3d from scriptcontext import doc def RunCommand(): # select a surface srfid = rs.GetObject("select serface", rs.filter.surface | rs.filter.polysurface) if not srfid: return # get the brep brep = rs.coercebrep(srfid) if not brep: return x = rs.GetReal("value of x", 0) y = rs.GetReal("value of y", 0) pts = [(abs(point.Z), point.Z) for point in Intersect.Intersection.ProjectPointsToBreps( ``` -------------------------------- ### VB.NET Example for Brep.CreateFromLoft Source: https://github.com/mcneel/rhinocommon-api-docs/wiki/M_Rhino_Geometry_Brep_CreateFromLoft This VB.NET code example demonstrates how to use the Brep.CreateFromLoft method to loft a selection of curves in Rhino. ```APIDOC ## VB.NET Example: Lofting Curves ### Description This example shows how to prompt the user to select curves, then loft them using `Rhino.Geometry.Brep.CreateFromLoft` and add the resulting Breps to the document. ### Method ```vb Imports Rhino Imports Rhino.Input.Custom Imports Rhino.DocObjects Imports Rhino.Commands Imports System.Collections.Generic Imports Rhino.Geometry Public Class LoftCommand Inherits Command Public Overrides ReadOnly Property EnglishName() As String Get Return "vbLoft" End Get End Property Protected Overrides Function RunCommand(doc As RhinoDoc, mode As Rhino.Commands.RunMode) As Result ' select curves to loft Dim gs = New GetObject() gs.SetCommandPrompt("select curves to loft") gs.GeometryFilter = ObjectType.Curve gs.DisablePreSelect() gs.SubObjectSelect = False gs.GetMultiple(2, 0) If gs.CommandResult() <> Result.Success Then Return gs.CommandResult() End If Dim curves = New List(Of Curve)() For Each obj As ObjRef In gs.Objects() curves.Add(obj.Curve()) Next Dim breps = Rhino.Geometry.Brep.CreateFromLoft(curves, Point3d.Unset, Point3d.Unset, LoftType.Tight, False) For Each brep As Brep In breps doc.Objects.AddBrep(brep) Next doc.Views.Redraw() Return Result.Success End Function End Class ``` ``` -------------------------------- ### GetPlugInObject(Guid) Source: https://github.com/mcneel/rhinocommon-api-docs/wiki/Overload_Rhino_RhinoApp_GetPlugInObject Gets the object that is returned by PlugIn.GetPlugInObject for a given plug-in using its unique identifier (Guid). This function attempts to find and load a plug-in with the given Id. When a plug-in is found, its GetPlugInObject function is called and the result is returned. The plug-in must have already been installed in Rhino. ```APIDOC ## GetPlugInObject(Guid) ### Description Gets the object that is returned by PlugIn.GetPlugInObject for a given plug-in using its unique identifier (Guid). This function attempts to find and load a plug-in with a given Id. When a plug-in is found, it's GetPlugInObject function is called and the result is returned here. Note the plug-in must have already been installed in Rhino or the plug-in manager will not know where to look for a plug-in with a matching id. ### Method Static ### Parameters #### Path Parameters - **id** (Guid) - Required - The unique identifier of the plug-in. ### Response #### Success Response - **object** - The object returned by the plug-in's GetPlugInObject function. #### Error Response - **null** - If the plug-in is not found or cannot be loaded. ``` -------------------------------- ### Get Curve Start Point (VB) Source: https://github.com/mcneel/rhinocommon-api-docs/wiki/P_Rhino_Geometry_Curve_PointAtStart Use the PointAtStart property to get the starting point of a curve. This is a read-only property. ```VB Public ReadOnly Property PointAtStart As Point3d Get ``` -------------------------------- ### VB Example for Mesh.CreateFromBrep Source: https://github.com/mcneel/rhinocommon-api-docs/wiki/M_Rhino_Geometry_Mesh_CreateFromBrep_1 Example demonstrating how to use Mesh.CreateFromBrep in VB.NET to mesh a selected Brep object with specific meshing parameters. ```APIDOC ## VB.NET Example: Create Mesh from Brep ### Description This example shows how to select a Brep object from the document and then create a mesh from it using the `Mesh.CreateFromBrep` method with `MeshingParameters.Smooth`. ### Code ```vb Imports Rhino Imports Rhino.Commands Imports Rhino.Geometry Imports Rhino.DocObjects Public Class CreateMeshFromBrepCommand Inherits Command Public Overrides ReadOnly Property EnglishName() As String Get Return "vbCreateMeshFromBrep" End Get End Property Protected Overrides Function RunCommand(doc As RhinoDoc, mode As RunMode) As Result Dim objRef As ObjRef = Nothing Dim rc = Rhino.Input.RhinoGet.GetOneObject("Select surface or polysurface to mesh", True, ObjectType.Surface Or ObjectType.PolysrfFilter, objRef) If rc <> Result.Success Then Return rc End If Dim brep = objRef.Brep() If brep Is Nothing Then Return Result.Failure End If Dim smoothAndSlower = MeshingParameters.Smooth Dim meshes = Mesh.CreateFromBrep(brep, smoothAndSlower) If meshes Is Nothing OrElse meshes.Length = 0 Then Return Result.Failure End If Dim brepmesh = New Mesh() For Each facemesh As Mesh In meshes brepmesh.Append(facemesh) Next doc.Objects.AddMesh(brepmesh) doc.Views.Redraw() Return Result.Success End Function End Class ``` ``` -------------------------------- ### Get Curve Length and Point at Length (C#) Source: https://github.com/mcneel/rhinocommon-api-docs/wiki/M_Rhino_Geometry_Curve_GetLength This C# example shows how to obtain the length of a selected curve and then calculate a point on that curve at a given distance from its start. It involves user interaction for selecting the curve and inputting the desired length. ```C# partial class Examples { public static Rhino.Commands.Result ArcLengthPoint(Rhino.RhinoDoc doc) { Rhino.DocObjects.ObjRef objref; Rhino.Commands.Result rc = Rhino.Input.RhinoGet.GetOneObject("Select curve", true, Rhino.DocObjects.ObjectType.Curve,out objref); if(rc!= Rhino.Commands.Result.Success) return rc; Rhino.Geometry.Curve crv = objref.Curve(); if( crv==null ) return Rhino.Commands.Result.Failure; double crv_length = crv.GetLength(); double length = 0; rc = Rhino.Input.RhinoGet.GetNumber("Length from start", true, ref length, 0, crv_length); if(rc!= Rhino.Commands.Result.Success) return rc; Rhino.Geometry.Point3d pt = crv.PointAtLength(length); if (pt.IsValid) { doc.Objects.AddPoint(pt); doc.Views.Redraw(); } return Rhino.Commands.Result.Success; } } ``` -------------------------------- ### GetPoint with Command Line Options (C#) Source: https://github.com/mcneel/rhinocommon-api-docs/blob/gh-pages/api/RhinoCommon/html/P_Rhino_Input_Custom_OptionToggle_CurrentValue.htm This C# example shows how to set up and use various command-line options, including an OptionToggle, with Rhino's GetPoint class. It demonstrates adding integer, double, boolean toggle, and list options, and retrieving their current values after user input. ```C# using System; using Rhino.Input.Custom; partial class Examples { public static Rhino.Commands.Result CommandLineOptions(Rhino.RhinoDoc doc) { // For this example we will use a GetPoint class, but all of the custom // "Get" classes support command line options. Rhino.Input.Custom.GetPoint gp = new Rhino.Input.Custom.GetPoint(); gp.SetCommandPrompt("GetPoint with options"); // set up the options Rhino.Input.Custom.OptionInteger intOption = new Rhino.Input.Custom.OptionInteger(1, 1, 99); Rhino.Input.Custom.OptionDouble dblOption = new Rhino.Input.Custom.OptionDouble(2.2, 0, 99.9); Rhino.Input.Custom.OptionToggle boolOption = new Rhino.Input.Custom.OptionToggle(true, "Off", "On"); string\[\] listValues = new string\[\] { "Item0", "Item1", "Item2", "Item3", "Item4" }; gp.AddOptionInteger("Integer", ref intOption); gp.AddOptionDouble("Double", ref dblOption); gp.AddOptionToggle("Boolean", ref boolOption); int listIndex = 3; int opList = gp.AddOptionList("List", listValues, listIndex); while (true) { // perform the get operation. This will prompt the user to input a point, but also // allow for command line options defined above Rhino.Input.GetResult get_rc = gp.Get(); if (gp.CommandResult() != Rhino.Commands.Result.Success) return gp.CommandResult(); if (get_rc == Rhino.Input.GetResult.Point) { doc.Objects.AddPoint(gp.Point()); doc.Views.Redraw(); Rhino.RhinoApp.WriteLine("Command line option values are"); Rhino.RhinoApp.WriteLine(" Integer = {0}", intOption.CurrentValue); Rhino.RhinoApp.WriteLine(" Double = {0}", dblOption.CurrentValue); Rhino.RhinoApp.WriteLine(" Boolean = {0}", boolOption.CurrentValue); Rhino.RhinoApp.WriteLine(" List = {0}", listValues[listIndex]); } else if (get_rc == Rhino.Input.GetResult.Option) { if (gp.OptionIndex() == opList) listIndex = gp.Option().CurrentListOptionIndex; continue; } break; } return Rhino.Commands.Result.Success; } } ``` -------------------------------- ### Initialize Source: https://github.com/mcneel/rhinocommon-api-docs/blob/gh-pages/api/RhinoCommon/html/Methods_T_Rhino_Runtime_IZooClientUtilities.htm Initializes the Zoo client utilities. ```APIDOC ## Initialize ### Description Initializes the Zoo client utilities. ### Method POST (assumed) ### Endpoint /api/IZooClientUtilities/Initialize ``` -------------------------------- ### Get or Set MappingTag Id in VB.NET Source: https://github.com/mcneel/rhinocommon-api-docs/wiki/P_Rhino_Render_MappingTag_Id This property allows for getting and setting the unique Guid identifier for a MappingTag in VB.NET. The Guid ensures distinct identification. ```VB Public Property Id As Guid Get Set ``` -------------------------------- ### PreviewGeometry.SetUpPreview Source: https://github.com/mcneel/rhinocommon-api-docs/blob/gh-pages/api/RhinoCommon/html/M_Rhino_Render_PreviewGeometry_SetUpPreview.htm Sets up the preview geometry for rendering. This method is available since Rhino 6.0. ```APIDOC ## SetUpPreview Method ### Description Sets up the preview geometry for rendering. This method is part of the PreviewGeometry class in the Rhino.Render namespace and is used to configure the scene server and render content for previewing geometry. It takes pointers to the scene server and render content, along with a boolean flag indicating whether to copy the content. ### Syntax ```csharp public void SetUpPreview(IntPtr sceneServerPointer, IntPtr pRenderContent, bool bCopy) ``` ```vb Public Sub SetUpPreview (sceneServerPointer As IntPtr, pRenderContent As IntPtr, bCopy As Boolean) ``` ### Parameters #### sceneServerPointer Type: System.IntPtr [Missing documentation for "M:Rhino.Render.PreviewGeometry.SetUpPreview(System.IntPtr,System.IntPtr,System.Boolean)"] #### pRenderContent Type: System.IntPtr [Missing documentation for "M:Rhino.Render.PreviewGeometry.SetUpPreview(System.IntPtr,System.IntPtr,System.Boolean)"] #### bCopy Type: System.Boolean [Missing documentation for "M:Rhino.Render.PreviewGeometry.SetUpPreview(System.IntPtr,System.IntPtr,System.Boolean)"] ### See Also * [PreviewGeometry Class](T_Rhino_Render_PreviewGeometry.htm) * [Rhino.Render Namespace](N_Rhino_Render.htm) ``` -------------------------------- ### Get or Set Arc Start Angle in Degrees (VB) Source: https://github.com/mcneel/rhinocommon-api-docs/wiki/P_Rhino_Geometry_Arc_StartAngleDegrees This property allows you to get or set the start angle of an arc in degrees using Visual Basic. The value should be a Double. ```VB Public Property StartAngleDegrees As Double Get Set ``` -------------------------------- ### GetOption Example: Setting the Command Prompt Message Source: https://github.com/mcneel/rhinocommon-api-docs/blob/gh-pages/api/RhinoCommon/html/T_Rhino_Input_Custom_GetOption.htm Demonstrates how to customize the message displayed in the Rhino command prompt window. ```C# get.SetCommandPrompt("Enter a value:"); ``` -------------------------------- ### TryGetValue (Guid) Source: https://github.com/mcneel/rhinocommon-api-docs/blob/gh-pages/api/RhinoCommon/html/T_Rhino_Render_Fields_FieldDictionary.htm Finds a field with the specified key and gets its Guid value if found. ```APIDOC ## TryGetValue (Guid) ### Description Finds a field with the specified key and gets its Guid value if found. ### Method GET (assumed, based on TryGetValue pattern) ### Endpoint /api/render/fields/{key} (assumed, based on TryGetValue pattern) ### Parameters #### Path Parameters - **key** (string) - Required - The key of the field to retrieve. #### Query Parameters None explicitly documented. ### Response #### Success Response (200) - **value** (Guid) - The value of the field if found. #### Response Example ```json { "value": "a1b2c3d4-e5f6-7890-1234-567890abcdef" } ``` ``` -------------------------------- ### Initialize Source: https://github.com/mcneel/rhinocommon-api-docs/blob/gh-pages/api/RhinoCommon/html/Methods_T_Rhino_PlugIns_LicenseUtils.htm Initializes the license manager. ```APIDOC ## Initialize ### Description Initializes the license manager. ### Method (Not specified, likely a static method call) ### Endpoint (Not applicable for SDK methods) ### Parameters (None explicitly listed) ### Response (None explicitly listed) ``` -------------------------------- ### Objects Method (Guid) Source: https://github.com/mcneel/rhinocommon-api-docs/blob/gh-pages/api/RhinoCommon/html/M_Rhino_DocObjects_Tables_NamedPositionTable_Objects.htm Gets the Rhino Objects associated with a named position by its Guid. ```APIDOC ## Objects(Guid id) ### Description Retrieves an array of Rhino Objects related to a Named Position. ### Method public RhinoObject[] Objects(Guid id) ### Parameters #### Path Parameters * **id** (Guid) - Required - The Guid of the named position from which you want to retrieve the objects. ### Return Value Type: RhinoObject[] - Array of Rhino Objects which are tracked by the Named Position. ``` -------------------------------- ### PostConstruct Method Source: https://github.com/mcneel/rhinocommon-api-docs/blob/gh-pages/api/RhinoCommon/html/Methods_T_Rhino_Render_RealtimeDisplayMode.htm Performs post-initialization tasks for the display mode. ```APIDOC ## PostConstruct Method ### Description Performs tasks that need to be executed after the object has been constructed and initialized. This is a common pattern for setup routines. ### Method (Method signature not explicitly provided in source, assumed to be a method call) ### Endpoint (Not applicable for SDK methods) ### Parameters (No parameters explicitly documented) ### Request Example (Not applicable for SDK methods) ### Response (No return type explicitly documented) ``` -------------------------------- ### Id Source: https://github.com/mcneel/rhinocommon-api-docs/blob/gh-pages/api/RhinoCommon/html/Properties_T_Rhino_DocObjects_Custom_CustomBrepObject.htm Gets the unique identifier (Guid) for the object. A new Guid is created if the object is added to a model with an empty or duplicate Guid. ```APIDOC ## Id ### Description Every object has a Guid (globally unique identifier, also known as UUID, or universally unique identifier). The default value is Guid.Empty. When an object is added to a model, the value is checked. If the value is Guid.Empty, a new Guid is created. If the value is not null but it is already used by another object in the model, a new Guid is created. If the value is not Guid.Empty and it is not used by another object in the model, then that value persists. When an object is updated, by a move for example, the value of ObjectId persists. This value is the same as the one returned by this.Attributes.ObjectId. ### Property Type Guid ``` -------------------------------- ### C# Mesh.CreatePartitions Example Source: https://github.com/mcneel/rhinocommon-api-docs/blob/gh-pages/api/RhinoCommon/html/M_Rhino_Geometry_Mesh_CreatePartitions.htm Demonstrates how to partition a mesh into smaller subsets using C#. This method is useful for rendering engines with limitations on the number of vertices and triangles per batch. It returns true if the mesh was successfully partitioned, and false otherwise. ```csharp public bool CreatePartitions( int maximumVertexCount, int maximumTriangleCount ) ``` -------------------------------- ### RhinoApp.InstallationType Source: https://github.com/mcneel/rhinocommon-api-docs/blob/gh-pages/api/RhinoCommon/html/P_Rhino_RhinoApp_InstallationType.htm Gets the type of installation. ```APIDOC ## RhinoApp.InstallationType ### Description Gets the type of installation. ### Property Value Type: [Installation](T_Rhino_ApplicationSettings_Installation.htm) ### Reference * [RhinoApp Class](T_Rhino_RhinoApp.htm) * [Rhino Namespace](N_Rhino.htm) ``` -------------------------------- ### GetPlugInObject (Guid) Source: https://github.com/mcneel/rhinocommon-api-docs/wiki/M_Rhino_RhinoApp_GetPlugInObject Retrieves the object associated with a plug-in identified by its Guid. The plug-in must be installed and accessible. ```APIDOC ## GetPlugInObject (Guid) ### Description Gets the object that is returned by PlugIn.GetPlugInObject for a given plug-in. This function attempts to find and load a plug-in with a given Id. When a plug-in is found, its GetPlugInObject function is called and the result is returned. ### Method `static Object GetPlugInObject(Guid pluginId)` ### Parameters #### Path Parameters - **pluginId** (Guid) - Required - Guid for a given plug-in. ### Return Value Type: Object - Result of PlugIn.GetPlugInObject for a given plug-in on success. ```