### Example Function with Docstring Source: https://github.com/mcneel/rhinoscriptsyntax/blob/rhino-8.x/docstring.md This example demonstrates a Python function with a comprehensive docstring following the RhinoScriptSyntax conventions. It includes sections for parameters, return values, examples, and related functions. Use this as a template for documenting your own functions. ```python def AliasMacro(alias, macro=None): """Returns or modifies the macro of a command alias. Parameters: alias (str): The name of an existing command alias. macro (str, optional): The new macro to run when the alias is executed. If omitted, the current alias macro is returned. Returns: str: If a new macro is not specified, the existing macro if successful. str: If a new macro is specified, the previous macro if successful. null: None on error Example: import rhinoscriptsyntax as rs aliases = rs.AliasNames() for alias in aliases: print("{} -> {}".format(alias, rs.AliasMacro(alias))) See Also: AddAlias AliasCount AliasNames DeleteAlias IsAlias """ rc = Rhino.ApplicationSettings.CommandAliasList.GetMacro(alias) if macro: Rhino.ApplicationSettings.CommandAliasList.SetMacro(alias, macro) if rc is None: return scriptcontext.errorhandler() return rc ``` -------------------------------- ### Import rhinoscriptsyntax Source: https://github.com/mcneel/rhinoscriptsyntax/blob/rhino-8.x/docstring.md This line is required for most examples to function. It imports the rhinoscriptsyntax library and assigns it the alias 'rs'. ```python import rhinoscriptsyntax as rs ``` -------------------------------- ### Get Point Input Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Prompts the user to pick points in the viewport. Can be used to get multiple points sequentially or with constraints. ```python import rhinoscriptsyntax as rs point1 = rs.GetPoint("Pick first point") if point1: rs.AddPoint(point1) point2 = rs.GetPoint("Pick second point", point1) if point2: rs.AddPoint(point2) ``` -------------------------------- ### Get and Set Current Layer Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Retrieves the name of the current layer and demonstrates how to set a new current layer. ```python import rhinoscriptsyntax as rs layer = rs.CurrentLayer() print("Current layer: {}".format(layer)) rs.CurrentLayer("Default") ``` -------------------------------- ### Get String Input Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Prompts the user to enter a string value. Can optionally provide a list of clickable command options. Use for text-based input like layer names. ```python import rhinoscriptsyntax as rs layer = rs.CurrentLayer() layer = rs.GetString("Layer to set current", layer) if layer: rs.CurrentLayer(layer) ``` -------------------------------- ### Get Color Input Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Displays the Rhino color picker dialog. Use to allow users to select a color. ```python import rhinoscriptsyntax as rs color = rs.LayerColor("Default") rgb = rs.GetColor(color) if rgb: rs.LayerColor("Default", rgb) ``` -------------------------------- ### GetColor - Get Color Input Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Displays the Rhino color picker dialog, allowing the user to select a color. ```APIDOC ## GetColor ### Description Displays the Rhino color picker dialog. ### Method Not Applicable (Function Call) ### Endpoint Not Applicable ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import rhinoscriptsyntax as rs color = rs.LayerColor("Default") rgb = rs.GetColor(color) if rgb: rs.LayerColor("Default", rgb) ``` ### Response #### Success Response (200) - **tuple(number, number, number)** (tuple) - RGB tuple on success #### Response Example ```json { "rgb": [255, 0, 0] } ``` ``` -------------------------------- ### GetString - Get String Input Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Pauses for user input of a string value, with options for a default string and a list of clickable command options. ```APIDOC ## GetString ### Description Pauses for user input of a string value. ### Method Not Applicable (Function Call) ### Endpoint Not Applicable ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import rhinoscriptsyntax as rs layer = rs.CurrentLayer() layer = rs.GetString("Layer to set current", layer) if layer: rs.CurrentLayer(layer) ``` ### Response #### Success Response (200) - **str** (str) - The string input or selected by the user #### Response Example ```json { "str": "MyLayer" } ``` ``` -------------------------------- ### Get Integer Input Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Prompts the user to enter a whole number within a specified range. Use when integer input is required. ```python import rhinoscriptsyntax as rs value = rs.GetInteger("Enter a number", 10, 1, 100) if value: print("You entered: {}".format(value)) ``` -------------------------------- ### Get and Set Layer Color Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Retrieves the color of a specified layer and shows how to change it. The color parameter accepts a color value. ```python import rhinoscriptsyntax as rs layer = rs.GetString("Layer name") if layer: color = rs.LayerColor(layer) print("Layer color: {}".format(color)) ``` -------------------------------- ### GetInteger - Get Integer Input Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Pauses for user input of a whole number, with options for a default value, minimum, and maximum allowable values. ```APIDOC ## GetInteger ### Description Pauses for user input of a whole number. ### Method Not Applicable (Function Call) ### Endpoint Not Applicable ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import rhinoscriptsyntax as rs value = rs.GetInteger("Enter a number", 10, 1, 100) if value: print("You entered: {}".format(value)) ``` ### Response #### Success Response (200) - **value** (number) - The whole number input by the user #### Response Example ```json { "value": 50 } ``` ``` -------------------------------- ### Convert Python 2 to Python 3 Scripts Source: https://github.com/mcneel/rhinoscriptsyntax/blob/rhino-8.x/README.md Use this script to convert Python 2 files to Python 3 compatible files. Ensure you have pipenv installed and set up. ```shell # one time only to setup pipenv environment and packages pipenv install # to convert the files pipenv run convert ``` -------------------------------- ### Get Object Selection Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Prompts the user to select a single object in the document. Can filter by object type, such as curves. ```python import rhinoscriptsyntax as rs obj = rs.GetObject("Select a curve", rs.filter.curve) if obj: print("Object selected: {}".format(obj)) ``` -------------------------------- ### Get Mesh Vertices Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Retrieves the vertex points of a selected mesh object and adds them as a point cloud to the document. ```python import rhinoscriptsyntax as rs obj = rs.GetObject("Select mesh", rs.filter.mesh) vertices = rs.MeshVertices(obj) if vertices: rs.AddPointCloud(vertices) ``` -------------------------------- ### Get Real Number Input Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Pauses for user input of a number, which can be a decimal. Use for radius or other floating-point values. ```python import rhinoscriptsyntax as rs radius = rs.GetReal("Radius of new circle", 3.14, 1.0) if radius: rs.AddCircle((0, 0, 0), radius) ``` -------------------------------- ### GetReal - Get Real Number Input Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Pauses for user input of a number (real or floating-point), with options for a default value, minimum, and maximum allowable values. ```APIDOC ## GetReal ### Description Pauses for user input of a number. ### Method Not Applicable (Function Call) ### Endpoint Not Applicable ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import rhinoscriptsyntax as rs radius = rs.GetReal("Radius of new circle", 3.14, 1.0) if radius: rs.AddCircle((0, 0, 0), radius) ``` ### Response #### Success Response (200) - **number** (number) - The number input by the user #### Response Example ```json { "number": 5.75 } ``` ``` -------------------------------- ### Get Bounding Box and Add Text Dots Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Retrieves the bounding box of a selected object and adds text dots at each corner to visualize the box. ```python import rhinoscriptsyntax as rs object = rs.GetObject("Select object") if object: box = rs.BoundingBox(object) if box: for i, point in enumerate(box): rs.AddTextDot(i, point) ``` -------------------------------- ### Add Line Curve with RhinoScriptSyntax Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Adds a line curve to the current model. Requires user input for start and end points. ```python import rhinoscriptsyntax as rs start = rs.GetPoint("Start of line") if start: end = rs.GetPoint("End of line") if end: rs.AddLine(start, end) ``` -------------------------------- ### Create Revolved Surface Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Creates a surface by revolving a curve around an axis. Requires a curve ID and an axis line. Start and end angles can be specified. ```python import rhinoscriptsyntax as rs curve = rs.AddLine((5,0,0), (10,0,10)) rs.AddRevSrf(curve, ((0,0,0), (0,0,1))) ``` -------------------------------- ### Curve Functions - AddLine Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Adds a line curve to the current Rhino model. Requires start and end points. ```APIDOC ## POST /api/curves/AddLine ### Description Adds a line curve to the current model. ### Method POST ### Endpoint /api/curves/AddLine ### Parameters #### Request Body - **start** (point) - Required - Start point of the line - **end** (point) - Required - End point of the line ### Request Example ```json { "start": [0,0,0], "end": [1,1,1] } ``` ### Response #### Success Response (200) - **guid** (string) - Identifier of the new curve object #### Response Example ```json { "guid": "a1b2c3d4-e5f6-7890-1234-567890abcdef" } ``` ``` -------------------------------- ### Layer Management Functions Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Functions for managing layers in Rhino, including getting, setting, deleting, and checking layer properties. ```APIDOC ## CurrentLayer ### Description Returns or changes the current layer. ### Method GET/SET ### Endpoint N/A (Function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **layer** (str, optional) - The name of an existing layer to set as current. ### Request Example ```python import rhinoscriptsyntax as rs layer = rs.CurrentLayer() print("Current layer: {}".format(layer)) rs.CurrentLayer("Default") ``` ### Response #### Success Response (200) - **layer_name** (str) - The name of the current layer if no layer is specified in the request. #### Response Example ```json { "layer_name": "Default" } ``` ``` ```APIDOC ## DeleteLayer ### Description Removes an existing layer from the document. ### Method DELETE ### Endpoint N/A (Function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **layer** (str) - Name of an existing empty layer to delete. ### Request Example ```python import rhinoscriptsyntax as rs layer = rs.GetString("Layer to remove") if layer: rs.DeleteLayer(layer) ``` ### Response #### Success Response (200) - **success** (bool) - True if the layer was successfully deleted, False otherwise. #### Response Example ```json { "success": true } ``` ``` ```APIDOC ## LayerColor ### Description Returns or changes the color of a layer. ### Method GET/SET ### Endpoint N/A (Function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **layer** (str) - Name of an existing layer. - **color** (color, optional) - The new color value for the layer. ### Request Example ```python import rhinoscriptsyntax as rs layer = rs.GetString("Layer name") if layer: color = rs.LayerColor(layer) print("Layer color: {}".format(color)) ``` ### Response #### Success Response (200) - **color_value** (color) - The current color value of the layer if no color is specified in the request. #### Response Example ```json { "color_value": "RGB(255,0,0)" } ``` ``` ```APIDOC ## IsLayer ### Description Verifies the existence of a layer in the document. ### Method GET ### Endpoint N/A (Function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **layer** (str) - The name of a layer to search for. ### Request Example ```python import rhinoscriptsyntax as rs layer = rs.GetString("Layer name to verify") if layer: exists = rs.IsLayer(layer) if exists: print("The layer exists.") else: print("The layer does not exist.") ``` ### Response #### Success Response (200) - **exists** (bool) - True if the layer exists, False otherwise. #### Response Example ```json { "exists": true } ``` ``` -------------------------------- ### Get Mesh Face Count Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Retrieves the total number of faces for a given mesh object. Requires a mesh object ID as input. ```python import rhinoscriptsyntax as rs obj = rs.GetObject("Select mesh", rs.filter.mesh) print("Total faces: জৈ{}Format(rs.MeshFaceCount(obj))) ``` -------------------------------- ### Add 3-Point Arc Curve with RhinoScriptSyntax Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Adds a 3-point arc curve to the document. Requires user input for the start, end, and a point on the arc. ```python import rhinoscriptsyntax as rs start = rs.GetPoint("Start of arc") end = rs.GetPoint("End of arc") point_on = rs.GetPoint("Point on arc") rs.AddArc3Pt(start, end, point_on) ``` -------------------------------- ### Get Circle Center Point Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Returns the center point of a circle curve object and adds a point at that location. Prompts the user to select a circle. Requires the rhinoscriptsyntax library. ```python import rhinoscriptsyntax as rs id = rs.GetObject("Select circle") if rs.IsCircle(id): point = rs.CircleCenterPoint(id) rs.AddPoint(point) ``` -------------------------------- ### Return Description: Multiple Return Values Source: https://github.com/mcneel/rhinoscriptsyntax/blob/rhino-8.x/docstring.md Illustrates how to document multiple possible return values with their types and descriptions. ```python str: The name of an existing command alias. number: If no argument, returns number of aliases. None: If not successful ``` -------------------------------- ### Return Description: Simple String Source: https://github.com/mcneel/rhinoscriptsyntax/blob/rhino-8.x/docstring.md Describes a simple string return value. ```python str: The name of an existing command alias. ``` -------------------------------- ### Add Point Cloud Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Creates a point cloud object from a list of 3D points. Optional colors can be provided for each point. ```python import rhinoscriptsyntax as rs points = (0,0,0), (1,1,1), (2,2,2), (3,3,3) rs.AddPointCloud(points) ``` -------------------------------- ### Return Description: List of Values Source: https://github.com/mcneel/rhinoscriptsyntax/blob/rhino-8.x/docstring.md Describes a return value that is a list of strings. ```python list(str, ...): A list of alias. ``` -------------------------------- ### Parameter Description: Nested Lists Source: https://github.com/mcneel/rhinoscriptsyntax/blob/rhino-8.x/docstring.md Illustrates how to describe nested lists within a parameter's type hint. ```python alias ([str, [number, number], bool]): list of values for command alias. ``` -------------------------------- ### Browse For Folder Dialog Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Opens a dialog box for the user to select a folder. Use to specify a directory path. ```python import rhinoscriptsyntax as rs folder = rs.BrowseForFolder("C:\\Program Files\\") if folder: print(folder) ``` -------------------------------- ### OpenFileName - Display File Open Dialog Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Displays a file open dialog box, allowing the user to select a file. ```APIDOC ## OpenFileName ### Description Displays a file open dialog box. ### Method Not Applicable (Function Call) ### Endpoint Not Applicable ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import rhinoscriptsyntax as rs filename = rs.OpenFileName() if filename: rs.MessageBox(filename) filename = rs.OpenFileName("Open", "Text Files (*.txt)|*.txt||") if filename: rs.MessageBox(filename) ``` ### Response #### Success Response (200) - **str** (str) - File name if successful #### Response Example ```json { "filename": "C:\\Users\\User\\Documents\\myfile.txt" } ``` ``` -------------------------------- ### BrowseForFolder - Display Browse Folder Dialog Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Displays a browse-for-folder dialog, allowing the user to select a folder. ```APIDOC ## BrowseForFolder ### Description Displays a browse-for-folder dialog. ### Method Not Applicable (Function Call) ### Endpoint Not Applicable ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import rhinoscriptsyntax as rs folder = rs.BrowseForFolder("C:\\Program Files\\") if folder: print(folder) ``` ### Response #### Success Response (200) - **str** (str) - Selected folder #### Response Example ```json { "folder": "C:\\Users\\User\\Documents" } ``` ``` -------------------------------- ### Get Mesh Vertex Count Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Returns the number of vertices in a mesh. The function takes the mesh object's ID. ```python import rhinoscriptsyntax as rs obj = rs.GetObject("Select mesh", rs.filter.mesh) print("Vertex count: {}".format(rs.MeshVertexCount(obj))) ``` -------------------------------- ### Curve Functions - AddArc3Pt Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Adds a 3-point arc curve to the Rhino document. Requires start, end, and a point on the arc. ```APIDOC ## POST /api/curves/AddArc3Pt ### Description Adds a 3-point arc curve to the document. ### Method POST ### Endpoint /api/curves/AddArc3Pt ### Parameters #### Request Body - **start** (point) - Required - Start point of the arc - **end** (point) - Required - End point of the arc - **point_on_arc** (point) - Required - A point on the arc ### Request Example ```json { "start": [0,0,0], "end": [1,0,0], "point_on_arc": [0.5, 0.5, 0] } ``` ### Response #### Success Response (200) - **guid** (string) - Identifier of the new curve object #### Response Example ```json { "guid": "d4e5f6a7-b8c9-0123-4567-890abcdef123" } ``` ``` -------------------------------- ### Open File Dialog Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Displays a standard file open dialog. Allows specifying dialog title, file filters, and default locations/filenames. ```python import rhinoscriptsyntax as rs filename = rs.OpenFileName() if filename: rs.MessageBox(filename) filename = rs.OpenFileName("Open", "Text Files (*.txt)|*.txt||") if filename: rs.MessageBox(filename) ``` -------------------------------- ### Parameter Description: Union of Types Source: https://github.com/mcneel/rhinoscriptsyntax/blob/rhino-8.x/docstring.md Shows how to use the pipe symbol (|) to indicate that a parameter can accept one of several specified types. ```python alias (str|guid): The name or guid identifier of an existing command alias. ``` -------------------------------- ### Parameter Description: Simple String Source: https://github.com/mcneel/rhinoscriptsyntax/blob/rhino-8.x/docstring.md Describes a simple string parameter. Ensure the type and a concise description are provided. ```python alias (str): The name of an existing command alias. ``` -------------------------------- ### Create Lofted Surface from Curves Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Adds a surface created by lofting curves. Requires a list of curves and can optionally specify start/end points, loft type, and simplification methods. ```python import rhinoscriptsyntax as rs objs = rs.GetObjects("Pick curves to loft", rs.filter.curve) if objs: rs.AddLoftSrf(objs) ``` -------------------------------- ### Create Plane Surface Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Creates a plane surface and adds it to the document. Requires a plane definition, and magnitudes in the U and V directions. ```python import rhinoscriptsyntax as rs rs.AddPlaneSurface(rs.WorldXYPlane(), 5.0, 3.0) ``` -------------------------------- ### Return Description: Coded Numeric Values Source: https://github.com/mcneel/rhinoscriptsyntax/blob/rhino-8.x/docstring.md Explains numeric return values that represent specific codes or states. ```python 1 = counter clockwise 0 = stationary -1 = clockwise ``` -------------------------------- ### IsObject Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Verifies the existence of an object. ```APIDOC ## IsObject ### Description Verifies the existence of an object. ### Method IsObject ### Parameters #### Path Parameters - **object_id** (guid) - Required - An object to test ### Response #### Success Response (200) - **bool** (bool) - True if the object exists ``` -------------------------------- ### Get Arc Radius Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Returns the radius of an arc curve object. Prompts the user to select an arc and prints its radius. Requires the rhinoscriptsyntax library. ```python import rhinoscriptsyntax as rs id = rs.GetObject("Select arc") if rs.IsArc(id): radius = rs.ArcRadius(id) print("Arc radius: {}".format(radius)) ``` -------------------------------- ### Create Surface from Edge Curves Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Creates a surface from 2, 3, or 4 edge curves. Requires a list of curve IDs. Ensure the correct number of curves are selected. ```python import rhinoscriptsyntax as rs curves = rs.GetObjects("Select 2, 3, or 4 curves", rs.filter.curve) if curves and len(curves) > 1: rs.AddEdgeSrf(curves) ``` -------------------------------- ### Create Surface from Planar Curves Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Creates one or more surfaces from selected planar curves. Ensure curves are planar before selection. ```python import rhinoscriptsyntax as rs objs = rs.GetObjects("Select planar curves to build surface", rs.filter.curve) if objs: rs.AddPlanarSrf(objs) ``` -------------------------------- ### Get Mesh Face Vertices Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Retrieves the vertices defining the faces of a mesh. The code iterates through the faces and adds polylines to represent them, disabling redraw for performance. ```python import rhinoscriptsyntax as rs obj = rs.GetObject("Select mesh", rs.filter.mesh) faces = rs.MeshFaces(obj, False) if faces: rs.EnableRedraw(False) i = 0 while i <= len(faces): face = faces[i], faces[i+1], faces[i+2], faces[i] # Note: This line seems to have a typo, likely intended to be faces[i+3] for quads or similar logic. rs.AddPolyline(face) i += 3 rs.EnableRedraw(True) ``` -------------------------------- ### Get Arc Angle Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Returns the angle of an arc curve object in degrees. Prompts the user to select an arc and prints its angle. Requires the rhinoscriptsyntax library. ```python import rhinoscriptsyntax as rs id = rs.GetObject("Select arc") if rs.IsArc(id): angle = rs.ArcAngle(id) print("Arc angle: {}".format(angle)) ``` -------------------------------- ### Create Pipe Around Curve Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Creates a single-walled surface with a circular profile around a curve. Requires the curve ID and parameters for radius. Blend type, cap style, and fit options are available. ```python import rhinoscriptsyntax as rs curve = rs.GetObject("Select curve to create pipe around", rs.filter.curve, True) if curve: domain = rs.CurveDomain(curve) rs.AddPipe(curve, 0, 4) ``` -------------------------------- ### User Interface Functions Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Functions for interacting with the user through prompts and selections. ```APIDOC ## GetPoint ### Description Pauses for user input of a point. ### Method GET ### Endpoint N/A (Function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **message** (str, optional) - A prompt or message to display to the user. - **base_point** (point, optional) - A starting or base point for the input. - **distance** (number, optional) - A constraining distance for the point input. - **in_plane** (bool, optional) - If True, constrains the point input to the construction plane. ### Request Example ```python import rhinoscriptsyntax as rs point1 = rs.GetPoint("Pick first point") if point1: rs.AddPoint(point1) point2 = rs.GetPoint("Pick second point", point1) if point2: rs.AddPoint(point2) ``` ### Response #### Success Response (200) - **point** (point) - The 3D point selected by the user. #### Response Example ```json { "point": [1.0, 2.0, 3.0] } ``` #### Cancellation Response - **point** (null) - Returns None if the user cancels the input. #### Cancellation Response Example ```json { "point": null } ``` ``` ```APIDOC ## GetObject ### Description Prompts the user to select a single object. ### Method GET ### Endpoint N/A (Function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **message** (str, optional) - A prompt or message to display to the user. - **filter** (number, optional) - An object type filter to restrict selections. - **preselect** (bool, optional) - Allows pre-selected objects to be returned. - **select** (bool, optional) - If True, the picked object will be selected. ### Request Example ```python import rhinoscriptsyntax as rs obj = rs.GetObject("Select a curve", rs.filter.curve) if obj: print("Object selected: {}".format(obj)) ``` ### Response #### Success Response (200) - **object_id** (guid) - The identifier of the picked object. #### Response Example ```json { "object_id": "e5f6a7b8-c9d0-1234-5678-90abcdef1234" } ``` #### Cancellation Response - **object_id** (null) - Returns None if the user cancels the selection. #### Cancellation Response Example ```json { "object_id": null } ``` ``` -------------------------------- ### Get Object Type in Rhino Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Retrieves the type of a selected object. The return value is a number representing the object type (e.g., Point, Curve, Surface, Mesh). ```python import rhinoscriptsyntax as rs obj = rs.GetObject("Select object") if obj: objtype = rs.ObjectType(obj) print("Object type:{}".format(objtype)) ``` -------------------------------- ### AddPlanarSrf Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Creates one or more surfaces from planar curves. ```APIDOC ## POST /api/AddPlanarSrf ### Description Creates one or more surfaces from planar curves. ### Method POST ### Endpoint /api/AddPlanarSrf ### Parameters #### Request Body - **object_ids** (list[guid]) - Required - Curves to use for creating planar surfaces ### Response #### Success Response (200) - **list[guid]** (array) - Identifiers of surfaces created ``` -------------------------------- ### Get Arc Center Point Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Returns the center point of an arc curve object and adds a point at that location. Prompts the user to select an arc. Requires the rhinoscriptsyntax library. ```python import rhinoscriptsyntax as rs id = rs.GetObject("Select arc") if rs.IsArc(id): point = rs.ArcCenterPoint(id) rs.AddPoint(point) ``` -------------------------------- ### Parameter Description: List of Different Types Source: https://github.com/mcneel/rhinoscriptsyntax/blob/rhino-8.x/docstring.md Describes a parameter that accepts a list containing elements of different data types. ```python alias ([str, number, bool]): list of an existing command alias. ``` -------------------------------- ### Create Network Surface from Curves Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Creates a surface from a network of crossing curves. Requires a list of curve IDs. Continuity options for edge matching are available. ```python import rhinoscriptsyntax as rs curve_ids = rs.GetObjects("Select curves in network", 4, True, True) if len(curve_ids) > 0: rs.AddNetworkSrf(curve_ids) ``` -------------------------------- ### MessageBox - Display Message Box Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Displays a message box to the user, with options for different buttons and icons. ```APIDOC ## MessageBox ### Description Displays a message box. ### Method Not Applicable (Function Call) ### Endpoint Not Applicable ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import rhinoscriptsyntax as rs rs.MessageBox("Hello Rhino!") rs.MessageBox("Hello Rhino!", 4 | 32) # Yes/No with question icon rs.MessageBox("Hello Rhino!", 2 | 48) # Abort/Retry/Ignore with warning icon ``` ### Response #### Success Response (200) - **number** (number) - Indicating which button was clicked (1=OK, 2=Cancel, etc.) #### Response Example ```json { "button_clicked": 1 } ``` ``` -------------------------------- ### AddPlaneSurface Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Creates a plane surface and adds it to the document. ```APIDOC ## POST /api/AddPlaneSurface ### Description Creates a plane surface and adds it to the document. ### Method POST ### Endpoint /api/AddPlaneSurface ### Parameters #### Request Body - **plane** (plane) - Required - The plane - **u_dir** (number) - Required - Magnitude in the U direction - **v_dir** (number) - Required - Magnitude in the V direction ### Response #### Success Response (200) - **guid** (string) - Identifier of the new object ``` -------------------------------- ### AddPipe Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Creates a single walled surface with a circular profile around a curve. ```APIDOC ## POST /api/AddPipe ### Description Creates a single walled surface with a circular profile around a curve. ### Method POST ### Endpoint /api/AddPipe ### Parameters #### Request Body - **curve_id** (guid) - Required - Identifier of rail curve - **parameters** (list[number]) - Required - Normalized curve parameters - **radii** (list[number]) - Required - Radius values at parameters - **blend_type** (number) - Optional - 0=local, 1=global - **cap** (number) - Optional - 0=none, 1=flat, 2=round - **fit** (bool) - Optional - Attempt to fit a single surface ### Response #### Success Response (200) - **list[guid]** (array) - Identifiers of new objects created ``` -------------------------------- ### AddPlanarMesh Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Creates a planar mesh from a closed, planar curve. ```APIDOC ## AddPlanarMesh ### Description Creates a planar mesh from a closed, planar curve. ### Method rs.AddPlanarMesh ### Parameters - **object_id** (guid) - Required - Identifier of a closed, planar curve - **delete_input** (bool, optional) - Delete the input curve (default: False) ### Returns - **guid** - Identifier of the new mesh ``` -------------------------------- ### AddLayer Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Adds a new layer to the document. ```APIDOC ## AddLayer ### Description Adds a new layer to the document. ### Method AddLayer ### Parameters #### Path Parameters - **name** (str) - Optional - The layer name - **color** (color) - Optional - A Red-Green-Blue color value - **visible** (bool) - Optional - Layer visibility (default: True) - **locked** (bool) - Optional - Layer locked state (default: False) - **parent** (str) - Optional - Name of parent layer ### Response #### Success Response (200) - **str** - The full name of the new layer ``` -------------------------------- ### Display Message Box Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Shows a simple message box to the user. Supports different button and icon combinations. ```python import rhinoscriptsyntax as rs rs.MessageBox("Hello Rhino!") rs.MessageBox("Hello Rhino!", 4 | 32) # Yes/No with question icon rs.MessageBox("Hello Rhino!", 2 | 48) # Abort/Retry/Ignore with warning icon ``` -------------------------------- ### AddNetworkSrf Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Creates a surface from a network of crossing curves. ```APIDOC ## POST /api/AddNetworkSrf ### Description Creates a surface from a network of crossing curves. ### Method POST ### Endpoint /api/AddNetworkSrf ### Parameters #### Request Body - **curves** (list[guid]) - Required - Curves from which to create the surface - **continuity** (number) - Optional - Edge matching (0=loose, 1=position, 2=tangency, 3=curvature) ### Response #### Success Response (200) - **guid** (string) - Identifier of new object ``` -------------------------------- ### Add Text to Document Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Adds a text string to the document at a specified point or plane. Customizable height, font, style, and justification are available. ```python import rhinoscriptsyntax as rs point = rs.GetPoint("Pick point") if point: rs.AddText("Hello Rhino!", point) ``` -------------------------------- ### AddEdgeSrf Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Creates a surface from 2, 3, or 4 edge curves. ```APIDOC ## POST /api/AddEdgeSrf ### Description Creates a surface from 2, 3, or 4 edge curves. ### Method POST ### Endpoint /api/AddEdgeSrf ### Parameters #### Request Body - **curve_ids** (list[guid]) - Required - List of curves (2-4) ### Response #### Success Response (200) - **guid** (string) - Identifier of new object ``` -------------------------------- ### AddCone Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Adds a cone shaped polysurface to the document. ```APIDOC ## AddCone ### Description Adds a cone shaped polysurface to the document. ### Method Not specified (assumed to be a function call within a script) ### Endpoint Not applicable (scripting function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import rhinoscriptsyntax as rs radius = 5.0 base = rs.GetPoint("Base of cone") if base: height = rs.GetPoint("Height of cone", base) if height: rs.AddCone(base, height, radius) ``` ### Response #### Success Response (200) - **guid** (guid) - Identifier of the new object #### Response Example None specified ``` -------------------------------- ### Save File Dialog Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Displays a standard file save dialog. Similar to OpenFileName, it allows customization of dialog title, filters, and defaults. ```python import rhinoscriptsyntax as rs filename = rs.SaveFileName("Save", "Text Files (*.txt)|*.txt||") if filename: rs.MessageBox(filename) ``` -------------------------------- ### ObjectType Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Returns the type of an object. ```APIDOC ## ObjectType ### Description Returns the type of an object. ### Method ObjectType ### Parameters #### Path Parameters - **object_id** (guid) - Required - Identifier of an object ### Response #### Success Response (200) - **number** - The object type (1=Point, 4=Curve, 8=Surface, 32=Mesh, etc.) ``` -------------------------------- ### Add Sphere to Document Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Adds a spherical surface. Requires a center point and radius. Ensure the center point is defined before proceeding. ```python import rhinoscriptsyntax as rs radius = 2 center = rs.GetPoint("Center of sphere") if center: rs.AddSphere(center, radius) ``` -------------------------------- ### Display Check List Box Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Shows a dialog with a list of items, each with a checkbox. Allows users to select multiple items with on/off states. ```python import rhinoscriptsyntax as rs layers = rs.LayerNames() if layers: items = [(layer, rs.IsLayerOn(layer)) for layer in layers] results = rs.CheckListBox(items, "Turn layers on/off", "Layers") if results: for layer, state in results: rs.LayerVisible(layer, state) ``` -------------------------------- ### ShowObject Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Shows a previously hidden object in the Rhino document. ```APIDOC ## ShowObject ### Description Shows a previously hidden object in the Rhino document. ### Method ShowObject ### Parameters #### Path Parameters - **object_id** (guid) - Required - Identifier of object to show ### Response #### Success Response (200) - **bool** (bool) - True or False indicating success or failure ``` -------------------------------- ### MirrorObject Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Mirrors a single object across a plane defined by two points. ```APIDOC ## MirrorObject ### Description Mirrors a single object across a plane defined by two points. Optionally copies the object. ### Method MirrorObject ### Parameters #### Path Parameters - **object_id** (guid) - Required - The identifier of an object to mirror - **start_point** (point) - Required - Start of the mirror plane - **end_point** (point) - Required - End of the mirror plane #### Query Parameters - **copy** (bool) - Optional - Copy the object (default: False) ### Response #### Success Response (200) - **guid** (guid) - Identifier of the mirrored object ``` -------------------------------- ### ListBox - Display List Box Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Displays a list of items in a list box dialog, allowing the user to select one item. ```APIDOC ## ListBox ### Description Displays a list of items in a list box dialog. ### Method Not Applicable (Function Call) ### Endpoint Not Applicable ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import rhinoscriptsyntax as rs layers = rs.LayerNames() if layers: result = rs.ListBox(layers, "Layer to set current") if result: rs.CurrentLayer(result) ``` ### Response #### Success Response (200) - **str** (str) - The selected item #### Response Example ```json { "selected_item": "Layer1" } ``` ``` -------------------------------- ### Display List Box Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Presents a list of items in a dialog box for the user to select one. Useful for choosing from predefined options. ```python import rhinoscriptsyntax as rs layers = rs.LayerNames() if layers: result = rs.ListBox(layers, "Layer to set current") if result: rs.CurrentLayer(result) ``` -------------------------------- ### SaveFileName - Display File Save Dialog Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Displays a save dialog box, allowing the user to specify a file name and location to save a file. ```APIDOC ## SaveFileName ### Description Displays a save dialog box. ### Method Not Applicable (Function Call) ### Endpoint Not Applicable ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import rhinoscriptsyntax as rs filename = rs.SaveFileName("Save", "Text Files (*.txt)|*.txt||") if filename: rs.MessageBox(filename) ``` ### Response #### Success Response (200) - **str** (str) - File name if successful #### Response Example ```json { "filename": "C:\\Users\\User\\Documents\\newfile.txt" } ``` ``` -------------------------------- ### ObjectLayer Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Returns or modifies the layer of an object. ```APIDOC ## ObjectLayer ### Description Returns or modifies the layer of an object. ### Method ObjectLayer ### Parameters #### Path Parameters - **object_id** (guid) - Required - The identifier of the object(s) - **layer** (str) - Optional - Name of an existing layer ### Response #### Success Response (200) - **str** - The object's current or previous layer ``` -------------------------------- ### Return Description: Mixed Types Source: https://github.com/mcneel/rhinoscriptsyntax/blob/rhino-8.x/docstring.md Describes a return value that is a list containing elements of different data types. ```python list(str, number, bool): Various information about command alias. ``` -------------------------------- ### ObjectName Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Returns or modifies the name of an object. ```APIDOC ## ObjectName ### Description Returns or modifies the name of an object. ### Method ObjectName ### Parameters #### Path Parameters - **object_id** (guid) - Required - Identifier of object(s) - **name** (str) - Optional - The new object name ### Response #### Success Response (200) - **str** - Current or previous object name ``` -------------------------------- ### Return Description: None Source: https://github.com/mcneel/rhinoscriptsyntax/blob/rhino-8.x/docstring.md Specifies that a function returns None, even if it's an error condition. ```python Returns: None ``` -------------------------------- ### Object Manipulation Functions Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Functions for common object operations like copying, deleting, moving, rotating, and scaling. ```APIDOC ## CopyObject ### Description Copies an object from one location to another, or in-place. ### Method rs.CopyObject ### Parameters #### Path Parameters - **object_id** (guid) - Required - The object to copy. - **translation** (vector) - Optional - Translation vector to apply. If not provided, the object is copied in-place. ### Returns #### Success Response (guid) - **new_object_id** (guid) - Identifier for the newly created copy. ### Request Example ```python import rhinoscriptsyntax as rs id = rs.GetObject("Select object to copy") if id: start = rs.GetPoint("Point to copy from") if start: end = rs.GetPoint("Point to copy to", start) if end: translation = end - start rs.CopyObject(id, translation) ``` ``` ```APIDOC ## DeleteObject ### Description Deletes a single object from the document. ### Method rs.DeleteObject ### Parameters #### Path Parameters - **object_id** (guid) - Required - Identifier of the object to delete. ### Returns #### Success Response (bool) - **success** (bool) - True if the deletion was successful, False otherwise. ### Request Example ```python import rhinoscriptsyntax as rs id = rs.GetObject("Select object to delete") if id: rs.DeleteObject(id) ``` ``` ```APIDOC ## MoveObject ### Description Moves a single object. ### Method rs.MoveObject ### Parameters #### Path Parameters - **object_id** (guid) - Required - The identifier of the object to move. - **translation** (vector) - Required - A list of 3 numbers or a Vector3d representing the translation. ### Returns #### Success Response (guid) - **moved_object_id** (guid) - Identifier of the moved object. ### Request Example ```python import rhinoscriptsyntax as rs id = rs.GetObject("Select object to move") if id: start = rs.GetPoint("Point to move from") if start: end = rs.GetPoint("Point to move to") if end: translation = end - start rs.MoveObject(id, translation) ``` ``` ```APIDOC ## RotateObject ### Description Rotates a single object. ### Method rs.RotateObject ### Parameters #### Path Parameters - **object_id** (guid) - Required - The identifier of the object to rotate. - **center_point** (point) - Required - The center of rotation. - **rotation_angle** (number) - Required - The angle of rotation in degrees. - **axis** (plane) - Optional - The axis of rotation. Defaults to the Z axis. - **copy** (bool) - Optional - Whether to copy the object. Defaults to False. ### Returns #### Success Response (guid) - **rotated_object_id** (guid) - Identifier of the rotated object. ### Request Example ```python import rhinoscriptsyntax as rs obj = rs.GetObject("Select object to rotate") if obj: point = rs.GetPoint("Center point of rotation") if point: rs.RotateObject(obj, point, 45.0, None, copy=True) ``` ``` ```APIDOC ## ScaleObject ### Description Scales a single object. ### Method rs.ScaleObject ### Parameters #### Path Parameters - **object_id** (guid) - Required - The identifier of the object. - **origin** (point) - Required - The origin of the scale transformation. - **scale** (list[number]) - Required - A list containing the X, Y, and Z axis scale factors. - **copy** (bool) - Optional - Whether to copy the object. Defaults to False. ### Returns #### Success Response (guid) - **scaled_object_id** (guid) - Identifier of the scaled object. ### Request Example ```python import rhinoscriptsyntax as rs obj = rs.GetObject("Select object to scale") if obj: origin = rs.GetPoint("Origin point") if origin: rs.ScaleObject(obj, origin, (1, 2, 3), True) ``` ``` -------------------------------- ### Parameter Description: List of Same Type Source: https://github.com/mcneel/rhinoscriptsyntax/blob/rhino-8.x/docstring.md Describes a parameter that accepts a list of values of the same type. The ellipsis (...) indicates an unlimited number of elements. ```python alias ([str, ...]): The name of an existing command alias. ``` -------------------------------- ### SelectObject Source: https://context7.com/mcneel/rhinoscriptsyntax/llms.txt Selects a single object in the Rhino document. ```APIDOC ## SelectObject ### Description Selects a single object in the Rhino document. ### Method SelectObject ### Parameters #### Path Parameters - **object_id** (guid) - Required - The identifier of the object to select ### Response #### Success Response (200) - **bool** (bool) - True on success ```