Sketchup

SketchUp 6.0+

module

Parent: N/A

Introduction

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.

     # 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])

Methods

Sketchup.active_modelSketchUp 6.0+

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.

Returns:

model
active model object if successful, false if unsuccessful
 model = Sketchup.active_model
 if (! model)
   UI.messagebox "Failure"
 else
   # code acting on the model
 end

Sketchup.add_observerSketchUp 6.0+

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

Arguments:

observer
An observer.

Returns:

status
true if successful, false if unsuccessful.
 status = Sketchup.add_observer observer

Sketchup.app_nameSketchUp 6.0+

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

Returns:

name
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".
 name = Sketchup.app_name

Sketchup.break_edges=SketchUp 7.0+

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.

Arguments:

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

Returns:

setting
true if break edges was turned on.
 is_on = Sketchup.break_edges?

Sketchup.break_edges?SketchUp 7.0+

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.

Returns:

break_edges
true if the feature is on.
 is_on = Sketchup.break_edges?

Sketchup.create_texture_writerSketchUp 6.0+

The create_texture_writer method is used to create a TextureWriter object.

Returns:

texturewriter
a texturewriter object if successful.
 texturewriter = Sketchup.create_texture_writer

Sketchup.display_name_from_actionSketchUp 6.0+

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.

Arguments:

action_name
An action string.

Returns:

friendly_name = a friendly name.
 Sketchup.display_name_from_action("viewRight:")

Sketchup.extensionsSketchUp 8.0 M2+

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

Returns:

extensionsmanager
an ExtensionsManager object.
 extensions = Sketchup.extensions
 for extension in extensions
   UI.messagebox('The next extension is named: ' + extension.name +
       ' and its loaded? state is: ' + extension.loaded?)
 end

Sketchup.file_newSketchUp 6.0+

The file_new method is used to create a new file.

Returns:

Sketchup
a Sketchup object if successful.
 new_sketchup = Sketchup.file_new

Sketchup.find_support_fileSketchUp 6.0+

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.

Arguments:

filename
Name of the filename you want to find.
directory
(optional) directory relative to the SketchUp installation directory.

Returns:

path
the entire path if successful. If unsuccessful, the method returns false.
 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

Sketchup.find_support_filesSketchUp 6.0+

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.

Arguments:

filename
Extension of the files to be found.
directory
directory relative to the SketchUp installation directory. Without this the result will be empty.

Returns:

array
an array of files. If unsuccessful, the method returns false.
 files = Sketchup.find_support_files('rb', 'Plugins')

Sketchup.fix_shadow_strings=SketchUp 8.0 M1+

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.

Arguments:

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

Returns:

setting
true if shadow strings fix was turned on.
 Sketchup.fix_shadow_strings=true

Sketchup.fix_shadow_strings?SketchUp 8.0 M1+

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.

Returns:

fix_shadow_strings
true if the feature is on.
 is_on = Sketchup.fix_shadow_strings?

Sketchup.format_angleSketchUp 6.0+

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.

Arguments:

number
A number to be formatted.

Returns:

degrees
an angle in degrees if successful, false if unsuccessful
 degrees = Sketchup.format_angle Math::PI

Sketchup.format_areaSketchUp 6.0+

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

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

Arguments:

number
A number to be formatted.

Returns:

area
an area if successful, false if unsuccessful.
 area = Sketchup.format_area number

Sketchup.format_degreesSketchUp 6.0+

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.

Arguments:

number
A number to be formatted.

Returns:

degrees
degrees if successful, false if unsuccessful.
 degrees = Sketchup.format_degrees number

Sketchup.format_lengthSketchUp 6.0+

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".

Arguments:

number
A number to be formatted.

Returns:

length
length if successful, false if unsuccessful
 length = Sketchup.format_area 10
 if (length)
   UI.messagebox length
 end

Sketchup.get_datfile_infoSketchUp 6.0+

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.

Arguments:

key
The key whose value you want to retrieve.
default_value
The default value you want returned if key is not available.

Returns:

value
a string value if successful.
 value = Sketchup.get_datfile_info(key, default_value)

Sketchup.get_i18ndatfile_infoSketchUp 6.0+

The get_i18ndatfile_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.

Arguments:

key
The key whose value you want to retrieve.
default_value
The default value you want returned if key is not available.

Returns:

value
a string value if successful.
 value = Sketchup.get_i18ndatfile_info(key, default_value)

Sketchup.get_localeSketchUp 6.0+

The get_locale method returns the language code for the language SketchUp is running in.

Valid return values include: en-US, fr, it, de, es, ja, ko, zh-CN, zh-TW, pt-BR, nl, ru. If the OS language does not have corresponding folder and files in the SketchUp Resources folder, the returned language is, by default, en-US.

Returns:

language
a code representing the language SketchUp is displaying.
 locale = Sketchup.get_locale
 if (locale)
   UI.messagebox locale
 end

Sketchup.get_resource_pathSketchUp 6.0+

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.

Arguments:

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

Returns:

path
the directory path to the resources folder.
 directory = Sketchup.get_resource_path "Styles.strings"

Sketchup.get_shortcutsSketchUp 6.0+

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"

Returns:

shortcuts
an array of shortcut strings.
 shortcuts = Sketchup.get_shortcuts

Sketchup.install_from_archiveSketchUp 8.0 M2+

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 .rb or .rbs 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.

Returns:

extensionsmanager
an ExtensionsManager object.
 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

Sketchup.is_onlineSketchUp 6.0+

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.

Returns:

status
true if successful, false if unsuccessful.
 status = Sketchup.is_online

Sketchup.is_pro?SketchUp 7.0+

Returns a boolean flag indicating whether the application is SketchUp Pro. Note that after the free trial period, SketchUp Pro will revert to regular SketchUp and this method will return false until the user registers the product.

Returns:

is_pro
true if the user is using SketchUp Pro
 if (Sketchup.is_pro?)
   UI.messagebox "You are running SU Pro."
 end

Sketchup.is_valid_filename?SketchUp 6.0+

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

Arguments:

filename
A filename string.

Returns:

status
true if filename is valid, false if filename is invalid (contains illegal characters).
 status = Sketchup.is_valid_filename? filename

Sketchup.loadSketchUp 6.0+

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 .rbs (encrypted). The scrambler application used to encrypt SketchUp ruby scripts is available in the SketchUp C++ SDK. See the "Distributing your Plugin" article for details.

Arguments:

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

Returns:

status
True if the file is included. False if the file is not included.
 sfile = "application_loader" # .rb or .rbs not required
 statuts = Sketchup.load(sfile)

Sketchup.open_fileSketchUp 6.0+

The open_file method is used to open a file.

Arguments:

filename
The path and filename to open.

Returns:

result
true if opening the file succeeded, false otherwise.
 result = Sketchup.open_file "C:\\model.skp"

Sketchup.os_languageSketchUp 6.0+

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

Valid return values are: en-US, fr, it, de, es, ja, ko, zh-CN, zh-TW, pt-BR, nl, ru. If the OS language does not have corresponding folder and files in the SketchUp Resources folder, the returned language is, by default, en-US.

Returns:

language
a code representing the language SketchUp is displaying.
 language = Sketchup.os_language

Sketchup.parse_lengthSketchUp 6.0+

The parse_length method parses a string as a length.

For example, "200" becomes 200.0.

Arguments:

stringnumber
The string to be parsed as a number.

Returns:

length
the numerical representation of the string if successful, or false if unsuccessful.
 length = Sketchup.parse_length "stringnumber"

Sketchup.platformSketchUp 2014+

This methods return a 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
  • Returns:

    symbol
    Current OS platform.
     IS_WIN = Sketchup.platform == :platform_win
     IS_OSX = Sketchup.platform == :platform_osx

Sketchup.plugins_disabled=SketchUp 8.0 M2+

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.

Arguments:

enabled
If true, the plugins directory will not load.

Returns:

setting
true if plugins were disabled.
 // 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

Sketchup.plugins_disabled?SketchUp 8.0 M2+

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

Returns:

plugins_disabled
true if the plugins are disabled.
 is_disabled = Sketchup.plugins_disabled?

Sketchup.quitSketchUp 2014+

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.

Returns:

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

Sketchup.read_defaultSketchUp 6.0+

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).

Arguments:

section
A section in an .INI or registry.
variable
A variable within the section.
default
(optional) A default value if the value is not found.

Returns:

result
nil if unsuccessful, the value of the default if successful.
 result = Sketchup.read_default "section",
 "variable", "default"

Sketchup.register_extensionSketchUp 6.0+

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

Arguments:

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

Returns:

status
true if extension registered properly
 utilitiesExtension = SketchupExtension.new "Utilities Tools",
   "Utilities/utilitiesTools.rb"

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

 Sketchup.register_extension utilitiesExtension, false

Sketchup.register_importerSketchUp 6.0+

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

Arguments:

importer
An Importer object representing the importer.

Returns:

status
true if successful, false if unsuccessful.
 status = Sketchup.register_importer importer

Sketchup.remove_observerSketchUp 6.0+

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

Arguments:

observer
An observer.

Returns:

true if successful, false if unsuccessful.
 status = Sketchup.remove_observer observer

Sketchup.requireSketchUp 6.0+

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 .rb first (unencrypted) and then .rbs (encrypted). The scrambler application used to encrypt SketchUp ruby scripts is available in the SketchUp C++ SDK.

Arguments:

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

Returns:

status
True if the file is included. False if the file is not included.
 sfile = "application_loader" # .rb or .rbs not required
 statuts = Sketchup::require(sfile)

Sketchup.save_thumbnailSketchUp 6.0+

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

Arguments:

skp_filename
The name of the SketchUp file whose model you want represented in the thumbnail.
img_filename
The name of the file where the thumbnail will be saved.

Returns:

status
true if successful, false if unsuccessful.
 status = Sketchup.save_thumbnail "skp_filename", "image_filename"

Sketchup.send_actionSketchUp 6.0 (changes in SketchUp 8.0/2013)+

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:
  • selectRotateTool:
  • selectScaleTool:
  • selectSectionPlaneTool:
  • selectTextTool:
  • selectDimensionTool:
  • selectExtrudeTool:
  • selectSelectionTool:
  • editUndo:
  • editRedo:
  • editHide:
  • editUnhide:
  • fixNonPlanarFaces:


Added in SketchUp 8.0+:
  • addBuilding:
  • getPhotoTexture:
  • selectImageIglooTool:
  • selectNorthTool:


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: toggle 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: create 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
  • 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° 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
  • Arguments:

    action
    The action to be performed.

    Returns:

    result
    true if successful, false if unsuccessful
     result = Sketchup.send_action "selectArcTool:"

Sketchup.set_status_textSketchUp 6.0+

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
  • Arguments:

    status
    text (optional) the status text that will appear.
    position
    (optional) the position where the text will appear.

    Returns:

    result
    true if successful, false if unsuccessful.
     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

Sketchup.status_text=SketchUp 6.0+

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.

Arguments:

status_text
The status text that will appear.

Returns:

result
true if successful, false if unsuccessful.
 result = Sketchup.status_text = "This is a Test"

Sketchup.temp_dirSketchUp 2014+

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.

Returns:

String containing the full temporary directory path
 temp_dir = Sketchup.temp_dir

Sketchup.templateSketchUp 6.0+

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.

Returns:

name
the current template
 name = Sketchup.template

Sketchup.template=SketchUp 6.0+

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.

Arguments:

filename
The name of the template to set.

Returns:

status
true if successful, false if unsuccessful.
 status = Sketchup.template= "filename"

Sketchup.template_dirSketchUp 6.0+

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.

Returns:

String containing the full template directory path
 directory = Sketchup.template_dir

Sketchup.undoSketchUp 6.0+

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

Returns:

nil
 Sketchup.undo

Sketchup.vcb_label=SketchUp 6.0+

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.

Arguments:

label_text
The label text that will appear.

Returns:

result
true if successful, false if unsuccessful.
 result = Sketchup.vcb_label = "This is a Test"

Sketchup.vcb_value=SketchUp 6.0+

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.

Arguments:

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

Returns:

result
true if successful, false if unsuccessful.
 result = Sketchup.vcb_value = "This is a Test"

Sketchup.versionSketchUp 6.0+

Gets the current version of sketchup in decimal form.

Returns:

version
the decimal form of the version
 version = Sketchup.version
 if (version)
   UI.messagebox version
 else
   return
 end

Sketchup.version_numberSketchUp 6.0+

Get the current version of sketchup as a whole number for comparisons.

Returns:

version
the whole number form of the version
 version = Sketchup.version_number
 if (version)
   UI.messagebox version
 else
   return
 end

Sketchup.write_defaultSketchUp 6.0+

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).

Arguments:

section
A section in a .plist file (Mac) or the registry (Windows).
variable
A variable within the section.
value
The value to store.

Returns:

result
True if successful, false if unsuccessful.
 result = Sketchup.write_default "section",
   "variable", "my_value"

  

Trimble Home
About Trimble - Privacy Policy - Contact Us