Module: Sketchup

Defined in:
lib/sketchup-api-stubs/stubs/sketchup.rb

Overview

The Sketchup module contains a number of important utility methods for use in your Ruby scripts. Many of the classes in the API are implemented beneath this module. You can think of the Sketchup module as the “root” of the application tree. Most ruby calls start from the currently active model, and this is accessed via the Sketchup.active_model method.

Examples:

# Grab a handle to the currently active model (aka the one the user is
# looking at in SketchUp.)
model = Sketchup.active_model

# Grab other handles to commonly used collections inside the model.
entities = model.entities
layers = model.layers
materials = model.materials
component_definitions = model.definitions
selection = model.selection

# Now that we have our handles, we can start pulling objects and making
# method calls that are useful.
first_entity = entities[0]
UI.messagebox("First thing in your model is a " + first_entity.typename)

number_materials = materials.length
UI.messagebox("Your model has " + number_materials.to_s + " materials.")

new_edge = entities.add_line( [0,0,0], [500,500,0])

Version:

  • SketchUp 6.0

Defined Under Namespace

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

Class Method Summary collapse

Class Method Details

.active_modelSketchup::Model

The active_model method returns the currently active SketchUp model. On the PC, this is the only model that one can have access to via the API, but Macintosh versions of SketchUp can have multiple models open at once, in which case the method will return the model that the user currently has focused.

Examples:

model = Sketchup.active_model
if !model
  UI.messagebox("Failure")
else
  # code acting on the model
end

Returns:

  • (Sketchup::Model)

    active model object if successful, false if unsuccessful

Version:

  • SketchUp 6.0



55
56
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 55

def self.active_model
end

.add_observer(observer) ⇒ Boolean

The add_observer method is used to add an observer to the current object.

Examples:

status = Sketchup.add_observer(observer)

Parameters:

  • observer (Object)

    An observer.

Returns:

  • (Boolean)

    true if successful, false if unsuccessful.

Version:

  • SketchUp 6.0



69
70
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 69

def self.add_observer(observer)
end

.app_nameString

The app_name method is used to retrieve the current application name.

Examples:

name = Sketchup.app_name

Returns:

  • (String)

    the name of the application, either “SketchUp Pro” or “SketchUp”. Note: For versions earlier than SketchUp8 M4 (Mac 8.0.15157 and Windows 8.0.15158) this function will return “Google SketchUp Pro” or “Google SketchUp”.

Version:

  • SketchUp 6.0



84
85
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 84

def self.app_name
end

.break_edges=(enabled) ⇒ Boolean

The break_edges= method can be used to disable or enable the break edges feature. Break edges is the SketchUp 7 feature that automatically splits edges that the user draws which cross over one another.

This feature is always on by default and cannot be disabled by the user via the user interface, but you can call this method to disable it. Be cautious in doing so, however, as the resulting model could then be altered when the user later draws lines into it with the break edges feature reactivated.

Examples:

Sketchup.break_edges = false

Parameters:

  • enabled (Boolean)

    If true, break edges will be turned on. If false, it will be deactivated.

Returns:

  • (Boolean)

    true if break edges was turned on.

Version:

  • SketchUp 7.0



107
108
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 107

def self.break_edges=(enabled)
end

.break_edges?Boolean

The break_edges? method indicates whether the break edges feature is currently turned on. Break edges is the SketchUp 7 feature that automatically splits edges that the user draws which cross over one another. This feature is always on by default and cannot be disabled by the user via the user interface.

Examples:

is_on = Sketchup.break_edges?

Returns:

  • (Boolean)

Version:

  • SketchUp 7.0



122
123
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 122

def self.break_edges?
end

.create_texture_writerSketchup::TextureWriter

The create_texture_writer method is used to create a TextureWriter object.

Examples:

texturewriter = Sketchup.create_texture_writer

Returns:

Version:

  • SketchUp 6.0



133
134
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 133

def self.create_texture_writer
end

.debug_mode=(enabled) ⇒ Boolean

The debug_mode= method lets you controls whether SketchUp will output warnings to the console when it detects incorrect usage of the API. The setting takes effect right away, no need to restart SketchUp.

Examples:

Sketchup.debug_mode = true

Parameters:

  • enabled (Boolean)

    If true, SketchUp will produce debug warnings.

Returns:

  • (Boolean)

Version:

  • SketchUp 2016



149
150
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 149

def self.debug_mode=(enabled)
end

.debug_mode?Boolean

The debug_mode? controls whether SketchUp will output warnings to the console when it detects incorrect usage of the API.

Examples:

debug_mode = Sketchup.debug_mode?

Returns:

  • (Boolean)

Version:

  • SketchUp 2016



161
162
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 161

def self.debug_mode?
end

.display_name_from_action(action_name) ⇒ String

Note:

This method has been non-functional on Mac since SketchUp 8.

The display_name_from_action method is used to gets a user-friendly name from an action string. See Sketchup.send_action for a list of valid action strings.

Examples:

Sketchup.display_name_from_action("viewRight:")

Parameters:

  • action_name (String)

    An action string.

Returns:

  • (String)

    a friendly name.

Version:

  • SketchUp 6.0



179
180
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 179

def self.display_name_from_action(action_name)
end

.extensionsSketchup::ExtensionsManager

Returns the ExtensionsManager where you can find all registered SketchupExtension objects.

Examples:

extensions = Sketchup.extensions
extensions.each{ |extension|
  puts "The next extension is named: #{extension.name} and its loaded? state is: #{extension.loaded?}"
}

Returns:

Version:

  • SketchUp 8.0 M2



194
195
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 194

def self.extensions
end

.file_newModule

The file_new method is used to create a new file.

Examples:

new_sketchup = Sketchup.file_new

Returns:

  • (Module)

    The Sketchup module.

Version:

  • SketchUp 6.0



205
206
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 205

def self.file_new
end

.find_support_file(filename, directory) ⇒ String

The find_support_files method is used to retrieve the relative path and name of a file within the SketchUp installation directory.

Forward slashes must be used to delimit between directory names.

Examples:

help_file = Sketchup.find_support_file("help.html", "Plugins/")
if help_file
  # Print out the help_file full path
  UI.messagebox(help_file)

  # Open the help_file in a web browser
  UI.openURL("file://" + help_file)
else
  UI.messagebox("Failure")
end

Parameters:

  • filename (String)

    Name of the filename you want to find.

  • directory (String)

    directory relative to the SketchUp installation directory.

Returns:

  • (String)

    the entire path if successful. If unsuccessful, the method returns false.

Version:

  • SketchUp 6.0



236
237
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 236

def self.find_support_file(filename, directory)
end

.find_support_files(filename, directory) ⇒ Array<String>

The find_support_files method is used to retrieve the path and name of all matching files within the SketchUp installation directory.

Forward slashes must be used to delimit between directory names.

Examples:

files = Sketchup.find_support_files('rb', 'Plugins')

Parameters:

  • filename (String)

    Extension of the files to be found.

  • directory (String)

    directory relative to the SketchUp installation directory. Without this the result will be empty.

Returns:

  • (Array<String>)

    an array of files. If unsuccessful, the method returns false.

Version:

  • SketchUp 6.0



259
260
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 259

def self.find_support_files(filename, directory)
end

.fix_shadow_strings=(enabled) ⇒ Boolean

The fix_shadow_strings= method lets you control whether shadow rendering attempts to fix an artifact commonly referred to as “strings”. The fix is actually very model dependent and not controllable from the UI, so this method can be used to control it.

Examples:

Sketchup.fix_shadow_strings = true

Parameters:

  • enabled (Boolean)

    If true, shadow strings fix will be turned on. If false, it will be deactivated.

Returns:

  • (Boolean)

    true if shadow strings fix was turned on.

Version:

  • SketchUp 8.0 M1



277
278
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 277

def self.fix_shadow_strings=(enabled)
end

.fix_shadow_strings?Boolean

The fix_shadow_strings? method indicates whether the a fix for a shadow rendering artifact commonly referred to as “strings” is enabled. The fix is actually very model dependent and not controllable from the UI, so this method can be used to test it.

Examples:

is_on = Sketchup.fix_shadow_strings?

Returns:

  • (Boolean)

Version:

  • SketchUp 8.0 M1



291
292
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 291

def self.fix_shadow_strings?
end

.focusObject

The focus method is used to focus the active model window.

Examples:

Sketchup.focus

See Also:

Version:

  • SketchUp 2021.1



302
303
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 302

def self.focus
end

.format_angle(number) ⇒ String

The format_angle method takes a number as an angle in radians and formats it into degrees. For example, format_angle(Math::PI) will return 180.0.

Examples:

degrees = Sketchup.format_angle(Math::PI)

Parameters:

  • number (Numeric)

    A number to be formatted.

Returns:

  • (String)

    an angle in degrees if successful, false if unsuccessful

Version:

  • SketchUp 6.0



317
318
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 317

def self.format_angle(number)
end

.format_area(number) ⇒ String

The format_area method formats a number as an area using the current units settings.

The number must be in square inches.

Examples:

number = 3.m * 4.m # This will result in 12m2 in inches.
formatted_area = Sketchup.format_area(number)

Parameters:

  • number (Numeric)

    A number to be formatted.

Returns:

Version:

  • SketchUp 6.0



335
336
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 335

def self.format_area(number)
end

.format_degrees(number) ⇒ String

The format_degrees method formats a number as an angle given in degrees. For example, 10 becomes 10.0. This is the equivalent to a to_f call.

Examples:

degrees = Sketchup.format_degrees(number)

Parameters:

  • number (Numeric)

    A number to be formatted.

Returns:

  • (String)

    degrees if successful, false if unsuccessful.

Version:

  • SketchUp 6.0



350
351
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 350

def self.format_degrees(number)
end

.format_length(number) ⇒ String .format_length(number, precision) ⇒ String

The format_length method formats a number as a length using the current units settings.

The default unit setting is inches. For example, 10 becomes 10“.

Examples:

length = Sketchup.format_length(10)

Overloads:

  • .format_length(number) ⇒ String

    Parameters:

    • number (Numeric)

      A number to be formatted.

  • .format_length(number, precision) ⇒ String

    Parameters:

    • number (Numeric)

      A number to be formatted.

    • number (Integer)

      A custom precision. Negative number will strip trailing zeros.

Returns:

Version:

  • SketchUp 6.0



374
375
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 374

def self.format_length(*args)
end

.format_volume(number) ⇒ String

The format_volume method formats a number as a volume using the current units settings.

The number must be in cubic inches.

Examples:

number = 3.m * 4.m * 5.m # This will result in 60m3 in inches.
formatted_volume = Sketchup.format_area(number)

Parameters:

  • number (Numeric)

    A number to be formatted.

Returns:

Version:

  • SketchUp 2019.2



392
393
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 392

def self.format_volume(number)
end

.get_datfile_info(key, default_value) ⇒ String

The get_datfile_info method is used to retrieve the value for the given key from Sketchup.dat.

If the key is not found, default_value is returned.

Examples:

value = Sketchup.get_datfile_info(key, default_value)

Parameters:

  • key (String)

    The key whose value you want to retrieve.

  • default_value (String)

    The default value you want returned if key is not available.

Returns:

  • (String)

    a string value if successful.

Version:

  • SketchUp 6.0



413
414
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 413

def self.get_datfile_info(key, default_value)
end

.get_i18n_datfile_info(key, default_value) ⇒ String

The get_i18n_datfile_info method is used to retrieve the value for the given key from the internationalization file that SketchUp uses to work in multiple languages.

If the key is not found, default_value is returned.

Examples:

value = Sketchup.get_i18n_datfile_info(key, default_value)

Parameters:

  • key (String)

    The key whose value you want to retrieve.

  • default_value (String)

    The default value you want returned if key is not available.

Returns:

Version:

  • SketchUp 6.0



435
436
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 435

def self.get_i18n_datfile_info(key, default_value)
end

.get_localeString

The os_language method returns the language code for the language SketchUp is running in. This is an alias for the get_locale method.

Examples of return values are: en-US, fr, it, de, es, ja, ko, zh-CN, zh-TW, pt-BR, nl, ru and sv. For an up to date list os supported languages, see the SketchUp download page.

Examples:

language = Sketchup.os_language

Returns:

  • (String)

    a code representing the language SketchUp is displaying.

Version:

  • SketchUp 6.0



452
453
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 452

def self.get_locale
end

.get_resource_path(filename) ⇒ String

The get_resource_path is used to retrieve the directory where “resource” files are stored by SketchUp. Resource files include things like language localization files.

Examples:

directory = Sketchup.get_resource_path("Styles.strings")

Parameters:

  • filename (String)

    The filename of a resource file in the resource directory hierarchy.

Returns:

  • (String)

    the directory path to the resources folder.

Version:

  • SketchUp 6.0



468
469
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 468

def self.get_resource_path(filename)
end

.get_shortcutsArray<String>

The get_shortcuts method retrieves an array of all keyboard shortcuts currently registered with SketchUp. Each shortcut is returned as a string with the shortcut and the command separated by a tab, similar to “Ctrl+A\tEdit/Select All”

Examples:

shortcuts = Sketchup.get_shortcuts

Returns:

Version:

  • SketchUp 6.0



482
483
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 482

def self.get_shortcuts
end

.install_from_archive(filepath, show_warning = true) ⇒ Boolean

Installs the contents of a ZIP archive file into SketchUp’s Plugins folder. If the ZIP contains subfolders, these will be preserved. This allows for a Ruby API plugin or Extension developer to distribute their plugin as a single file regardless of how many asset files must be included.

The user will be shown a warning message that they must agree to before the install proceeds. If they do not agree, an Interrupt error will be raised. If the user does agree but there is a problem with the unzip process, an Exception will be raised. You can capture these states via a begin/rescue. See the example below.

If the install is successful, any Ruby files that have been added to the Plugins folder will immediately be executed, saving the user a restart.

To create an archive file, use your favorite tool (7zip, Winzip, etc.) to zip up any files and folders in your plugins directory. If the archive contains a SketchupExtension that you would like users to be able to install from the Preferences > Extensions panel, rename your file to have a .rbz file extension.

Examples:

path = 'c:/temp/SomePluginPackage.zip'
begin
  Sketchup.install_from_archive(path)
rescue Interrupt => error
  UI.messagebox("User said 'no': " + error)
rescue Exception => error
  UI.messagebox("Error during unzip: " + error)
end

Parameters:

  • filepath (String)

    The path to the RBZ or ZIP file to install.

  • show_warning (Boolean) (defaults to: true)

    Whether to warn the user not to install untrusted extensions. In certain cases the warning can be confusing and redundant, e.g. when automatically updating a trusted extension. When the user has selected the archive themselves, it is best to warn about the possible risks.

Returns:

  • (Boolean)

Raises:

  • (Exception)

    If the archive cannot be installed.

  • (Interrupt)

    If the user cancel the installation.

  • (Exception)

    If the archive cannot be found.

Version:

  • SketchUp 8.0 M2



533
534
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 533

def self.install_from_archive(filepath, show_warning = true)
end

.is_64bit?Boolean

This methods indicates whether the host SketchUp application is 64bit. Useful for extensions that ship with binaries and need to determine which versions to load.

Examples:

# For backward compatibility, check for the existence of the method
# and load 32bit binaries for SketchUp versions that do not have this
# method.
if Sketchup.respond_to?(:is_64bit?) && Sketchup.is_64bit?
  # Load 64bit binaries.
else
  # Load 32bit binaries.
end

Returns:

  • (Boolean)

Version:

  • SketchUp 2015



553
554
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 553

def self.is_64bit?
end

.is_onlineBoolean

The is_online method is used to verify a connection to the Internet. This method can take some time to execute, so be careful not to call it more often than you need.

Examples:

status = Sketchup.is_online

Returns:

  • (Boolean)

    true if successful, false if unsuccessful.

Version:

  • SketchUp 6.0



566
567
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 566

def self.is_online
end

.is_pro?Boolean

Note:

In SketchUp Make this method will return true during the Pro trial period and revert to false when the trial period is over.

Returns a boolean flag indicating whether the application is SketchUp Pro.

Examples:

if Sketchup.is_pro?
  UI.messagebox("You are running SU Pro.")
end

Returns:

  • (Boolean)

Version:

  • SketchUp 7.0



582
583
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 582

def self.is_pro?
end

.is_valid_filename?(filename) ⇒ Boolean

The is_valid_filename? method is used to determine whether a filename contains illegal characters.

Examples:

status = Sketchup.is_valid_filename?(filename)

Parameters:

  • filename (String)

    A filename string.

Returns:

  • (Boolean)

Version:

  • SketchUp 6.0



597
598
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 597

def self.is_valid_filename?(filename)
end

.load(path) ⇒ Boolean

The load method is used to include encrypted and nonencrypted ruby files.

You do not need to include the file extension on the path. This method will look for .rb first (unencrypted) and then .rbe (encrypted) and finally .rbs (the deprecated scrambled format) files. See the “Distributing your Plugin” article for details.

Examples:

sfile = "application_loader" # file extension not required
status = Sketchup.load(sfile)

Parameters:

  • path (String)

    The path, including the filename, to the file you want to require.

Returns:

  • (Boolean)

    True if the file is included. False if the file is not included.

Version:

  • SketchUp 6.0



619
620
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 619

def self.load(path)
end

.open_file(filename) ⇒ Boolean .open_file(filename, with_status: true) ⇒ Integer, false

The open_file method is used to open a SketchUp model.

Examples:

result = Sketchup.open_file("C:\\model.skp")

Overloads:

  • .open_file(filename) ⇒ Boolean
    Deprecated.

    Prefer with_status overload instead of this variant.

    Returns true if opening the file succeeded, false otherwise.

    Parameters:

    • filename (String)

      The model file to open.

    Returns:

    • (Boolean)

      true if opening the file succeeded, false otherwise.

  • .open_file(filename, with_status: true) ⇒ Integer, false

    Starting with SketchUp 2021.0 SketchUp attempts to load newer SketchUp models. If a newer model is loaded some information might have been skipped and extensions should be careful to not save over the file they loaded from as information might be lost.

    Success status codes:

    Parameters:

    • filename (String)

      The model file to open.

    Returns:

    • (Integer, false)

      status code if opening the file succeeded, false otherwise.

    Version:

    • SketchUp 2021.0

Version:

  • SketchUp 6.0



651
652
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 651

def self.open_file(*args)
end

.os_languageString

The os_language method returns the language code for the language SketchUp is running in. This is an alias for the get_locale method.

Examples of return values are: en-US, fr, it, de, es, ja, ko, zh-CN, zh-TW, pt-BR, nl, ru and sv. For an up to date list os supported languages, see the SketchUp download page.

Examples:

language = Sketchup.os_language

Returns:

  • (String)

    a code representing the language SketchUp is displaying.

Version:

  • SketchUp 6.0



668
669
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 668

def self.os_language
end

.parse_length(string) ⇒ Float

The parse_length method parses a string as a length.

For example, “200” becomes 200.0.

Examples:

float = Sketchup.parse_length("2'") # Returns 24 (representing inches)
length = float.to_l # Convert to a Length type if needed.

Parameters:

  • string (String)

    The string to be parsed as a number.

Returns:

  • (Float)

    the numerical representation of the string if successful, or nil if unsuccessful.

Version:

  • SketchUp 6.0



686
687
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 686

def self.parse_length(string)
end

.platformSymbol

This methods returns a symbol indicating the current platform.

It should be used over RUBY_PLATFORM as this returns a different value for Windows since SketchUp 2014.

Older SketchUp versions still need to check RUBY_PLATFORM.include?('mswin') or RUBY_PLATFORM.include?('darwin').

Possible return values:

  • :platform_win

  • :platform_osx

Examples:

module MyExtension
  IS_WIN = Sketchup.platform == :platform_win
  IS_OSX = Sketchup.platform == :platform_osx
end

Returns:

  • (Symbol)

    Current OS platform.

Version:

  • SketchUp 2014



711
712
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 711

def self.platform
end

.plugins_disabled=(enabled) ⇒ Boolean

The plugins_disabled= method lets you control whether SketchUp will load Ruby scripts from the plugins directory at startup time. This is primarily a trouble-shooting method. If you are having strange behavior in SketchUp that you suspect is from a bad script, you can type Sketchup.plugins_disabled=true into the Ruby console and restart SketchUp to see if the problem is fixed.

Examples:

# Type this in the Ruby console then restart SketchUp.
Sketchup.plugins_disabled = true

# To reactivate plugins, type this into the Ruby console and restart.
Sketchup.plugins_disabled = false

Parameters:

  • enabled (Boolean)

    If true, the plugins directory will not load.

Returns:

  • (Boolean)

    true if plugins were disabled.

Version:

  • SketchUp 8.0 M2



734
735
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 734

def self.plugins_disabled=(enabled)
end

.plugins_disabled?Boolean

The plugins_disabled? method indicates whether Ruby scripts in the plugins directory will be loaded at startup time.

Examples:

is_disabled = Sketchup.plugins_disabled?

Returns:

  • (Boolean)

Version:

  • SketchUp 8.0 M2



746
747
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 746

def self.plugins_disabled?
end

.quitObject

The quit method is used to terminate the application. This will pop-up the usual model save prompts if there are unsaved models open. User can cancel the model save, in which case the application will not terminate.

Examples:

Sketchup.quit
# Do not expect code to execute reliably after this point.

Returns:

  • self

Version:

  • SketchUp 2014



760
761
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 760

def self.quit
end

.read_default(section, variable, default = nil) ⇒ Object?

The read_default method is used to retrieve the string associated with a value within the specified sub-section section of a .INI file or registry (within the Software > SketchUp > SketchUp [Version] section).

Examples:

result = Sketchup.read_default("section", "variable", "default")

Parameters:

  • section (String)

    A section in an .INI or registry.

  • variable (String)

    A variable within the section.

  • default (Object) (defaults to: nil)

    A default value if the value is not found.

Returns:

  • (Object, nil)

    if unsuccessful, the value of the default if successful.

Version:

  • SketchUp 6.0



783
784
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 783

def self.read_default(section, variable, default = nil)
end

.redonil

The redo method is used redo the last transaction on the redo stack.

Examples:

Sketchup.redo

Returns:

  • (nil)

Version:

  • SketchUp 2021.0



794
795
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 794

def self.redo
end

.register_extension(extension, load_on_start = false) ⇒ Boolean

Note:

It is recommended to set load_on_start to true unless you have a very good reason not to.

The register_extension method is used to register an extension with SketchUp’s extension manager (in SketchUp preferences).

Examples:

utilities_extension = SketchupExtension.new("Utilities Tools",
  "Utilities/utilitiesTools.rb")

utilities_extension.description = "Adds Tools->Utilities to the " +
  "SketchUp inteface. The Utilities submenu contains two tools: " +
  "Create Face and Query Tool."

Sketchup.register_extension(utilities_extension, false)

Parameters:

  • extension (SketchupExtension)

    A SketchupExtension object.

  • load_on_start (Boolean) (defaults to: false)

    Passing true into this will load the extension immediately and set it so that it will load automatically whenever SketchUp restarts.

Returns:

  • (Boolean)

    true if extension registered properly

Version:

  • SketchUp 6.0



825
826
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 825

def self.register_extension(extension, load_on_start = false)
end

.register_importer(importer) ⇒ Boolean

The register_importer method is used to register an importer with SketchUp.

Examples:

status = Sketchup.register_importer(importer)

Parameters:

Returns:

  • (Boolean)

    true if successful, false if unsuccessful.

Version:

  • SketchUp 6.0



839
840
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 839

def self.register_importer(importer)
end

.remove_observer(observer) ⇒ Boolean

The remove_observer method is used to remove an observer from the current object.

Examples:

status = Sketchup.remove_observer(observer)

Parameters:

Returns:

  • (Boolean)

    true if successful, false if unsuccessful.

Version:

  • SketchUp 6.0



854
855
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 854

def self.remove_observer(observer)
end

.require(path) ⇒ Boolean

The require method is used to include encrypted and nonencrypted ruby files. This is an alias of the Sketchup.load method.

You do not need to include the file extension on the path. This method will look for .rbe first (encrypted) and then .rbs (the deprecated scrambled format) and finally .rb (unencrypted) files. The loading order was changed in SketchUp 2016 when the new .rbe encryption was introduced. Prior to SketchUp 2016 the loading order was first .rb then .rbs.

Examples:

sfile = "application_loader" # file extension not required
status = Sketchup::require(sfile)

Parameters:

  • path (String)

    The path, including the filename, to the file you want to require.

Returns:

  • (Boolean)

    True if the file is included. False if the file is not included.

Version:

  • SketchUp 6.0



878
879
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 878

def self.require(path)
end

.save_thumbnail(skp_filename, img_filename) ⇒ Boolean

The save_thumbnail method is used to generate a thumbnail for any SKP file - not necessarily the loaded model.

Examples:

status = Sketchup.save_thumbnail("skp_filename", "image_filename")

Parameters:

  • skp_filename (String)

    The name of the SketchUp file whose model you want represented in the thumbnail.

  • img_filename (String)

    The name of the file where the thumbnail will be saved.

Returns:

  • (Boolean)

    true if successful, false if unsuccessful.

Version:

  • SketchUp 6.0



897
898
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 897

def self.save_thumbnail(skp_filename, img_filename)
end

.send_action(action) ⇒ Boolean

The send_action method sends a message to the message queue to perform some action asynchronously.

Valid actions are:

  • showRubyPanel:

  • viewBack:

  • viewBottom:

  • viewFront:

  • viewIso:

  • viewLeft:

  • viewRight:

  • viewTop:

  • viewPerspective:

  • viewShowAxes:

  • viewShowHidden:

  • viewZoomExtents:

  • viewZoomToSelection:

  • viewUndo:

  • selectOrbitTool:

  • selectPositionCameraTool:

  • selectDollyTool:

  • selectTurnTool:

  • selectWalkTool:

  • selectZoomTool:

  • selectFieldOfViewTool:

  • selectZoomWindowTool:

  • pageAdd:

  • pageDelete:

  • pageUpdate:

  • pageNext:

  • pagePrevious:

  • renderWireframe:

  • renderHiddenLine:

  • renderMonochrome:

  • renderShaded:

  • renderTextures:

  • selectArcTool:

  • selectArc3PointTool:

  • selectArc3PointPieTool:

  • selectAxisTool:

  • selectCircleTool:

  • selectEraseTool:

  • selectFreehandTool:

  • selectLineTool:

  • selectMeasureTool:

  • selectMoveTool:

  • selectOffsetTool:

  • selectPaintTool:

  • selectPolygonTool:

  • selectProtractorTool:

  • selectPushPullTool:

  • selectRectangleTool:

  • selectRectangle3PointTool:

  • selectRotateTool:

  • selectScaleTool:

  • selectSectionPlaneTool:

  • selectTextTool:

  • selectDimensionTool:

  • selectExtrudeTool:

  • selectSelectionTool:

  • editUndo:

  • editRedo:

  • editHide:

  • editUnhide:

  • fixNonPlanarFaces:

Added in SketchUp 8.0+:

  • addBuilding:

  • getPhotoTexture:

  • selectImageIglooTool:

  • selectNorthTool:

Added in SketchUp 2013+:

  • showExtensionStore:

Removed in SketchUp 2013+:

  • addBuilding:

On the PC only, you can also send these numeric values. (Note that these are officially “unsupported” and are not guaranteed to work in current or future versions of the API.)

  • 10501: set view to Top

  • 10502: set view to Front

  • 10503: set view to Rear

  • 10504: set view to Left

  • 10505: set view to Right

  • 10506: set view to Bottom

  • 10507: set view to Axonometric

  • 10510: set render mode to Wire

  • 10511: set render mode to Hidden lines removal

  • 10512: set render mode to Surfaces Shading

  • 10513: set render mode to Transparency

  • 10519: set camera to ortho (removes perspective)

  • 10520: walk tool

  • 10521: display the System Preferences dialog box (Files tab)

  • 10522: removes axes display

  • 10523: pan tool

  • 10525: set the interactive eye height feature

  • 10526: zoom window

  • 10527: zoom extents

  • 10529: zoom out 2

  • 10531: toggle the Standard toolbar

  • 10532: toggle the Camera toolbar

  • 10533: display the Shadows Settings dialog box

  • 10537: toggle the Views toolbar

  • 10538: display the System Preferences dialog box (Display tab)

  • 10545: toggle Color ByLayer

  • 10546: toggle Shadows toolbar

  • 10551: toogle Large icons

  • 10576: toggle Render Mode toolbar

  • 10596: set Render Mode to No Transparency (Preferences)

  • 10597: set Render Mode to Wire (Preferences)

  • 10598: set Render Mode to Transparency (Preferences)

  • 10599: set Render Mode to Surfaces Shading (Preferences)

  • 10600: set Render Mode to Texture (Preferences)

  • 10601: set Render Mode to No Texture (Preferences)

  • 10602: toggle Shadows

  • 10603: toggle Profiles

  • 10604: toggle Extension Lines

  • 10605: toggle Jitter edges

  • 21019: hide Status bar and VCB

  • 21020: show Status bar and VCB

  • 21022: hide Status bar and VCB

  • 21023: place 3d text box

  • 21024: select the Measure tool

  • 21031: select the Freehand Draw tool

  • 21041: select the PushPull tool

  • 21048: select the Move tool

  • 21052: hide selected objects

  • 21056: create face with selected edges closed loop

  • 21057: select the Protractor tool

  • 21060: display Components Window

  • 21061: toggle Draw toolbar

  • 21063: toggle Model Bounding Box display

  • 21065: select the Arc tool

  • 21067: creat a new Page

  • 21069: select the Arc 3 Point tool

  • 21070: select the Arc 3 Point Pie tool

  • 21074: show the Materials Browser Window

  • 21076: display the Preferences dialog box (Text activated)

  • 21077: display the Tip of the day Window

  • 21078: select the Paint Bucket tool

  • 21080: display the Page Manager Window

  • 21082: display the Macros Dialog Box

  • 21086: display the Components Browser Window

  • 21094: select the Rectangle tool

  • 21095: select the Polygon tool

  • 21096: select the Circle tool

  • 21098: open the Open Window

  • 21100: select the Offset tool

  • 21101: select all objects

  • 21107: invert selection

  • 21112: open the Import Window

  • 21124: launch the validity check tool

  • 21126: select the Axes tool

  • 21029: select the Rotate tool

  • 21032: toggle Layer toolbar

  • 21036: display the Save as Window

  • 21046: spin the model a full 360&deg; and display report

  • 21047: fast Pick Time report

  • 21049: open the Export model Window

  • 21169: select the Position Camera tool

  • 21170: display the Preferences, Tour Guide activated

  • 21180: create a new Page just right of selected page

  • 21200: display the Insert Image Window

  • 21233: display Area of selected face

  • 21234: display Area of all faces with selected material

  • 21236: select the Scale tool

  • 21237: display the Export 2D Graphics Window

  • 21245: display a Polygon Offset Factors dialog box

  • 21276: reverse selected face(s)

  • 21287: select the Divide feature

  • 21337: select the Section Plane Placement tool

  • 21354: open the Layer Window

  • 21386: open the Export Animation Window

  • 21405: select the Text tool

  • 21406: display Fog dialog box

  • 21410: select the Dim tool

  • 21433: toggle Edit toolbar

  • 21442: select the FollowMe tool

  • 21448: select the Axes tool

  • 21453: select all objects

  • 21460: display Licence

  • 21462: display Authorization dialog box

  • 21463: display un-authorizing message

  • 21464: display Open Licence files (Network) Window

  • 21466: display Quick reference Card in Adobe Reader

  • 21467: display Licences in use dialog box

  • 21469: zoom extents to selected objects

  • 21476: perform a non-planar check on selected objects

  • 21477: list accelerators in window

  • 21485: erase selected objects

  • 21487: display Edit current material dialog box

  • 21485: erase all new created pages

  • 21488: display Entity Info Window

  • 21490: display Soften Edges Window

  • 21491: display Profiles

  • 21492: display Extended Edges

  • 21493: display Jitter Lines

  • 21494: select Field of view tool

  • 21513: display the outliner

  • 21520: override Tile Rendering Size dialog box

  • 21525: select the FollowMe tool

  • 21542: display the Insert Image Window

  • 21560 and up: causes a runtime Error

Examples:

result = Sketchup.send_action("selectArcTool:")

Parameters:

  • action (String, Integer)

    The action to be performed.

Returns:

  • (Boolean)

    true if successful, false if unsuccessful

Version:

  • SketchUp 6.0



1116
1117
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 1116

def self.send_action(action)
end

.send_to_layout(file) ⇒ Boolean

The send_to_layout method is used to open a file in LayOut.

Examples:

result = Sketchup.send_to_layout("C:/models/hexaflexagon.layout")

Parameters:

  • file (String)

    The path and filename to open, either .skp or .layout.

Returns:

  • (Boolean)

    true if opening the file succeeded, false otherwise. If LayOut is not installed or the file is not present this function will return false.

Version:

  • SketchUp 2018



1132
1133
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 1132

def self.send_to_layout(file)
end

.set_status_textnil .set_status_text(status_text = '', position = SB_PROMPT) ⇒ nil

The set_status_text method is used to set the text appearing on the status bar within the drawing window.

If no arguments are passed, the status bar content is cleared. Valid positions are:

  • SB_PROMPT - the text will appear at the left-side of the status bar

  • SB_VCB_LABEL - the text will appear in place of the VCB label

  • SB_VCB_VALUE - the text will appear in the VCB

Examples:

result = Sketchup.set_status_text("This is a Test", SB_VCB_VALUE)
if result
  #code to do something if set_status_text is successful
end

Overloads:

  • .set_status_textnil

    Clears all status panes.

    Returns:

    • (nil)
  • .set_status_text(status_text = '', position = SB_PROMPT) ⇒ nil

    Parameters:

    • status (String)

      text the status text that will appear.

    • position (Integer) (defaults to: SB_PROMPT)

      the position where the text will appear.

    Returns:

    • (nil)

Version:

  • SketchUp 6.0



1163
1164
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 1163

def self.set_status_text(*args)
end

.status_text=(status_text) ⇒ String

The status_text= method is used to set the text appearing on the status bar within the drawing window.

This is the same as calling set_status_text with a 2nd parameter of SB_PROMPT.

Examples:

result = Sketchup.status_text = "This is a Test"

Parameters:

  • status_text (String)

    The status text that will appear.

Returns:

Version:

  • SketchUp 6.0



1181
1182
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 1181

def self.status_text=(status_text)
end

.temp_dirString

The temp_dir method is used to retrieve the OS temporary directory for the current user. You can use this directory to write temporary files that are not required to persist between SketchUp sessions.

Examples:

temp_dir = Sketchup.temp_dir

Returns:

  • (String)

    a string containing the full temporary directory path

Version:

  • SketchUp 2014



1194
1195
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 1194

def self.temp_dir
end

.templateString

The template method is used to get the file name of the current template. Templates are the .skp files that are loaded when the user select File > New.

Examples:

name = Sketchup.template

Returns:

  • (String)

    the current template

Version:

  • SketchUp 6.0



1206
1207
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 1206

def self.template
end

.template=(filename) ⇒ String

The template= method is used to set the file name of the current template. Templates are the .skp files that are loaded when the user select File > New.

Examples:

status = Sketchup.template = "filename"

Parameters:

  • filename (String)

    The name of the template to set.

Returns:

  • (String)

    true if successful, false if unsuccessful.

Version:

  • SketchUp 6.0



1221
1222
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 1221

def self.template=(filename)
end

.template_dirString

The template_dir is used to retrieve the directory where templates are stored by the SketchUp install. Templates are the .skp files that are loaded when the user select File > New.

Examples:

directory = Sketchup.template_dir

Returns:

  • (String)

    containing the full template directory path

Version:

  • SketchUp 6.0



1234
1235
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 1234

def self.template_dir
end

.undonil

The undo method is used undo the last transaction on the undo stack.

Examples:

Sketchup.undo

Returns:

  • (nil)

Version:

  • SketchUp 6.0



1245
1246
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 1245

def self.undo
end

.vcb_label=(label_text) ⇒ String

The vcb_label= method is used to set the label that appears on the vcb, or the “value control box”, which is another word for the “measurements” text entry box that appears at the bottom on the SketchUp window.

This is the same as calling set_status_text with a 2nd parameter of SB_VCB_LABEL.

Examples:

result = Sketchup.vcb_label = "This is a Test"

Parameters:

  • label_text (String)

    The label text that will appear.

Returns:

Version:

  • SketchUp 6.0



1264
1265
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 1264

def self.vcb_label=(label_text)
end

.vcb_value=(value) ⇒ String

The vcb_value= method is used to set the value that appears on the vcb, or the “value control box”, which is another word for the “measurements” text entry box that appears at the bottom on the SketchUp window.

This is the same as calling set_status_text with a 2nd parameter of SB_VCB_VALUE.

Examples:

result = Sketchup.vcb_value = "This is a Test"

Parameters:

  • value (String)

    The text that will appear as the vcb’s value.

Returns:

Version:

  • SketchUp 6.0



1283
1284
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 1283

def self.vcb_value=(value)
end

.versionString

Gets the current version of sketchup in decimal form.

Examples:

version = Sketchup.version
if (version)
  UI.messagebox version
else
  return
end

Returns:

  • (String)

    the decimal form of the version

Version:

  • SketchUp 6.0



1299
1300
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 1299

def self.version
end

.version_number(*args) ⇒ Integer

Get the current version of sketchup as a whole number for comparisons. The number returned has the major, minor, and build values packed into an integer value as follows:

  • Major version = X

  • Minor version = Y

  • Build number = Z

SketchUp 6.0 - SketchUp 2015

  • XXYYYZZZ

SketchUp 2016+

  • XXYZZZZZZZ

Examples:

if (15003000...15004000) === Sketchup.version_number
  puts "SketchUp 15.3"
end
if Sketchup.version_number >= 1600000000
  puts "New format"
end

Returns:

  • (Integer)

    the whole number form of the version

Version:

  • SketchUp 6.0



1326
1327
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 1326

def self.version_number(*args)
end

.write_default(section, key, value) ⇒ Boolean

The write_default method is used to set the string associated with a variable within the specified sub-section of a .plist file on the Mac or the registry on Windows (within the Software > SketchUp > SketchUp [Version] section).

Examples:

result = Sketchup.write_default("section", "key", "my_value")

Parameters:

  • section (String)

    A section in a .plist file (Mac) or the registry (Windows).

  • key (String)

    A key within the section.

  • value (Object)

    The value to store.

Returns:

  • (Boolean)

    True if successful, false if unsuccessful.

Version:

  • SketchUp 6.0



1350
1351
# File 'lib/sketchup-api-stubs/stubs/sketchup.rb', line 1350

def self.write_default(section, key, value)
end