ModraUp Ruby API Documentation Ruby API Reference

Module: ModraUp

Overview

Application entry points for accessing the active model, reading version information, registering extensions, opening files, and formatting units. This namespace follows the SketchUp Ruby API naming conventions.

Note: ModraUp and Sketchup reference the same module. Ruby class names retain the Sketchup prefix.

Examples:

model = ModraUp.active_model
model.entities.add_face([0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0])

Defined Under Namespace

Classes: AppObserver, ArcCurve, AttributeDictionaries, AttributeDictionary, Axes, Behavior, Camera, Color, ComponentDefinition, ComponentInstance, Console, ConstructionLine, ConstructionPoint, Curve, DefinitionList, DefinitionObserver, DefinitionsObserver, Dimension, DimensionLinear, DimensionObserver, Drawingelement, Edge, EdgeUse, Entities, EntitiesObserver, Entity, EntityObserver, EnvironmentsObserver, ExtensionsManager, Face, FrameChangeObserver, Group, HatchPattern, HatchPatternData, HatchPatterns, Http, Image, ImageRep, Importer, InputPoint, InstanceObserver, InstancePath, Layer, LayerFolder, Layers, LayersObserver, Licensing, LineStyle, LineStyles, LoadHandler, LocalExtensionManager, Loop, Material, Materials, MaterialsObserver, Menu, Model, ModelObserver, OptionsManager, OptionsProvider, OptionsProviderObserver, Overlay, OverlaysManager, Page, Pages, PagesObserver, PickHelper, Procedure, RegionalSettings, RenderingOptions, RenderingOptionsObserver, SectionPlane, Selection, SelectionObserver, ShadowInfo, ShadowInfoObserver, Skp, Text, Texture, TextureWriter, Tool, Tools, ToolsObserver, UVHelper, Vertex, View, ViewObserver

Constants # collapse

ModraUp::PROCEDURE_ID_FOLLOW_ME

The native process Follow Me's id (in the string form of ComponentDefinition#attach_procedure).

ModraUp::PROCEDURE_ID_SOLID_TOOLS

The native procedure ID for solid tools (union, difference, intersection).

ModraUp::PROCEDURE_ID_COPY_ALONG

The native process ID for "Copy Along" in Ruby SketchUp.

ModraUp::SnapTo_Arbitrary

SnapTo_Arbitrary = 0

Snap to any face.

Returns:

  • (Integer)
ModraUp::SnapTo_Horizontal

SnapTo_Horizontal = 1

Snap to horizontal plane.

Returns:

  • (Integer)
ModraUp::SnapTo_Vertical

SnapTo_Vertical = 2

Snap to vertical plane.

Returns:

  • (Integer)
ModraUp::SnapTo_Sloped

SnapTo_Sloped = 3

Snap to the nearest point on a sloped surface.

Returns:

  • (Integer)
ModraUp::VERSION

The application version string.

Returns:

  • (String)
Note: ModraUp extension.

Examples:

ModraUp::VERSION  #=> "0.8.0"

Class Method Summary # collapse

Class Method Details

ModraUp.register_procedure(procedure) ⇒ Boolean

Register a procedure in the current session. Registering the same instance or the same ID again returns false. Only the procedure's ID and parameters are stored in the model. When the file is opened, the procedure must be registered; otherwise, get_procedure_parameters returns an empty value and run_procedures does not run, preserving any existing output geometry.

Parameters:

  • procedure (ModraUp::Procedure)

Returns:

  • (Boolean)

Raises:

  • [TypeError] is not a ModraUp::Procedure

Examples:

ModraUp.register_procedure(MyModule::Fence.new)

ModraUp.active_model ⇒ ModraUp::Model

The currently open model (the host contains only this instance).

Returns:

  • (ModraUp::Model)

Examples:

ModraUp.active_model.entities

ModraUp.version ⇒ String

Declared SketchUp compatible version string (currently fixed to "24.0.0").

Returns:

  • (String)

Examples:

ModraUp.version  #=> "24.0.0"

ModraUp.version_number ⇒ Integer

Version number (current +2400000000).

Returns:

  • (Integer)

Examples:

ModraUp.version_number  #=> 2400000000

ModraUp.app_name ⇒ String

Application Name, currently set to `ModraUp`.

Returns:

  • (String)

Examples:

ModraUp.app_name  #=> "ModraUp"

ModraUp.platform ⇒ Symbol

Current operating system. macOS is denoted as :platform_osx, and Windows as :platform_win.

Returns:

  • (Symbol)

Examples:

IS_OSX = ModraUp.platform == :platform_osx

ModraUp.register_extension(extension, load_at_start) ⇒ extension

Register the SketchupExtension. When load_at_start is true, its load path (specified by the second parameter @path of SketchupExtension.new) is immediately +require"d.

Parameters:

  • extension (SketchupExtension)
  • load_at_start (Boolean)

Returns:

  • (SketchupExtension)

Examples:

ext = SketchupExtension.new("Demo", File.join(__dir__, "main.rb"))
ModraUp.register_extension(ext, true)

ModraUp.require(path) ⇒ Boolean

Loads Ruby files, supporting both .rbe (RBS2.0) and old .rbs (RBS1.0) formats. Returns false if the file is not found or a LoadError occurs; the old error strategy of the host application is maintained.

Parameters:

  • path (String)

Returns:

  • (Boolean)

Examples:

ModraUp.require "su_dynamiccomponents/ruby/dcloader"

ModraUp.load(path) ⇒ Boolean

Load Ruby files. Currently, behaves the same as ModraUp.require: the file will not be executed more than once; and it returns false if the file is not found.

Parameters:

  • path (String)

Returns:

  • (Boolean)
Note: Supports .rbe (RBS2.0) and the older .rbs (RBS1.0).

Examples:

ModraUp.load "application_loader"

ModraUp.is_pro? ⇒ Boolean

Is Pro functionality enabled. Currently always true; otherwise, the DC Manager/Report functions will be disabled.

Returns:

  • (Boolean)
Note: ModraUp extension. No SketchUp authorization detection.

Examples:

ModraUp.is_pro?

ModraUp.is_online ⇒ Boolean

Do you consider there to be an online connection? Currently, it is always set to false, with DC reports using local HTML.

Returns:

  • (Boolean)
Note: ModraUp extension. Does not perform true connectivity checking.

Examples:

ModraUp.is_online  #=> false

ModraUp.get_datfile_info(key, default = nil) ⇒ Object

Read keys from the SketchUp installation dat file. Return the default value if no dat file is found.

Parameters:

  • key (String)
  • default (Object)

Returns:

  • (Object)
Note: ModraUp extension. Does not parse Trimble dat.

Examples:

ModraUp.get_datfile_info("DC_HELP", "http://example.com")

ModraUp.get_i18n_datfile_info(key, default = nil) ⇒ Object

Read the interface language dat file. Like ModraUp.get_datfile_info, it returns default when no table is found.

Parameters:

  • key (String)
  • default (Object)

Returns:

  • (Object)
Note: ModraUp extension. Does not parse Trimble language dat.

Examples:

ModraUp.get_i18n_datfile_info("HelpMenu", "Help")

ModraUp.temp_dir ⇒ String

Temporary directory (system temporary path).

Returns:

  • (String)

Examples:

ModraUp.temp_dir

ModraUp.get_locale ⇒ String

The current application language; uses the system language if no fixed language is set, following SketchUp style tags such as "zh-CN", "en-US". LanguageHandler extends the Resources subdirectory using this name.

Returns:

  • (String)

Examples:

ModraUp.get_locale  # e.g. "zh-CN"

ModraUp.os_language ⇒ String

System preferred language, unaffected by the application language setting.

Returns:

  • (String)

Examples:

ModraUp.os_language  # e.g. "zh-CN"

ModraUp.is_64bit? ⇒ Boolean

Is the process 64-bit.

Returns:

  • (Boolean)

Examples:

ModraUp.is_64bit?  #=> true

ModraUp.mdi? ⇒ Boolean

Is the multi-document interface. This host is single-document and always returns false.

Returns:

  • (Boolean)
Note: ModraUp extension. No Mac multi-window support.

Examples:

ModraUp.mdi?  #=> false

ModraUp.debug_mode? ⇒ Boolean

Outputs API misuse warnings to the console. Currently, only the switch is saved; individual messages are not printed yet.

Returns:

  • (Boolean)

Examples:

ModraUp.debug_mode?

ModraUp.debug_mode = enabled ⇒ Boolean

Sets the value reported by ModraUp.debug_mode?.

Parameters:

  • enabled (Boolean)

Returns:

  • (Boolean)

Examples:

ModraUp.debug_mode = true

ModraUp.plugins_disabled? ⇒ Boolean

Does the plugin skip the Plugins directory's .rb files on startup? This setting is defined in the ModraUp.write_default preference file and will take effect on the next startup.

Returns:

  • (Boolean)

Examples:

ModraUp.plugins_disabled?

ModraUp.plugins_disabled = enabled ⇒ Boolean

Sets the flag returned by ModraUp.plugins_disabled?. Pass true to disable the plugins directory.

Parameters:

  • enabled (Boolean)

Returns:

  • (Boolean)

Examples:

ModraUp.plugins_disabled = false

ModraUp.is_valid_filename?(filename) ⇒ Boolean

Does the filename contain no path separators or Windows illegal characters.

Parameters:

  • filename (String)

Returns:

  • (Boolean)

Examples:

ModraUp.is_valid_filename?("box.skp")  #=> true

ModraUp.get_shortcuts ⇒ Array<String>

Returns all shortcuts configured by the host, including user rebindings, multiple bindings for the same command, and plugin commands.

Each item is a key, tab, and command identifier (e.g., selectLineTool:); if no command identifier is present, the registered menu path is used.

Keys are represented in Qt PortableText format, preserving distinctions between modifiers like Ctrl and Meta, and do not force conversion to Windows key format.

HTML input temporarily suspends shortcut triggering without affecting the query; unbound commands are not output, and an empty array is returned if there is no host.

Returns:

  • (Array<String>)

Examples:

ModraUp.get_shortcuts

ModraUp.get_resource_path(filename) ⇒ String, nil

Find application resource files (LanguageHandler uses). In $LOAD_PATH, look for Resources/en-US/filename, then find the same-named file. If not found, return nil.

Parameters:

  • filename (String)

Returns:

  • (String, nil)

Examples:

ModraUp.get_resource_path("gettingstarted.strings")

ModraUp.format_length(length) ⇒ StringModraUp.format_length(length, precision) ⇒ String

Format the length according to the current model units (internal inches). The second parameter covers decimal places; a negative value will remove trailing zeros.

Parameters:

  • length (Numeric)
  • precision (Integer)

Returns:

  • (String)

Examples:

ModraUp.format_length(1)
ModraUp.format_length(1, 3)

ModraUp.format_angle(radians) ⇒ String

Format the angle in radians into a degree format used by the current model. Currently, it outputs in degrees with a decimal point, e.g., ..

Parameters:

  • radians (Numeric)

Returns:

  • (String)
Note: ModraUp extension. Still does not support model angle units (degrees, minutes, seconds) or regional decimal separators.

Examples:

ModraUp.format_angle(0)  #=> "0.0"

ModraUp.format_degrees(degrees) ⇒ String

Format a number that is already in degrees into an angle text (currently "%.1f").

Parameters:

  • degrees (Numeric)

Returns:

  • (String)

Examples:

ModraUp.format_degrees(10)  #=> "10.0"

ModraUp.format_area(square_inches) ⇒ String

Format the area according to the current model units. The parameter is in square inches.

Parameters:

  • square_inches (Numeric)

Returns:

  • (String)

Examples:

ModraUp.format_area(1)

ModraUp.parse_length(text) ⇒ Float, nil

Parse the length text into inches. Return nil if parsing fails.

Parameters:

  • text (String)

Returns:

  • (Float, nil)

Examples:

ModraUp.parse_length("25.4mm")

ModraUp.format_volume(cubic_inches) ⇒ String

Format the volume using the current model's length unit. The parameter is in cubic inches.

Parameters:

  • cubic_inches (Numeric)

Returns:

  • (String)

Examples:

ModraUp.format_volume(1)

ModraUp.break_edges? ⇒ Boolean

Does the line snap to intersect coplanar edges at the intersection point when breaking them? Defaults to true. The line tool reads this switch from the core imprint_coplanar_line.

Returns:

  • (Boolean)

Examples:

ModraUp.break_edges?

ModraUp.break_edges = enabled ⇒ enabled

Set ModraUp.break_edges? to false to keep intersecting edges intact.

Parameters:

  • enabled (Boolean)

Returns:

  • (Boolean)

Examples:

ModraUp.break_edges = false
ModraUp.break_edges = true

ModraUp.create_texture_writer ⇒ ModraUp::TextureWriter

Create a texture writer.

Returns:

  • (ModraUp::TextureWriter)

Examples:

ModraUp.create_texture_writer.length  #=> 0

ModraUp.add_observer(observer) ⇒ Boolean

Register application-level observers. Adding the same object a second time returns false.

When an observer implements expectsStartupModelNotifications and returns true, the plugin will receive the onNewModel notification after the plugin loads. New, open, and exit events are then dispatched by the host.

Parameters:

  • observer (ModraUp::AppObserver)

Returns:

  • (Boolean)

Examples:

class MyApp < ModraUp::AppObserver
  def expectsStartupModelNotifications
    true
  end
  def onNewModel(model)
    model.tools
  end
end
ModraUp.add_observer(MyApp.new)

ModraUp.remove_observer(observer) ⇒ Boolean

Remove application-level observers. Returns false if not registered.

Parameters:

  • observer (ModraUp::AppObserver)

Returns:

  • (Boolean)

Examples:

obs = ModraUp::AppObserver.new
ModraUp.add_observer(obs)
ModraUp.remove_observer(obs)

ModraUp.read_default(section, key, default = nil) ⇒ Object

Read the persisted preferences and return the type written at the time (see ModraUp.write_default); if not written, return default.

Parameters:

  • section (String)
  • key (String)
  • default (Object)

Returns:

  • (Object)

Examples:

ModraUp.write_default("Demo", "enabled", false)
ModraUp.read_default("Demo", "enabled", true)  #=> false
ModraUp.read_default("Demo", "missing", 3)     #=> 3

ModraUp.write_default(section, key, value) ⇒ Boolean

Persist preferences: save values by type, readable during the current session and written to disk on exit.

Like in SketchUp 2018 and later versions, they are stored in the user directory's PrivatePreferences.json (macOS: ~/Library/Application Support/ModraUp 2026/ModraUp; Windows: %LOCALAPPDATA%\ModraUp\ModraUp 2026\ModraUp).

Nil, true/false, Integer (64-bit or less), Float, String, and their composed Array, Hash are read back as-is; Lengths are stored as Float, Symbols as String, Hash keys as String, and other objects as their to_s result.

Parameters:

  • section (String)
  • key (String)
  • value (Object)

Returns:

  • (Boolean) true

Raises:

  • [ArgumentError] The value contains NaN or Infinity, or is nested more than 64 levels deep (including self-referencing).
  • [RangeError] Integer exceeds 64-bit limit

Examples:

ModraUp.write_default("Demo", "size", [800, 600])
ModraUp.read_default("Demo", "size")  #=> [800, 600]

ModraUp.status_text = text ⇒ text

Displays a prompt in the status bar on the left. Equivalent to ModraUp.set_status_text(text, SB_PROMPT). Ignored if there is no host.

Parameters:

  • text (String)

Returns:

  • (Object)

Examples:

ModraUp.status_text = "Ready"

ModraUp.vcb_label = label_text ⇒ label_text

VCB Label. Equivalent to ModraUp.set_status_text(label_text, SB_VCB_LABEL).

Parameters:

  • label_text (String)

Returns:

  • (Object)

Examples:

ModraUp.vcb_label = "Length"

ModraUp.vcb_value = value ⇒ value

VCB value. Equivalent to ModraUp.set_status_text(value, SB_VCB_VALUE).

Parameters:

  • value (String)

Returns:

  • (Object)

Examples:

ModraUp.vcb_value = "10mm"

ModraUp.set_status_text ⇒ nilModraUp.set_status_text(status_text = '', position = SB_PROMPT) ⇒ Object

Set the status bar. Clear the left prompt, VCB label, and VCB value. position can be SB_PROMPT (left prompt), SB_VCB_LABEL (VCB label), or SB_VCB_VALUE (VCB value).

Parameters:

  • status_text (Object) would to_s
  • position (Integer)

Returns:

  • (Object, nil)

Examples:

Left Status Bar

ModraUp.set_status_text "Working"

VCB

ModraUp.set_status_text("Length", SB_VCB_LABEL)
ModraUp.set_status_text("10mm", SB_VCB_VALUE)

ModraUp.undo ⇒ Boolean

Undo the previous operation on the current model.

Returns:

  • (Boolean)

Examples:

ModraUp.undo

ModraUp.redo ⇒ nil

Redoes the current model by executing the next step in the undo stack.

Returns:

  • (nil)

Examples:

ModraUp.redo

ModraUp.file_new ⇒ Sketchup

Create a new document. When hosted, it follows the path of the "File / New" menu: if the document is dirty, ask to save first, then display the template dialog. If the user cancels saving or selects a template, the document remains unchanged. When not hosted, reset to the default millimeter template (1 m cube).

Returns:

  • (Module)

Examples:

ModraUp.file_new

ModraUp.open_file(path) ⇒ BooleanModraUp.open_file(path, with_status: true) ⇒ Integer, false

Open a .osk3d or .skp file, or pass it to the importer registered by ModraUp.register_importer. Replace the current model. If the file does not exist, return false. For dirty documents, prompt the host to save; if the user cancels, return false. If with_status is true, return ModraUp::Model::LOAD_STATUS_SUCCESS (importers return their ModraUp::Importer::ImportSuccess status, etc.). Ignore show_version_warning_dialog.

Parameters:

  • path (String)

Returns:

  • (Boolean, Integer)

Examples:

ModraUp.open_file("/tmp/box.osk3d")

ModraUp.quit ⇒ nil

Exit the application. Follow the path of closing the window when there is a host (prompt to save dirty documents). Do nothing if there is no host.

Returns:

  • (nil)

Examples:

# ModraUp.quit
ModraUp.respond_to?(:quit)

ModraUp.focus ⇒ Sketchup

Brings the main window to the foreground. Does nothing if there is no host.

Returns:

  • (Module)

Examples:

ModraUp.focus

ModraUp.resize_viewport(width, height) ⇒ BooleanModraUp.resize_viewport(width, height, logical_pixels: true) ⇒ Boolean

Resize the 3D viewport dimensions. After adjustment, ModraUp::View#vpwidth / ModraUp::View#vpheight aligns correctly. logical_pixels: false when resizing by physical pixels; uses screen DPR when hosted, otherwise directly sets the model viewport.

Parameters:

  • width (Integer)
  • height (Integer)

Returns:

  • (Boolean)
Note: ModraUp extension. logical_pixels: is an extension keyword.

Examples:

ModraUp.resize_viewport(640, 480)
ModraUp.active_model.active_view.vpwidth  #=> 640

ModraUp.template ⇒ String

The current template file path. It is an empty string if there is no host and no template is set.

Returns:

  • (String)

Examples:

ModraUp.template

ModraUp.template=(path) ⇒ path

Set the path for the template to be used next time a new model is created. Write the setting when there is a host.

Parameters:

  • path (String)

Returns:

  • (String)

Examples:

ModraUp.template = "mm.osk3d"

ModraUp.template_dir ⇒ String

Template directory. When hosted, it is located at Templates under the application data directory.

Returns:

  • (String)

Examples:

ModraUp.template_dir

ModraUp.fix_shadow_strings? ⇒ Boolean

Enhance face offsetting to reduce shadow stripe artifacts. Only affects polygon offsetting when there is no true shadow channel.

Returns:

  • (Boolean)

Examples:

ModraUp.fix_shadow_strings?

ModraUp.fix_shadow_strings=(enabled) ⇒ Boolean

Toggle Shadow Stripes Correction.

Parameters:

  • enabled (Boolean)

Returns:

  • (Boolean)

Examples:

ModraUp.fix_shadow_strings = false

ModraUp.install_from_archive(path) ⇒ trueModraUp.install_from_archive(path, show_warning) ⇒ true

Unzip the archive (either .rbz or .zip) to the Plugins directory and save the installation record. On restart, load the top-level entry. A default warning for third-party extensions will pop up; if the user cancels, throw Interrupt. If there is no host, return false.

Parameters:

  • path (String)
  • show_warning (Boolean)

Returns:

  • (Boolean)

Raises:

  • [ArgumentError] path is empty
  • [Interrupt] User cancels the warning dialog.
  • [RuntimeError] Archive extraction failed
Note: ModraUp extension. The second parameter show_warning enables the extension.

Examples:

ModraUp.respond_to?(:install_from_archive)

ModraUp.register_importer(importer) ⇒ true

Register the ModraUp::Importer. Afterward, the "Open / Import" dialog will display its file filter, and ModraUp.open_file will call the load_file method when it corresponds to the extension.

Parameters:

  • importer (ModraUp::Importer)

Returns:

  • (Boolean)

Examples:

class DemoImporter < ModraUp::Importer
  def description; "Demo"; end
  def file_extension; "demo"; end
  def id; "demo"; end
  def load_file(path, status); ImportSuccess; end
end
ModraUp.register_importer(DemoImporter.new)

ModraUp.send_action(action) ⇒ Boolean

Trigger an action. The string can include or exclude a trailing colon. Recognized actions: showRubyPanel: (host console), standard views / zoom / perspective, built-in tools, editUndo: / editRedo:, pageAdd: / pageDelete: / pageUpdate: / pageNext: / pagePrevious:, renderWireframe: / renderHiddenLine: / renderMonochrome: / renderShaded: / renderTextures:, viewShowAxes: / viewShowHidden: / viewUndo:, fileNew: / fileOpen: / fileSave: (last two go through the host). Integers are Windows command numbers, e.g., 10501 for top view.

Parameters:

  • action (String, Integer)

Returns:

  • (Boolean)

Examples:

ModraUp.send_action("showRubyPanel:")
ModraUp.send_action("selectLineTool:")
ModraUp.send_action(10501)

ModraUp.display_name_from_action(action_name) ⇒ String

Replace the ModraUp.send_action string with a short name. Remove the trailing colon from unknown names and return them unchanged.

Parameters:

  • action_name (String)

Returns:

  • (String)

Examples:

ModraUp.display_name_from_action("viewRight:")  #=> "Right"

ModraUp.find_support_file(name) ⇒ String, nilModraUp.find_support_file(name, directory) ⇒ String, nil

Find support files. When querying "Plugins", omitting the directory or passing an empty string returns the user plugin directory. For other two-parameter calls, search for directory/name in the plugin directory (prefix can be removed) and $LOAD_PATH.

Parameters:

  • name (String)
  • directory (String) Subpath relative to the Plugins or user files root

Returns:

  • (String, nil)

Examples:

ModraUp.find_support_file("Plugins")

Two parameters

ModraUp.find_support_file("interact_tool.png", "Plugins/su_dynamiccomponents/images")

ModraUp.find_support_files(extension, directory) ⇒ Array<String>

Lists files with matching extensions in the support directory. Omitting directory returns an empty array.

Parameters:

  • extension (String) Does not contain points, for example, +"rb"+.
  • directory (String)

Returns:

  • (Array<String>)

Examples:

ModraUp.find_support_files("rb", "Plugins")

ModraUp.extensions ⇒ ModraUp::ExtensionsManager

Entries in the extensions table registered with ModraUp.register_extension.

Returns:

  • (ModraUp::ExtensionsManager)

Examples:

ModraUp.extensions.each { |ext| ext.name }