### Implement ExampleOverlay with start method Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Sketchup/Overlay.html Example of implementing a custom overlay that includes the start method, which is called when the overlay becomes active. ```ruby class ExampleOverlay < Sketchup::Overlay def initialize super('example_inc.my_overlay', 'Example Overlay') end def start puts "Overlay #{self} started" end end ``` -------------------------------- ### Sketchup::Overlay#start Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/method_list.html Starts an overlay. ```APIDOC ## Sketchup::Overlay#start ### Description Starts an overlay. ### Method POST ### Endpoint /sketchup/overlay/start ### Parameters None ### Response #### Success Response (200) - **status** (string) - Indicates if the overlay started successfully. ### Response Example ```json { "status": "started" } ``` ``` -------------------------------- ### Sketchup::ConstructionLine#start Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/method_list.html Gets the start point of a construction line. ```APIDOC ## Sketchup::ConstructionLine#start ### Description Gets the start point of a construction line. ### Method GET ### Endpoint /sketchup/constructionline/start ### Parameters None ### Response #### Success Response (200) - **start_point** (Point3d) - The start point of the construction line. ### Response Example ```json { "start_point": [10, 20, 30] } ``` ``` -------------------------------- ### Example Implementation Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Sketchup/SelectionObserver.html An example demonstrating how to implement and attach a custom selection observer. ```APIDOC ### Examples: ```ruby # This is an example of an observer that watches the selection for # changes. class MySelectionObserver < Sketchup::SelectionObserver def onSelectionBulkChange(selection) puts "onSelectionBulkChange: #{selection}" end end # Attach the observer. Sketchup.active_model.selection.add_observer(MySelectionObserver.new) ``` ``` -------------------------------- ### Create and Show an HtmlDialog with Built-in Callbacks Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/UI/HtmlDialog.html This example demonstrates how to create an HtmlDialog and set its HTML content, which includes buttons that trigger built-in SketchUp callbacks for opening the Extension Warehouse or installing an RBZ file. The dialog is then displayed to the user. ```Ruby html = <<-HTML HTML dlg = UI::HtmlDialog.new(dialog_title: 'EW Example') dlg.set_html(html) dlg.show ``` -------------------------------- ### Sketchup::MaterialsObserver - Example Usage Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Sketchup/MaterialsObserver.html Example of how to implement and use the Sketchup::MaterialsObserver. ```APIDOC ## Sketchup::MaterialsObserver - Example Usage ### Description This example demonstrates how to create a custom observer class that inherits from Sketchup::MaterialsObserver and how to attach it to the model's materials. ### Method Instance Method (Callback) ### Endpoint N/A ### Parameters None ### Request Example ```ruby class MyMaterialsObserver < Sketchup::MaterialsObserver def onMaterialAdd(materials, material) puts "onMaterialAdd: #{material}" end def onMaterialRemove(materials, material) puts "onMaterialRemove: #{material}" end end # Create an instance of the observer my_observer = MyMaterialsObserver.new # Add the observer to the active model's materials collection Sketchup.active_model.materials.add_observer(my_observer) # To remove the observer later: # Sketchup.active_model.materials.remove_observer(my_observer) ``` ### Response #### Success Response (200) N/A (This is an example of observer implementation, not an API endpoint response). #### Response Example N/A ``` -------------------------------- ### Sketchup::InstanceObserver - Example Usage Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Sketchup/InstanceObserver.html Example demonstrating how to implement and attach an InstanceObserver to a component instance. ```APIDOC ## Example Usage ### Description This example shows how to create a custom observer class that inherits from Sketchup::InstanceObserver and how to attach an instance of this observer to a component instance in the model. ### Code: ```ruby # This is an example of an observer that watches a specific instance # for open edit actions and shows a messagebox. class MyInstanceObserver < Sketchup::InstanceObserver def onOpen(instance) puts "onOpen: #{instance}" end def onClose(instance) puts "onClose: #{instance}" end end # Attach the observer. # (This example assumes that your first definition in the model # contains an instance to attach the observer to. This example should # work with a model where Sang or Bryce are present in the template.) model = Sketchup.active_model # Ensure there's at least one definition and one instance to attach to if model.definitions.length > 0 && model.definitions[0].instances.length > 0 model.definitions[0].instances[0].add_observer(MyInstanceObserver.new) else puts "No component instances found to attach observer to." end ``` ``` -------------------------------- ### Complete HtmlDialog Example with Callbacks Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/UI/HtmlDialog.html A comprehensive example demonstrating the creation of an HTML dialog, setting its content, centering it, and adding a Ruby callback that can be invoked from JavaScript, including an example with an `onCompleted` handler. ```HTML

Hello World

``` ```Ruby options = { :dialog_title => "Example Dialog", :preferences_key => "example.htmldialog", :style => UI::HtmlDialog::STYLE_DIALOG } dialog = UI::HtmlDialog.new(options) dialog.set_html(html) dialog.center dialog.add_action_callback("say") { |action_context, param1, param2| puts "JavaScript said #{param1} and #{param2}" } dialog.show # should be called directly after binding callbacks ``` -------------------------------- ### Set and Get Large Icon for UI::Command Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/UI/Command.html This example demonstrates how to set both small and large icons for a UI::Command and then retrieve the path for the large icon. It uses `File.join` and `__dir__` for platform-independent icon path construction. ```ruby toolbar = UI::Toolbar.new "Test" # This command displays Hello World on the screen when clicked cmd = UI::Command.new("Test") { UI.messagebox("Hello World") } # Use __dir__ to set the icon paths relative to the current file's directory # __dir__ returns the directory of the file where it is called # File.join is used to construct file paths in a platform-independent way cmd.small_icon = File.join(__dir__, "icons", "ToolPencilSmall.png") cmd.large_icon = File.join(__dir__, "icons", "ToolPencilLarge.png") toolbar = toolbar.add_item cmd toolbar.show puts cmd.large_icon ``` -------------------------------- ### Get SketchUp Product Family Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Sketchup/Model.html Retrieves an integer representing the product family of the installed SketchUp application. This example shows how to check if the running application is a licensed SketchUp Pro. ```Ruby model = Sketchup.active_model product_family = model.get_product_family if product_family == Sketchup::Model::ProLicensed then puts "You are running licensed SketchUp Pro!" end ``` -------------------------------- ### Implement ExampleOverlay for Initialization Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Sketchup/Overlay.html Basic implementation of a custom overlay, demonstrating the initialize method for setting up the overlay with an ID and name. ```ruby class ExampleOverlay < Sketchup::Overlay def initialize super('example_inc.my_overlay', 'Example Overlay') end end ``` -------------------------------- ### Sketchup::Edge#start - Get Start Vertex Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Sketchup/Edge.html Retrieves the Vertex object located at the start of the edge. ```APIDOC ## GET Sketchup::Edge#start ### Description Retrieves the Vertex object at the start of the edge. ### Method GET ### Endpoint `edge.start` ### Parameters None ### Request Example ```ruby edge = Sketchup.active_model.entities.add_line([0, 0, 0], [100, 100, 0]) vertex = edge.start ``` ### Response #### Success Response (200) - **Sketchup::Vertex** - A Vertex object representing the start of the edge. #### Response Example ```ruby # ``` ``` -------------------------------- ### Image Set Export Examples Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Layout/Document.html Examples demonstrating how to export image sets from a Layout document with various options. ```APIDOC ## POST /sketchup/ruby-api-docs/export ### Description Exports image sets from a Layout document with customizable options. ### Method POST ### Endpoint /sketchup/ruby-api-docs/export ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **file_path** (String) - Required - The file or image set to create. The directory path must already exist. The path must include the file extension. - **options** (Hash) - Optional - An optional hash of settings for the export. - **start_page** (Integer) - The first page to export. - **end_page** (Integer) - The last page to export. - **page_range** (String) - A string specifying the range of pages to export (e.g., "1,3-5"). Supported in LayOut 2024.0 and later. - **compress_images** (Boolean) - Whether to compress images in the document. Valid only for PDF exports. - **compress_quality** (Float) - The compression quality for JPEG images. Valid only for PDF exports. - **dpi** (Integer) - The resolution in dots per inch for the exported images. Valid only for image exports. ### Request Example ```json { "file_path": "c:/path/to/export.png", "options": { "start_page": 1, "end_page": 3, "dpi": 300 } } ``` ### Response #### Success Response (200) - **status** (String) - Indicates the success of the export operation. #### Response Example ```json { "status": "Export successful" } ``` ### Errors - **TypeError**: if an options value is the wrong type. - **RangeError**: if an options value is out of range. - **ArgumentError**: if the full file path does not exist or the specified file type is missing or not supported. ``` -------------------------------- ### Implement a Simple Animation Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Sketchup/Animation.html This example shows how to implement a custom animation class by defining the required `nextFrame` method and the optional `stop` callback. It demonstrates moving the camera upwards and includes menu items to start and stop the animation. ```Ruby class SimpleFloatAnimation def initialize @speed = 1.0 # Camera movement speed puts "Animation initialized" end # Required method - called for each animation frame def nextFrame(view) # Move camera upward new_eye = view.camera.eye new_eye.z = new_eye.z + @speed view.camera.set(new_eye, view.camera.target, view.camera.up) view.show_frame # Continue animation until reaching maximum height return new_eye.z < 500.0 end # Optional callback - called by SketchUp when animation is stopped # Note: This method is called automatically by SketchUp and cannot # be called directly to stop an animation def stop puts "Animation was stopped by SketchUp" # Cleanup code when animation ends end end # Add menu item to start the animation UI.menu("Camera").add_item("Start Animation") { animation = SimpleFloatAnimation.new Sketchup.active_model.active_view.animation = animation } # To stop the animation programmatically: UI.menu("Camera").add_item("Stop Animation") { # Setting animation to nil will trigger the stop method in our animation class Sketchup.active_model.active_view.animation = nil } ``` -------------------------------- ### Create and Show a Toolbar with a Command Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/UI/Toolbar.html This example demonstrates how to create a new toolbar, define a command with a message box, assign icons and tooltips, add the command to the toolbar, and finally display the toolbar. Ensure you have the necessary icon files ('ToolPencilSmall.png', 'ToolPencilLarge.png') in the SketchUp plugins folder or a path SketchUp can access. ```ruby toolbar = UI::Toolbar.new "Test" # This toolbar icon simply displays Hello World on the screen cmd = UI::Command.new("Test") { UI.messagebox "Hello World" } cmd.small_icon = "ToolPencilSmall.png" cmd.large_icon = "ToolPencilLarge.png" cmd.tooltip = "Test Toolbars" cmd.status_bar_text = "Testing the toolbars class" cmd.menu_text = "Test" toolbar = toolbar.add_item cmd toolbar.show ``` -------------------------------- ### Sketchup::DimensionLinear#start Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/method_list.html Gets the start point of a linear dimension. ```APIDOC ## Sketchup::DimensionLinear#start ### Description Gets the start point of a linear dimension. ### Method GET ### Endpoint /sketchup/dimensionlinear/start ### Parameters None ### Response #### Success Response (200) - **start_point** (Point3d) - The start point of the dimension. ### Response Example ```json { "start_point": [10, 20, 30] } ``` ``` -------------------------------- ### Get Start Vertex of Edge Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Sketchup/Edge.html Retrieves the Vertex object at the start of the edge. ```ruby edge = Sketchup.active_model.entities.add_line([0, 0, 0], [100, 100, 0]) vertex = edge.start ``` -------------------------------- ### start Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Sketchup/Overlay.html Abstract method to be implemented by subclasses to react when the overlay becomes active. ```APIDOC ## start ### Description This method is abstract and can be implemented by subclasses to define actions that occur when the overlay becomes active (e.g., when the user enables it). ### Method `start` ### Parameters None ### Request Example ```ruby class ExampleOverlay < Sketchup::Overlay def initialize super('example_inc.my_overlay', 'Example Overlay') end def start puts "Overlay #{self} started" end end ``` ### Response #### Success Response (200) This method does not return a value; its purpose is to execute side effects. #### Response Example None ``` -------------------------------- ### Get Construction Line Start Point Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Sketchup/ConstructionLine.html Retrieves the starting point of a construction line. Returns nil if the line is infinite at the start. ```ruby model = Sketchup.active_model entities = model.active_entities point1 = Geom::Point3d.new(0,0,0) point2 = Geom::Point3d.new(20,20,20) constline = entities.add_cline(point1, point2) startofline = constline.start ``` -------------------------------- ### Sketchup::InstancePath#initialize Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/method_list.html Initializes a new Sketchup::InstancePath object. ```APIDOC ## Sketchup::InstancePath#initialize ### Description Initializes a new Sketchup::InstancePath object. ### Method initialize ### Parameters (No parameters specified in source) ### Request Example (No request example specified in source) ### Response #### Success Response (200) (No response details specified in source) #### Response Example (No response example specified in source) ``` -------------------------------- ### Sketchup::ComponentInstance#guid Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/method_list.html Gets the globally unique identifier (GUID) of a SketchUp component instance. ```APIDOC ## Sketchup::ComponentInstance#guid ### Description Gets the globally unique identifier (GUID) of a SketchUp component instance. ### Method Instance Method ### Parameters None ### Response - **guid** (String) - The GUID of the component instance. ``` -------------------------------- ### Create and Configure a SketchUpModel Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Layout/SketchUpModel.html Demonstrates how to create a new SketchUpModel instance, set its bounds, current scene, view, and render mode. It also shows how to trigger a render if needed. ```ruby bounds = Geom::Bounds2d.new(1, 1, 3, 3) model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds) model.current_scene = 2 model.view = Layout::SketchUpModel::FRONT_VIEW model.render_mode = Layout::SketchUpModel::VECTOR_RENDER model.render if model.render_needed? ``` -------------------------------- ### Get Start Extent Point Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Layout/LinearDimension.html Retrieves the paper space location for the start of the dimension line. ```ruby start_point = Geom::Point2d.new(1, 1) end_point = Geom::Point2d.new(5, 5) height = 1.0 dim = Layout::LinearDimension.new(start_point, end_point, height) start_ext_point = dim.start_extent_point ``` -------------------------------- ### Example Usage: Creating and Adding an Overlay Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Sketchup/Overlay.html Demonstrates how to create a custom overlay and add it to a SketchUp model using an application observer. ```APIDOC ## Example: Custom Overlay ### Description This example shows how to define a custom overlay class and register it with SketchUp using an `AppObserver` to ensure it's available when models are opened or created. ### Code Example ```ruby class ExampleOverlay < Sketchup::Overlay def initialize super('example_inc.my_overlay', 'Example Overlay') end def draw(view) rectangle = [ [100, 100, 0], [300, 100, 0], [300, 200, 0], [100, 200, 0] ] view.drawing_color = 'blue' view.draw2d(GL_QUADS, rectangle) point = Geom::Point3d.new(120, 120, 0) view.draw_text(point, "Hello Overlay", size: 20, bold: true, color: 'white') end end # Using an observer to create a new overlay per model. class ExampleAppObserver < Sketchup::AppObserver def expectsStartupModelNotifications true end def register_overlay(model) overlay = ExampleOverlay.new model.overlays.add(overlay) end alias_method :onNewModel, :register_overlay alias_method :onOpenModel, :register_overlay end observer = ExampleAppObserver.new Sketchup.add_observer(observer) # The following line is needed if you copy+paste in the Ruby Console or # at the moment the extension is installed: observer.register_overlay(Sketchup.active_model) ``` ### Version * SketchUp 2023.0 ``` -------------------------------- ### Get Model GUID Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Sketchup/Model.html Retrieves the globally unique identifier (GUID) for the SketchUp model. This GUID is stored with the file and changes upon modification and saving. ```Ruby model = Sketchup.active_model guid = model.guid ``` -------------------------------- ### Sketchup::Overlay#initialize Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/method_list.html Initializes a new Sketchup::Overlay object. ```APIDOC ## Sketchup::Overlay#initialize ### Description Initializes a new Sketchup::Overlay object. ### Method initialize ### Parameters (No parameters specified in source) ### Request Example (No request example specified in source) ### Response #### Success Response (200) (No response details specified in source) #### Response Example (No response example specified in source) ``` -------------------------------- ### Get Component Definition GUID Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Sketchup/ComponentDefinition.html Retrieves the unique identifier (GUID) of a component definition. Note that the GUID can change after modifications and exiting component edit mode. ```ruby componentdefinition = Sketchup.active_model.definitions[0] guid = componentdefinition.guid ``` -------------------------------- ### Check if Extension Loads on Startup Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/SketchupExtension.html The `load_on_start?` method returns `true` if the extension is configured to load automatically when SketchUp starts, and `false` otherwise. ```ruby ext = SketchupExtension.new('Stair Tools', 'StairTools/core') puts "load_on_start? is false: #{ext.load_on_start?.to_s}" Sketchup.register_extension(ext, true) puts "load_on_start? is now true: #{ext.load_on_start?.to_s}" ``` -------------------------------- ### Get Start Arrow of Layout::Path Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Layout/Path.html Retrieve the Layout::Path object representing the start arrow, if one is defined. Returns nil if no start arrow is present. ```ruby start_arrow = path.start_arrow ``` -------------------------------- ### Get Start Vertex Normal Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Sketchup/EdgeUse.html Retrieves the vertex normal for the starting point of the edge use. This is useful for geometric calculations and analysis. ```ruby entities = Sketchup.active_model.active_entities points = [] points << Geom::Point3d.new(0, 0, 0) points << Geom::Point3d.new(100, 0, 0) points << Geom::Point3d.new(100, 200, 0) points << Geom::Point3d.new(0, 200, 0) face = entities.add_face(points) loop = face.outer_loop edgeuses = loop.edgeuses edgeuse = edgeuses[0] vector3d = edgeuse.start_vertex_normal ``` -------------------------------- ### Create Grid Geometry with Optimized Point Creation Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/file.generating_geometry.html This example demonstrates creating a grid of faces in Sketchup. It includes an optimization strategy for scenarios with very high amounts of geometry by pre-creating and reusing unique 3D points. Benchmark and profile before implementing this optimization. ```Ruby module Example # @example # Example.create_grid(6, 8) # # @param [Integer] rows # @param [Integer] columns def self.create_grid(rows = 5, columns = 5) model = Sketchup.active_model model.start_operation('Grid', true) # In scenarios with very high amount of geometry it might be a slight gain # by creating all the unique 3D points in a pool up front and reusing them # when creating the faces. Benchmark and profile before you go to this # extent. row_points = rows + 1 col_points = columns + 1 points = [] row_points.times { |x| col_points.times { |y| points << Geom::Point3d.new(x * 10, y * 10, 0) } } model.active_entities.build { |builder| (0...rows).each { |x| (0...columns).each { |y| i1 = (col_points * y) + x i2 = i1 + 1 i3 = i2 + col_points i4 = i3 - 1 polygon = [i1, i2, i3, i4].map { |i| points[i] } builder.add_face(polygon) } } } model.commit_operation end end ``` -------------------------------- ### Sketchup::Camera#initialize Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/method_list.html Initializes a new Sketchup::Camera object. ```APIDOC ## Sketchup::Camera#initialize ### Description Initializes a new Sketchup::Camera object. ### Method initialize ### Parameters (No parameters specified in source) ### Request Example (No request example specified in source) ### Response #### Success Response (200) (No response details specified in source) #### Response Example (No response example specified in source) ``` -------------------------------- ### Get the Unique GUID of a Group in SketchUp Ruby API Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Sketchup/Group.html Retrieve the globally unique identifier (GUID) for a SketchUp group using the guid method. This returns a 22-character base64 encoded string. ```ruby group = Sketchup.active_model.entities.add_group group.entities.add_line([0,0,0],[100,100,100]) guid = group.guid ``` -------------------------------- ### Example Text File Importer Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Sketchup/Importer.html This Ruby script demonstrates a complete example of importing a .txt file and displaying its contents in a messagebox. It serves as a basic template for creating custom importers. ```ruby # Example of a complete script that imports a .txt file and displays its contents in a messagebox. ``` -------------------------------- ### Get Start Arrow Type - Layout::Style Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Layout/Style.html Retrieves the current start arrow type for a style. Returns nil if no value is set. ```ruby doc = Layout::Document.open("C:/path/to/document.layout") page = doc.pages.first entity = page.entities.first style = entity.style arrow_type = style.start_arrow_type ``` -------------------------------- ### Sketchup::Overlay Initialization Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Sketchup/Overlay.html Demonstrates how to initialize a new Sketchup::Overlay subclass with its ID, name, and an optional description. ```APIDOC ## Sketchup::Overlay#initialize ### Description Initializes a new overlay. ### Parameters #### Path Parameters - **id** (String) - Required - The string should be unique per overlay subclass. A good pattern would be something like: “company_name.extension_name.overlay_name”. - **name** (String) - Required - This is a user facing display name that will appear in the UI. Make it short and representative for what the overlay does. - **description** (String) - Optional (defaults to: "") - This is a user facing description that will appear in the UI. Make it short and representative for what the overlay does. ### Raises - (ArgumentError) - if `id` or `name` is an empty string ### Version - SketchUp 2023.0 ### Request Example ```ruby class ExampleOverlay < Sketchup::Overlay def initialize description = "A short sentence describing the overlay." super('example_inc.my_overlay', 'Example Overlay', description: description) end end overlay = ExampleOverlay.new ``` ``` -------------------------------- ### Get Start Point of Layout::Path Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Layout/Path.html Retrieve the starting Geom::Point2d of the Layout::Path. This is the first vertex in the path's sequence. ```ruby start_point = Geom::Point2d.new(1, 1) end_point = Geom::Point2d.new(2, 2) path = Layout::Path.new(start_point, end_point) # should be equal to start_point start = path.start_point ``` -------------------------------- ### UI::WebDialog#initialize Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/method_list.html Initializes a new UI::WebDialog object. ```APIDOC ## UI::WebDialog#initialize ### Description Initializes a new UI::WebDialog object. ### Method initialize ### Parameters (No parameters specified in source) ### Request Example (No request example specified in source) ### Response #### Success Response (200) (No response details specified in source) #### Response Example (No response example specified in source) ``` -------------------------------- ### Get Start Offset Point of Angular Dimension Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Layout/AngularDimension.html Retrieves the paper space location for the start of the first extension line. This point defines the beginning of the line segment that runs to the start extent point. ```ruby start_point = Geom::Point2d.new(1, 1) end_point = Geom::Point2d.new(5, 5) start_extent = Geom::Point2d.new(1, 2) end_extent = Geom::Point2d.new(5, 6) inner_angle = true dim = Layout::AngularDimension.new(start_point, end_point, start_extent, end_extent, inner_angle) start_offset = dim.start_offset_point ``` -------------------------------- ### Get Attached Start Point Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Sketchup/DimensionLinear.html Retrieve the attached start point of a dimension, which includes the InstancePath and a Point3d. This is useful for dimensions attached to component instances. ```Ruby # Assuming you have a valid dimension selected that is attached to a # component instance dim = Sketchup.active_model.selection[0] dim.start_attached_to ``` -------------------------------- ### Sketchup::ImageRep#initialize Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/method_list.html Initializes a new Sketchup::ImageRep object. ```APIDOC ## Sketchup::ImageRep#initialize ### Description Initializes a new Sketchup::ImageRep object. ### Method initialize ### Parameters (No parameters specified in source) ### Request Example (No request example specified in source) ### Response #### Success Response (200) (No response details specified in source) #### Response Example (No response example specified in source) ``` -------------------------------- ### Get Start Offset Point Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Layout/LinearDimension.html Retrieves the paper space location for the start of the first extension line. This point is used to draw the extension line. ```ruby start_point = Geom::Point2d.new(1, 1) end_point = Geom::Point2d.new(5, 5) height = 1.0 dim = Layout::LinearDimension.new(start_point, end_point, height) start_offset = dim.start_offset_point ``` -------------------------------- ### Get Start Extent Point Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Layout/AngularDimension.html Returns the paper space coordinates for the start of the dimension line. This is part of the definition of the angular dimension's extent. ```ruby start_ext_point = dim.start_extent_point ``` -------------------------------- ### Layout::Style#start_arrow_type Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/method_list.html Gets the start arrow type for a style. ```APIDOC ## Layout::Style#start_arrow_type ### Description Gets the start arrow type for a style. ### Method GET ### Endpoint /layout/style/start_arrow_type ### Parameters None ### Response #### Success Response (200) - **start_arrow_type** (string) - The type of the start arrow (e.g., 'arrow', 'dot'). ### Response Example ```json { "start_arrow_type": "arrow" } ``` ``` -------------------------------- ### ExampleTool - Mouse and Drawing Events Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Sketchup/Tool.html Demonstrates how to create a custom tool in SketchUp that responds to mouse events (like scrolling) and draws custom graphics on the view. ```APIDOC ## ExampleTool Class ### Description This class provides an example of a custom SketchUp tool that handles mouse events and draws custom elements. ### Methods #### `initialize` Initializes the tool's properties, including a rectangle and a property value. #### `onMouseMove(flags, x, y, view)` Called when the mouse moves. Invalidates the view to trigger a redraw. #### `onMouseWheel(flags, delta, x, y, view)` Handles mouse wheel events. If the cursor is within a defined rectangle, it updates a property value and prevents default zoom behavior. Otherwise, it returns `false` to allow default zoom. Parameters: - `flags` (Integer) - A bit mask for modifier keys and mouse buttons. - `delta` (Integer) - `1` or `-1` indicating scroll direction. - `x` (Integer/Float) - Screen coordinate (physical/logical pixels). - `y` (Integer/Float) - Screen coordinate (physical/logical pixels). - `view` ([Sketchup::View](View.html "Sketchup::View (class)")) - The current view object. Returns: - (Boolean) - `true` to prevent default zoom, `false` otherwise. Version: - SketchUp 2019.2 and later #### `draw(view)` Draws custom graphics on the view, including a rectangle, text, and lines. ### Request Example ```ruby Sketchup.active_model.select_tool(ExampleTool.new) ``` ``` -------------------------------- ### Layout::Style#start_arrow_size Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/method_list.html Gets the start arrow size for a style. ```APIDOC ## Layout::Style#start_arrow_size ### Description Gets the start arrow size for a style. ### Method GET ### Endpoint /layout/style/start_arrow_size ### Parameters None ### Response #### Success Response (200) - **start_arrow_size** (Float) - The size of the start arrow. ### Response Example ```json { "start_arrow_size": 10.5 } ``` ``` -------------------------------- ### Sketchup::InputPoint#initialize Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/method_list.html Initializes a new Sketchup::InputPoint object. ```APIDOC ## Sketchup::InputPoint#initialize ### Description Initializes a new Sketchup::InputPoint object. ### Method initialize ### Parameters (No parameters specified in source) ### Request Example (No request example specified in source) ### Response #### Success Response (200) (No response details specified in source) #### Response Example (No response example specified in source) ``` -------------------------------- ### Layout::Path#start_arrow Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/method_list.html Gets the start arrow setting for a path. ```APIDOC ## Layout::Path#start_arrow ### Description Gets the start arrow setting for a path. ### Method GET ### Endpoint /layout/path/start_arrow ### Parameters None ### Response #### Success Response (200) - **start_arrow** (boolean) - True if a start arrow is enabled, false otherwise. ### Response Example ```json { "start_arrow": true } ``` ``` -------------------------------- ### Sketchup::ImageRep Initialization Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Sketchup/ImageRep.html Demonstrates how to initialize a Sketchup::ImageRep object, either with default settings or by loading an image from a file path. ```APIDOC ## Sketchup::ImageRep Initialization ### Description Creates a new image object. The image object will have no data if a path to the image is not provided. ### Method `initialize` ### Endpoint N/A (Instance Method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```ruby # Default constructor image_rep = Sketchup::ImageRep.new # Use #set_data or #load_file to add image data. # Construct from file image_rep = Sketchup::ImageRep.new("/path/to/image.jpg") ``` ### Response #### Success Response (200) N/A (Constructor) #### Response Example N/A ``` -------------------------------- ### Sketchup::ArcCurve#start_angle Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/method_list.html Gets the start angle of an arc curve. ```APIDOC ## Sketchup::ArcCurve#start_angle ### Description Gets the start angle of an arc curve. ### Method GET ### Endpoint /sketchup/arccurve/start_angle ### Parameters None ### Response #### Success Response (200) - **start_angle** (Angle) - The start angle of the arc in radians. ### Response Example ```json { "start_angle": 0.785 } ``` ``` -------------------------------- ### Initialize Tool State with activate Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Sketchup/Tool.html Called when the tool is selected. Use this for initializing instance variables and tool state. ```Ruby def activate puts 'Your tool has been activated.' end ``` -------------------------------- ### Get a Specific Rendering Option Value Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Sketchup/RenderingOptions.html Use the `[]` method with a key string to retrieve the value of a specific rendering option. For example, to get the value of 'DisplayInstanceAxes'. ```ruby result = Sketchup.active_model.rendering_options["DisplayInstanceAxes"] ``` -------------------------------- ### Layout::SketchUpModel#initialize Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/method_list.html Initializes a new Layout::SketchUpModel object. ```APIDOC ## Layout::SketchUpModel#initialize ### Description Initializes a new Layout::SketchUpModel object. ### Method initialize ### Parameters (No parameters specified in source) ### Request Example (No request example specified in source) ### Response #### Success Response (200) (No response details specified in source) #### Response Example (No response example specified in source) ``` -------------------------------- ### Get Extension Keys from Sketchup Manager Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Sketchup/ExtensionsManager.html The `keys` method returns an array of strings, where each string is the name of an installed extension. This is equivalent to getting the names of all extensions. ```ruby manager = Sketchup.extensions keys = manager.keys ``` -------------------------------- ### Layout::LinearDimension#start_extent_point Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/method_list.html Gets the start extent point of a linear dimension. ```APIDOC ## Layout::LinearDimension#start_extent_point ### Description Gets the start extent point of a linear dimension. ### Method GET ### Endpoint /layout/lineardimension/start_extent_point ### Parameters None ### Response #### Success Response (200) - **extent_point** (Point) - The start extent point. ### Response Example ```json { "extent_point": [100, 200] } ``` ``` -------------------------------- ### initialize Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/UI/HtmlDialog.html Creates a new HTML dialog instance. ```APIDOC ## initialize ### Description Creates a new HtmlDialog. ### Method `initialize(properties)` ### Parameters * **properties** (Hash) - A hash of properties to configure the dialog. ### Returns `UI::HtmlDialog` - A new instance of HtmlDialog. ``` -------------------------------- ### Layout::AngularDimension#start_extent_point Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/method_list.html Gets the start extent point of an angular dimension. ```APIDOC ## Layout::AngularDimension#start_extent_point ### Description Gets the start extent point of an angular dimension. ### Method GET ### Endpoint /layout/angulardimension/start_extent_point ### Parameters None ### Response #### Success Response (200) - **extent_point** (Point) - The start extent point. ### Response Example ```json { "extent_point": [100, 200] } ``` ``` -------------------------------- ### SketchupExtension#load_on_start? Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/SketchupExtension.html Checks if the extension is configured to load automatically when SketchUp starts. ```APIDOC ## SketchupExtension#load_on_start? ### Description Checks if the extension is configured to load automatically when SketchUp starts. ### Method GET ### Endpoint SketchupExtension#load_on_start? ### Returns * (Boolean) ### Version * SketchUp 8.0 M2 ``` -------------------------------- ### Layout::LinearDimension#start_connection_point Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/method_list.html Gets the start connection point of a linear dimension. ```APIDOC ## Layout::LinearDimension#start_connection_point ### Description Gets the start connection point of a linear dimension. ### Method GET ### Endpoint /layout/lineardimension/start_connection_point ### Parameters None ### Response #### Success Response (200) - **connection_point** (Point) - The start connection point. ### Response Example ```json { "connection_point": [100, 200] } ``` ``` -------------------------------- ### UI::Command#initialize Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/method_list.html Initializes a new UI::Command object. ```APIDOC ## UI::Command#initialize ### Description Initializes a new UI::Command object. ### Method initialize ### Parameters (No parameters specified in source) ### Request Example (No request example specified in source) ### Response #### Success Response (200) (No response details specified in source) #### Response Example (No response example specified in source) ``` -------------------------------- ### Sketchup::Camera Initialization Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Sketchup/Camera.html Provides details on how to initialize a new Sketchup::Camera object, including its constructor overloads and parameters. ```APIDOC ## Sketchup::Camera#initialize ### Description Returns a new camera with eye (where the camera is) and targets (where the camera is looking). ### Method initialize ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "example": "camera = Sketchup::Camera.new" } ``` ### Response #### Success Response (200) - **Sketchup::Camera** - A new camera object. #### Response Example ```json { "example": "camera = Sketchup::Camera.new(eye, target, up)" } ``` ### Overloads #### #initialize ⇒ Sketchup::Camera #### #initialize(eye, target, up, perspective = true, fov = 30.0) ⇒ Sketchup::Camera **Parameters:** * **eye** (Geom::Point3d) - The position of the camera. * **target** (Geom::Point3d) - The point the camera is looking at. * **up** (Geom::Point3d) - The up vector for the camera. * **perspective** (Boolean) - Whether the camera is in perspective mode (defaults to true). * **fov** (Float) - The field of view for the camera (defaults to 30.0). **Version:** * SketchUp 6.0 ``` -------------------------------- ### Get Start Index of AutoTextDefinition Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Layout/AutoTextDefinition.html Retrieves the start index for AutoTextDefinitions of type `TYPE_PAGE_NUMBER`, `TYPE_PAGE_COUNT`, or `TYPE_SEQUENCE`. Raises an ArgumentError if the definition type is not one of these supported types. ```ruby doc = Layout::Document.open("C:/path/to/document.layout") sequence_def = doc.auto_text_definitions.add("Seq1", Layout::AutoTextDefinition::TYPE_SEQUENCE) start_index = sequence_def.start_index ``` -------------------------------- ### Get Arc Start Angle Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Sketchup/ArcCurve.html Retrieves the start angle of the arc in radians, measured from the X axis of the curve's coordinate system. Useful for defining segments of circles. ```ruby # Create a 1/4 circle, radius of 5, normal to the Z axis center = Geom::Point3d.new 0, 0, -1 normal = Geom::Vector3d.new 0,0,1 xaxis = Geom::Vector3d.new 1,0,0 start_a = Math::PI/2 end_a = Math::PI model = Sketchup.active_model entities = model.entities edgearray = entities.add_arc center, xaxis, normal, 5, start_a, end_a edge = edgearray[0] arccurve = edge.curve start_angle = arccurve.start_angle ``` -------------------------------- ### Layout::Path#initialize Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/method_list.html Initializes a new Layout::Path object. ```APIDOC ## Layout::Path#initialize ### Description Initializes a new Layout::Path object. ### Method initialize ### Parameters (No parameters specified in source) ### Request Example (No request example specified in source) ### Response #### Success Response (200) (No response details specified in source) #### Response Example (No response example specified in source) ``` -------------------------------- ### Sketchup::DimensionLinear#start_attached_to Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/method_list.html Gets the entity the start point of a linear dimension is attached to. ```APIDOC ## Sketchup::DimensionLinear#start_attached_to ### Description Gets the entity the start point of a linear dimension is attached to. ### Method GET ### Endpoint /sketchup/dimensionlinear/start_attached_to ### Parameters None ### Response #### Success Response (200) - **attached_entity** (Entity) - The entity the start point is attached to, or nil if not attached. ### Response Example ```json { "attached_entity": "entity_id" } ``` ``` -------------------------------- ### SketchupExtension#load_on_start? Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/SketchupExtension.html Returns whether the extension is set to load when SketchUp starts up. ```APIDOC ## SketchupExtension#load_on_start? ### Description Returns whether the extension is set to load when SketchUp starts up. ### Method Instance Method ### Returns - Boolean ``` -------------------------------- ### Get Start Point and Entity of DimensionLinear Source: https://github.com/sketchup/ruby-api-docs/blob/gh-pages/Sketchup/DimensionLinear.html Retrieves the start point and the optional entity that the DimensionLinear object is referencing. The result is an array where the first element is the entity (or nil) and the second is the Point3d. ```Ruby arr = dim.start if arr[0].nil? puts "No attached entity. Point is #{arr[1]}" else puts "Attached entity: #{arr[0]}, at point #{arr[1]}" end ```