├── lib
├── sketchup-api-stubs.rb
└── sketchup-api-stubs
│ └── stubs
│ ├── Layout
│ ├── LockedEntityError.rb
│ ├── LockedLayerError.rb
│ ├── Ellipse.rb
│ ├── ConnectionPoint.rb
│ ├── ReferenceEntity.rb
│ ├── Image.rb
│ ├── TableRow.rb
│ ├── TableColumn.rb
│ ├── LayerInstance.rb
│ ├── TableCell.rb
│ ├── Page.rb
│ └── Entities.rb
│ ├── String.rb
│ ├── Sketchup
│ ├── LineStyle.rb
│ ├── Http.rb
│ ├── ConstructionPoint.rb
│ ├── ViewObserver.rb
│ ├── DimensionObserver.rb
│ ├── Skp.rb
│ ├── RegionalSettings.rb
│ ├── RenderingOptionsObserver.rb
│ ├── Licensing.rb
│ ├── ClassificationSchema.rb
│ ├── Http
│ │ └── Response.rb
│ ├── EntityObserver.rb
│ ├── Style.rb
│ ├── ShadowInfoObserver.rb
│ ├── Console.rb
│ ├── OptionsProviderObserver.rb
│ ├── PagesObserver.rb
│ ├── DefinitionObserver.rb
│ ├── DimensionRadial.rb
│ ├── UVHelper.rb
│ ├── Menu.rb
│ ├── InstanceObserver.rb
│ ├── OverlaysManager.rb
│ ├── Licensing
│ │ └── ExtensionLicense.rb
│ ├── LineStyles.rb
│ ├── Classifications.rb
│ ├── ExtensionsManager.rb
│ ├── DefinitionsObserver.rb
│ ├── OptionsManager.rb
│ ├── SelectionObserver.rb
│ ├── Tools.rb
│ ├── EntitiesObserver.rb
│ ├── Vertex.rb
│ ├── MaterialsObserver.rb
│ ├── FrameChangeObserver.rb
│ ├── Loop.rb
│ ├── Axes.rb
│ ├── SectionPlane.rb
│ ├── AttributeDictionaries.rb
│ ├── Dimension.rb
│ ├── Set.rb
│ ├── Animation.rb
│ ├── ToolsObserver.rb
│ ├── Styles.rb
│ └── AppObserver.rb
│ ├── Layout.rb
│ ├── Geom
│ ├── OrientedBounds2d.rb
│ ├── LatLong.rb
│ ├── UTM.rb
│ └── Bounds2d.rb
│ └── LanguageHandler.rb
├── .gitignore
├── images
├── view-draw-text-with-bounds.png
└── geom-tesselation-polygon-with-holes.png
├── .github
├── ISSUE_TEMPLATE
│ ├── issues-for-the-stubs.md
│ └── documentation-issues.md
├── README.md
└── workflows
│ └── rake.yaml
├── Gemfile
├── Rakefile
├── .yardopts
├── pages
├── TOS.md
├── importer_options.md
└── intellectual_property.md
├── Solargraph.md
├── sketchup-api-stubs.gemspec
├── LICENSE
├── README.md
└── Documentation Guide.md
/lib/sketchup-api-stubs.rb:
--------------------------------------------------------------------------------
1 | require 'sketchup-api-stubs/sketchup'
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .yardoc/
2 | doc/
3 | debug/
4 |
5 | pkg/
6 |
7 | Gemfile\.lock
8 |
9 | rubocop-changelog.txt
--------------------------------------------------------------------------------
/images/view-draw-text-with-bounds.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SketchUp/ruby-api-stubs/HEAD/images/view-draw-text-with-bounds.png
--------------------------------------------------------------------------------
/images/geom-tesselation-polygon-with-holes.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SketchUp/ruby-api-stubs/HEAD/images/geom-tesselation-polygon-with-holes.png
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/issues-for-the-stubs.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Issues for the stubs
3 | about: Issues with the generation of the stubs can be posted here
4 |
5 | ---
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 |
3 | gemspec
4 |
5 | group :development do
6 | gem 'rake', '~> 12.0'
7 | gem 'yard'
8 | gem 'yard-sketchup'
9 | end
10 |
--------------------------------------------------------------------------------
/Rakefile:
--------------------------------------------------------------------------------
1 | require 'bundler/gem_tasks'
2 | require 'yard'
3 |
4 | YARD::Rake::YardocTask.new do |t|
5 | t.options << '--fail-on-warning'
6 | end
7 |
8 | task default: %i[
9 | yard
10 | ]
11 |
--------------------------------------------------------------------------------
/.yardopts:
--------------------------------------------------------------------------------
1 | --title "SketchUp Ruby API Documentation"
2 | --no-api
3 | --no-private
4 | --hide-api Internal
5 | --plugin yard-sketchup
6 | --asset images:images
7 | lib/sketchup-api-stubs/stubs/**/*.rb
8 | -
9 | pages/*.md
10 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/documentation-issues.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Documentation Issues
3 | about: Report documentation issues in the API Issues repository
4 |
5 | ---
6 |
7 | Please report API documentation issues in the API Issue Tracker repository: https://github.com/SketchUp/api-issue-tracker
8 |
--------------------------------------------------------------------------------
/pages/TOS.md:
--------------------------------------------------------------------------------
1 | # @title Terms Of Service
2 |
3 | # SketchUp Ruby API Terms of Service
4 |
5 | The SketchUp Ruby API is now owned by
6 | [Trimble Navigation Limited](http://www.trimble.com/) and subjected to their
7 | Terms of Service. Please see their
8 | [Terms of Service here](http://www.sketchup.com/intl/en/developer/api-terms-of-service.pdf).
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Layout/LockedEntityError.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # This is raised whenever a method attempts to modify any {Layout::Entity}
5 | # that is individually locked.
6 | #
7 | # @version LayOut 2018
8 | class Layout::LockedEntityError < ArgumentError
9 |
10 | end
11 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Layout/LockedLayerError.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # This is raised whenever a method attempts to modify any {Layout::Entity}
5 | # that resides on a locked {Layout::Layer}, or when attempting to change the
6 | # shared attribute of a locked {Layout::Layer}.
7 | #
8 | # @version LayOut 2018
9 | class Layout::LockedLayerError < ArgumentError
10 |
11 | end
12 |
--------------------------------------------------------------------------------
/Solargraph.md:
--------------------------------------------------------------------------------
1 | # Solargraph for VSCode
2 |
3 | https://marketplace.visualstudio.com/items?itemName=castwide.solargraph
4 | https://github.com/castwide/vscode-solargraph
5 |
6 | ## Using the API stubs for auto-complete
7 |
8 | Generate YARD docs:
9 |
10 | ```
11 | yard gems sketchup-api-stubs
12 | ```
13 |
14 | Add `sketchup-api-stubs` to the `require` config of your
15 | project's `.solargraph.yml` file.
16 |
17 | ```
18 | require_paths:
19 | - "C:/Program Files/SketchUp/SketchUp 2019/Tools"
20 | - src
21 |
22 | require:
23 | - sketchup-api-stubs
24 | ```
25 |
26 | Restart VSCode for config to take effect.
27 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/String.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # The String class contains a method used to parse a string as a length value.
5 | # All string arguments in Ruby API expect utf-8 strings.
6 | #
7 | # @version SketchUp 6.0
8 | class String
9 |
10 | # Instance Methods
11 |
12 | # The to_l method is used to convert a string to a length. The returned length
13 | # is expressed in the Model units.
14 | #
15 | # @example
16 | # length = "5'".to_l
17 | #
18 | # @return [Length] the length value
19 | #
20 | # @version SketchUp 6.0
21 | def to_l
22 | end
23 |
24 | end
25 |
--------------------------------------------------------------------------------
/.github/README.md:
--------------------------------------------------------------------------------
1 | # SketchUp Ruby API Stubs
2 |
3 | [](https://badge.fury.io/rb/sketchup-api-stubs) 
4 |
5 | Auto-generated stubs for the SketchUp Ruby API. Useful for IDE intellisense and auto-complete.
6 |
7 | This is currently a work in progress and it may change a lot in the near future.
8 |
9 | The stubs are automatically generated by a YARD template which we will publish in our sketchup-yard-template repository: https://github.com/SketchUp/sketchup-yard-template
10 |
11 | Guidance on how to set up editors to use the stubs will come.
12 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/LineStyle.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # This provides a way for SketchUp to customize a line style and be set on a
5 | # layer.
6 | #
7 | # @version SketchUp 2019
8 | class Sketchup::LineStyle < Sketchup::Entity
9 |
10 | # Instance Methods
11 |
12 | # The {#name} method retrieves the name of the line style object.
13 | #
14 | # @example
15 | # line_style = Sketchup.active_model.line_styles["Solid Basic"]
16 | # line_style.name # returns "Solid Basic"
17 | #
18 | # @return [String] The name of the line style.
19 | #
20 | # @version SketchUp 2019
21 | def name
22 | end
23 |
24 | end
25 |
--------------------------------------------------------------------------------
/sketchup-api-stubs.gemspec:
--------------------------------------------------------------------------------
1 | # coding: utf-8
2 | Gem::Specification.new do |spec|
3 | spec.name = 'sketchup-api-stubs'
4 | spec.version = '0.7.10'
5 | spec.authors = ['Trimble Inc, SketchUp Team']
6 |
7 | spec.summary = %q{SketchUp Ruby API stubs.}
8 | spec.description = %q{Stubs for the SketchUp Ruby API intended to assist IDEs.}
9 | spec.homepage = 'https://github.com/SketchUp/ruby-api-stubs'
10 | spec.license = 'MIT'
11 |
12 | spec.metadata = {
13 | 'yard.run' => 'yri'
14 | }
15 |
16 | spec.required_ruby_version = '>= 2.0'
17 |
18 | spec.files = Dir.glob([
19 | 'lib/**/*.rb',
20 | '.yardopts',
21 | ])
22 | # spec.require_paths = ['Sketchup']
23 |
24 | spec.add_development_dependency 'bundler', '>= 1.15.0', '< 3.0'
25 | end
26 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Layout/Ellipse.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # A simple elliptical shape entity.
5 | #
6 | # @version LayOut 2018
7 | class Layout::Ellipse < Layout::Entity
8 |
9 | # Instance Methods
10 |
11 | # The {#initialize} method creates a new {Layout::Ellipse}.
12 | #
13 | # @example
14 | # upper_left = Geom::Point2d.new(1, 1)
15 | # lower_right = Geom::Point2d.new(2, 2)
16 | # bounds = Geom::Bounds2d.new(upper_left, lower_right)
17 | # ellipse = Layout::Ellipse.new(bounds)
18 | #
19 | # @param [Geom::Bounds2d] bounds
20 | #
21 | # @raise ArgumentError if bounds is zero size
22 | #
23 | # @return [Layout::Ellipse]
24 | #
25 | # @version LayOut 2018
26 | def initialize(bounds)
27 | end
28 |
29 | end
30 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Layout.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # The LayOut module is the root of the LayOut Ruby API. Many of the classes in
5 | # the API are implemented beneath this module.
6 | #
7 | # @example
8 | # # Open an existing LayOut document.
9 | # doc = Layout::Document.open("C:/path/to/document.layout")
10 | #
11 | # # Grab other handles to commonly used collections inside the model.
12 | # layers = doc.layers
13 | # pages = doc.pages
14 | # entities = doc.shared_entities
15 | #
16 | # # Now that we have our handles, we can start pulling objects and making
17 | # # method calls that are useful.
18 | # first_entity = entities.first
19 | #
20 | # number_pages = pages.length
21 | #
22 | # @version LayOut 2018
23 | module Layout
24 |
25 | end
26 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/Http.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # The {Sketchup::Http} module provides interfaces to create asynchronous HTTP
5 | # requests. This is an alternative to the Net::Http module that comes with
6 | # Ruby StdLib - which is known to have issues within SketchUp.
7 | #
8 | # @version SketchUp 2017
9 | module Sketchup::Http
10 |
11 | # Constants
12 |
13 | DELETE = nil # Stub value.
14 | GET = nil # Stub value.
15 | HEAD = nil # Stub value.
16 | OPTIONS = nil # Stub value.
17 | PATCH = nil # Stub value.
18 | POST = nil # Stub value.
19 | PUT = nil # Stub value.
20 |
21 | STATUS_CANCELED = nil # Stub value.
22 | STATUS_FAILED = nil # Stub value.
23 | STATUS_PENDING = nil # Stub value.
24 | STATUS_SUCCESS = nil # Stub value.
25 | STATUS_UNKNOWN = nil # Stub value.
26 |
27 | end
28 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/ConstructionPoint.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # A construction point represents a point in the model that can be used to aid
5 | # in other modeling operations. For example, you may put a construction point
6 | # at the center of a circle to make it easier to locate that point for
7 | # performing other operations.
8 | #
9 | # @version SketchUp 6.0
10 | class Sketchup::ConstructionPoint < Sketchup::Drawingelement
11 |
12 | # Instance Methods
13 |
14 | # The position method is used to retrieve a Point3d used to create a
15 | # construction point.
16 | #
17 | # @example
18 | # model = Sketchup.active_model
19 | # entities = model.active_entities
20 | # point1 = Geom::Point3d.new(10,0,0)
21 | # constpoint = entities.add_cpoint point1
22 | # # Returns 10,0,0
23 | # position = constpoint.position
24 | #
25 | # @return point - the Point3d object used to create the
26 | # ConstructionPoint
27 | #
28 | # @version SketchUp 6.0
29 | def position
30 | end
31 |
32 | end
33 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016-2019 SketchUp
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/.github/workflows/rake.yaml:
--------------------------------------------------------------------------------
1 | name: Rake
2 |
3 | on:
4 | push:
5 | branches: [ main, master, dev/github-actions ]
6 | paths-ignore:
7 | - '**.md'
8 | pull_request:
9 | paths-ignore:
10 | - '**.md'
11 | workflow_dispatch:
12 |
13 | permissions:
14 | contents: read # to fetch code (actions/checkout)
15 |
16 | jobs:
17 | rake:
18 | name: >-
19 | OS ${{ matrix.os }}, Ruby ${{ matrix.ruby }}
20 | env:
21 | CI: true
22 |
23 | runs-on: ${{ matrix.os }}
24 | if: |
25 | !( contains(github.event.pull_request.title, '[ci skip]')
26 | || contains(github.event.pull_request.title, '[skip ci]'))
27 | strategy:
28 | fail-fast: false
29 | matrix:
30 | os: [ macos-12, windows-2022 ]
31 | ruby: [ 2.7 ]
32 |
33 | steps:
34 | - name: Checkout source
35 | uses: actions/checkout@v3
36 | with:
37 | submodules: recursive
38 |
39 | - name: Setup Ruby
40 | uses: ruby/setup-ruby-pkgs@v1
41 | with:
42 | ruby-version: ${{ matrix.ruby }}
43 | bundler-cache: true
44 | timeout-minutes: 10
45 |
46 | - name: Run rake
47 | timeout-minutes: 10
48 | run: bundle exec rake
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/ViewObserver.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # This observer interface is implemented to react to view events.
5 | #
6 | # @abstract To implement this observer, create a Ruby class of this type,
7 | # override the desired methods, and add an instance of the observer to the
8 | # view object.
9 | #
10 | # @example
11 | # # This is an example of an observer that watches tool interactions.
12 | # class MyViewObserver < Sketchup::ViewObserver
13 | # def onViewChanged(view)
14 | # puts "onViewChanged: #{view}"
15 | # end
16 | # end
17 | #
18 | # # Attach the observer.
19 | # Sketchup.active_model.active_view.add_observer(MyViewObserver.new)
20 | #
21 | # @version SketchUp 6.0
22 | class Sketchup::ViewObserver
23 |
24 | # Instance Methods
25 |
26 | # The {#onViewChanged} method is called whenever the view is altered, such as
27 | # when the user uses the Pan, Orbit, or Zoom tools are used.
28 | #
29 | # @bug Prior to SketchUp 2019.2 this event did not trigger when the viewport
30 | # size changed.
31 | #
32 | # @example
33 | # def onViewChanged(view)
34 | # puts "onViewChanged: #{view}"
35 | # end
36 | #
37 | # @param [Sketchup::View] view
38 | #
39 | # @return [nil]
40 | #
41 | # @version SketchUp 6.0
42 | def onViewChanged(view)
43 | end
44 |
45 | end
46 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/DimensionObserver.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # This observer interface is implemented to react to changes in dimension text.
5 | #
6 | # @abstract To implement this observer, create a Ruby class of this type,
7 | # override the desired methods, and add an instance of the observer to the
8 | # dimensions of interest.
9 | #
10 | # @example
11 | # # This is an example of a DimensionObserver
12 | # class MyDimensionObserver < Sketchup::DimensionObserver
13 | # def onTextChanged(dimension)
14 | # puts "onTextChanged: #{dimension}, new_text= #{dimension.text}"
15 | # end
16 | # end
17 | #
18 | # # Attach the observer. (Assumes there is a dimension in the model root.)
19 | # dim = Sketchup.active_model.entities.grep(Sketchup::Dimension).first
20 | # dim.add_observer(MyDimensionObserver.new)
21 | #
22 | # @version SketchUp 2014
23 | class Sketchup::DimensionObserver
24 |
25 | # Instance Methods
26 |
27 | # The {#onTextChanged} method is invoked when your entity is erased.
28 | #
29 | # @example
30 | # def onTextChanged(dimension)
31 | # puts "onTextChanged: #{dimension}, new_text= #{dimension.text}"
32 | # end
33 | #
34 | # @param [Sketchup::Dimension] dimension
35 | # The dimension object whose text has
36 | # been changed.
37 | #
38 | # @version SketchUp 2014
39 | def onTextChanged(dimension)
40 | end
41 |
42 | end
43 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/Skp.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # The {Sketchup::Skp} module is used to read metadata from external SketchUp
5 | # files without loading the whole file.
6 | #
7 | # @version SketchUp 2021.0
8 | module Sketchup::Skp
9 |
10 | # Class Methods
11 |
12 | # The {.read_guid} method is used to read the GUID, globally unique identifier,
13 | # for an external model.
14 | #
15 | # In SketchUp, GUIDs are used to test if {Sketchup::ComponentDefinition}s and
16 | # {Sketchup::Model}s match (a component being an embedded model).
17 | # When you insert a component to a model, its GUID is compared to existing
18 | # component definitions in that model, and if there is a match the existing
19 | # component definition is re-used rather than a duplicate being added.
20 | # When a component definition is modified or a model is saved, their GUIDs are
21 | # renewed.
22 | #
23 | # @example
24 | # model = Sketchup.active_model
25 | # definitions = model.definitions
26 | # definition = definitions.find { |definition| !definition.internal? }
27 | # # true if component matches its external file.
28 | # definition.guid == Sketchup::Skp.read_guid(definition.path)
29 | #
30 | # @param [String] filepath
31 | #
32 | # @raise [ArgumentError] if the file is missing or is not a SketchUp model.
33 | #
34 | # @return [String]
35 | #
36 | # @version SketchUp 2021.0
37 | def self.read_guid(filepath)
38 | end
39 |
40 | end
41 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/RegionalSettings.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # The {Sketchup::RegionalSettings} module contains methods getting information about the
5 | # user's locale settings.
6 | #
7 | # Note that when you convert between units and strings you don't need to parse
8 | # it yourself and you can instead use {String#to_l} and {Length#to_s}.
9 | #
10 | # @version SketchUp 2016 M1
11 | module Sketchup::RegionalSettings
12 |
13 | # Class Methods
14 |
15 | # Returns the decimal character for the current user's locale.
16 | #
17 | # @example
18 | # # Format a Float using the user's locale settings.
19 | # # Ruby's Float.to_s always use period as decimal separator.
20 | # formatted = 0.123.to_s.tr('.', Sketchup::RegionalSettings.decimal_separator)
21 | #
22 | # @return [String] the decimal separator character
23 | #
24 | # @version SketchUp 2016 M1
25 | def self.decimal_separator
26 | end
27 |
28 | # Returns the list separator character for the current user's locale.
29 | #
30 | # @example
31 | # # Format a CSV list in user's locale:
32 | # decimal = Sketchup::RegionalSettings.decimal_separator
33 | # list = Sketchup::RegionalSettings.list_separator
34 | # row = [3.14, 1.618, 2.718]
35 | # csv = row.map { |value| value.to_s.tr('.', decimal) }.join(list)
36 | #
37 | # @return [String] the list separator character
38 | #
39 | # @version SketchUp 2016 M1
40 | def self.list_separator
41 | end
42 |
43 | end
44 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/RenderingOptionsObserver.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # This observer interface is implemented to react to rendering options events.
5 | #
6 | # @abstract To implement this observer, create a Ruby class of this type, implement the
7 | # desired methods, and add an instance of the observer to the objects of
8 | # interests.
9 | #
10 | # @example
11 | # # This is an example of an observer that watches the rendering options
12 | # # for changes.
13 | # class MyRenderingOptionsObserver < Sketchup::RenderingOptionsObserver
14 | # def onRenderingOptionsChanged(rendering_options, type)
15 | # puts "onRenderingOptionsChanged(#{rendering_options}, #{type})"
16 | # end
17 | # end
18 | #
19 | # # Attach the observer.
20 | # rendering_options = Sketchup.active_model.rendering_options
21 | # rendering_options.add_observer(MyRenderingOptionsObserver.new)
22 | class Sketchup::RenderingOptionsObserver
23 |
24 | # Instance Methods
25 |
26 | # The onRenderingOptionsChanged method is invoked whenever the user changes
27 | # their rendering options.
28 | #
29 | # @example
30 | # def onRenderingOptionsChanged(rendering_options, type)
31 | # puts "onRenderingOptionsChanged(#{rendering_options}, #{type})"
32 | # end
33 | #
34 | # @param [Sketchup::RenderingOptions] rendering_options
35 | #
36 | # @param [Integer] type
37 | # A number indicating which option was changed
38 | # represented by one of the constants defined in
39 | # {Sketchup::RenderingOptions}.
40 | #
41 | # @version SketchUp 6.0
42 | def onRenderingOptionsChanged(rendering_options, type)
43 | end
44 |
45 | end
46 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/Licensing.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # The +Sketchup::Licensing+ module contains methods for
5 | # extensions purchased from Extension Warehouse to check their licensing status.
6 | #
7 | # It is advised to place these calls inside encrypted Ruby (.rbe) files. This
8 | # API is also exposed via the SketchUp C API. Extensions that already use
9 | # native code should prefer using the native API, which should be more secure
10 | # than their Ruby API counterparts.
11 | #
12 | # For more details, see
13 | # {Licensing Example}[https://github.com/SketchUp/sketchup-ruby-api-tutorials/tree/main/examples/99_license]
14 | #
15 | # @version SketchUp 2015
16 | module Sketchup::Licensing
17 |
18 | # Constants
19 |
20 | EXPIRED = nil # Stub value.
21 | LICENSED = nil # Stub value.
22 | NOT_LICENSED = nil # Stub value.
23 | TRIAL = nil # Stub value.
24 | TRIAL_EXPIRED = nil # Stub value.
25 |
26 | # Class Methods
27 |
28 | # Acquires a license for a given extension.
29 | #
30 | # @example
31 | # ext_id = "4e215280-dd23-40c4-babb-b8a8dd29d5ee"
32 | # ext_lic = Sketchup::Licensing.get_extension_license(ext_id)
33 | # if ext_lic.licensed?
34 | # puts "Extension is licensed."
35 | # end
36 | #
37 | # @param [String] extension_id
38 | # The Extension Warehouse UUID for the desired extension.
39 | #
40 | # @return [Sketchup::Licensing::ExtensionLicense] An object representing
41 | # licensing state for the extension. Do not store this object, retrieve
42 | # it again when needed since licensing state may have changed.
43 | #
44 | # @version SketchUp 2015
45 | def self.get_extension_license(extension_id)
46 | end
47 |
48 | end
49 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/ClassificationSchema.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # The ClassificationSchema class represent schemas loaded in the model.
5 | #
6 | # @version SketchUp 2015
7 | class Sketchup::ClassificationSchema
8 |
9 | # Includes
10 |
11 | include Comparable
12 |
13 | # Instance Methods
14 |
15 | # The <=> method is used to compare two ClassificationSchema objects for
16 | # sorting. The comparison is done based on the schema name.
17 | #
18 | # @example
19 | # schema1 = Sketchup.active_model.classifications["IFC 2x3"]
20 | # schema2 = Sketchup.active_model.classifications["gbXML"]
21 | # # Returns -1
22 | # result = schema1 <=> schema2
23 | # # Returns an array of sorted schemas.
24 | # schemas = Sketchup.active_model.classifications.to_a.sort
25 | #
26 | # @param schema2
27 | # The second schema in the comparison.
28 | #
29 | # @return Integer - -1 if schema1 is less then schema2. 1 if
30 | # schema1 is greater than schema2, 0 if the schemas
31 | # are equal.
32 | #
33 | # @version SketchUp 2015
34 | def <=>(schema2)
35 | end
36 |
37 | # The name method returns the name of the schema.
38 | #
39 | # @example
40 | # Sketchup.active_model.classifications.each { |schema|
41 | # puts schema.name
42 | # }
43 | #
44 | # @return String - containing the schema name.
45 | #
46 | # @version SketchUp 2015
47 | def name
48 | end
49 |
50 | # The namespace method returns the namespace of the schema.
51 | #
52 | # @example
53 | # Sketchup.active_model.classifications.each { |schema|
54 | # puts schema.namespace
55 | # }
56 | #
57 | # @return String - containing the schema namespace.
58 | #
59 | # @version SketchUp 2015
60 | def namespace
61 | end
62 |
63 | end
64 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/Http/Response.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # Http::Response objects allows you to get the response information from the
5 | # server, you can only receive the Http::Response if you have attached a
6 | # callback block when calling start from the Http::Request object.
7 | #
8 | # @version SketchUp 2017
9 | class Sketchup::Http::Response
10 |
11 | # Instance Methods
12 |
13 | # Gets the http body that was received from the server as a string encoded
14 | # using the charset provided in the Content-Type of the server response, if
15 | # no charset is specified, ASCII-8BIT will be used.
16 | #
17 | # @example
18 | # @request = Sketchup::Http::Request.new("http://localhost:8080")
19 | #
20 | # @request.start do |request, response|
21 | # puts "body: " + response.body
22 | # end
23 | #
24 | # @return [String]
25 | #
26 | # @version SketchUp 2017
27 | def body
28 | end
29 |
30 | # Returns the http headers that were sent by the server.
31 | #
32 | # @example
33 | # @request = Sketchup::Http::Request.new("http://localhost:8080")
34 | #
35 | # @request.start do |request, response|
36 | # response.headers.each do |key, value|
37 | # puts "#{key}: #{value}"
38 | # end
39 | # end
40 | #
41 | # @return [Hash]
42 | #
43 | # @version SketchUp 2017
44 | def headers
45 | end
46 |
47 | # Returns the HTTP response status code as defined in rfc2616.
48 | #
49 | # @example
50 | # @request = Sketchup::Http::Request.new("http://localhost:8080")
51 | #
52 | # @request.start do |request, response|
53 | # puts "http status code: #{response.status_code}"
54 | # end
55 | #
56 | # @return [Integer]
57 | #
58 | # @version SketchUp 2017
59 | def status_code
60 | end
61 |
62 | end
63 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/EntityObserver.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # This observer interface is implemented to react to entity events.
5 | #
6 | # @abstract To implement this observer, create a Ruby class of this type, override the
7 | # desired methods, and add an instance of the observer to the entity of
8 | # interests.
9 | #
10 | # @example
11 | # class MyEntityObserver < Sketchup::EntityObserver
12 | # def onEraseEntity(entity)
13 | # puts "onEraseEntity: #{entity}"
14 | # end
15 | # end
16 | #
17 | # # Attach the observer. (Assumes there is an entity in the model.)
18 | # Sketchup.active_model.entities[0].add_observer(MyEntityObserver.new)
19 | #
20 | # @note The methods of this observer fire in such a way that making changes
21 | # to the model while inside of them is dangerous. If you experience sudden
22 | # crashes, it could be because of this observer. A potential workaround is to
23 | # use a {Sketchup::ToolsObserver} to watch what the user is doing instead.
24 | #
25 | # @version SketchUp 6.0
26 | class Sketchup::EntityObserver
27 |
28 | # Instance Methods
29 |
30 | # The {#onChangeEntity} method is invoked when your entity is modified.
31 | #
32 | # @example
33 | # def onChangeEntity(entity)
34 | # puts "onChangeEntity: #{entity}"
35 | # end
36 | #
37 | # @param [Sketchup::Entity] entity
38 | #
39 | # @return [nil]
40 | #
41 | # @version SketchUp 6.0
42 | def onChangeEntity(entity)
43 | end
44 |
45 | # The {#onEraseEntity} method is invoked when your entity is erased.
46 | #
47 | # @example
48 | # def onEraseEntity(entity)
49 | # puts "onEraseEntity: #{entity}"
50 | # end
51 | #
52 | # @param [Sketchup::Entity] entity
53 | #
54 | # @return [nil]
55 | #
56 | # @version SketchUp 6.0
57 | def onEraseEntity(entity)
58 | end
59 |
60 | end
61 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/Style.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # The Style class contains methods for modifying information about a specific
5 | # style. Styles are a collection of display settings that tell SketchUp how to
6 | # draw the model.
7 | #
8 | # @example
9 | # styles = Sketchup.active_model.styles
10 | # puts "Your first style is named #{styles.first.name}"
11 | #
12 | # @version SketchUp 6.0
13 | class Sketchup::Style < Sketchup::Entity
14 |
15 | # Instance Methods
16 |
17 | # The {#description} method gets the description for a {Sketchup::Style}.
18 | #
19 | # @example
20 | # styles = Sketchup.active_model.styles
21 | # style = styles.first
22 | # puts "Your first style description is: #{style.description}"
23 | #
24 | # @return [String] description
25 | #
26 | # @version SketchUp 6.0
27 | def description
28 | end
29 |
30 | # The {#description=} method sets the description for a {Sketchup::Style}.
31 | #
32 | # @example
33 | # styles = Sketchup.active_model.styles
34 | # style = styles.first
35 | # style.description = "My new style description."
36 | #
37 | # @param [String] description
38 | #
39 | # @version SketchUp 6.0
40 | def description=(description)
41 | end
42 |
43 | # The {#name} method gets the name for a {Sketchup::Style}.
44 | #
45 | # @example
46 | # styles = Sketchup.active_model.styles
47 | # style = styles.first
48 | # name = style.name
49 | #
50 | # @return [String]
51 | #
52 | # @version SketchUp 6.0
53 | def name
54 | end
55 |
56 | # The {#name=} method sets the name for a {Sketchup::Style}.
57 | #
58 | # @example
59 | # styles = Sketchup.active_model.styles
60 | # style = styles.first
61 | # style.name = 'My Very Own Style'
62 | #
63 | # @param [String] name
64 | #
65 | # @version SketchUp 6.0
66 | def name=(name)
67 | end
68 |
69 | end
70 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/ShadowInfoObserver.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # This observer interface is implemented to react to changes to the shadow
5 | # settings.
6 | #
7 | # @abstract To implement this observer, create a Ruby class of this type,
8 | # override the desired methods, and add an instance of the observer to the
9 | # {Sketchup::ShadowInfo} object.
10 | #
11 | # @example
12 | # # This is an example of an observer that watches the selection for
13 | # # changes.
14 | # class MyShadowInfoObserver < Sketchup::ShadowInfoObserver
15 | # def onShadowInfoChanged(shadow_info, type)
16 | # puts "onShadowInfoChanged: #{type}"
17 | # end
18 | # end
19 | #
20 | # # Attach the observer.
21 | # Sketchup.active_model.shadow_info.add_observer(MyShadowInfoObserver.new)
22 | #
23 | # @version SketchUp 6.0
24 | class Sketchup::ShadowInfoObserver
25 |
26 | # Instance Methods
27 |
28 | # The {#onShadowInfoChanged} method is invoked whenever the user alters a
29 | # setting inside the Shadows and Model Info dialogs. The type parameter
30 | # contains a number identifying which option was altered. Here are the types to
31 | # expect:
32 | #
33 | # - 0 = Time/Date sliders
34 | # - 1 = Display Shadows checkbox
35 | # - 2 = Light/Dark sliders
36 | # - 3 = Geographic Location (in Model Info > Location)
37 | # - 4 = Solar Orientation (in Model Info > Location)
38 | # - 7 = Use Sun for Shading checkbox
39 | # - 8 = Display from Edges checkbox
40 | # - 9 = Display on Ground checkbox
41 | # - 10 = Display on Faces checkbox
42 | #
43 | # @example
44 | # def onShadowInfoChanged(shadow_info, type)
45 | # puts "onShadowInfoChanged: #{type}"
46 | # end
47 | #
48 | # @param [Sketchup::ShadowInfo] shadow_info
49 | #
50 | # @param [Integer] type
51 | # A number identifying which setting was changed.
52 | #
53 | # @return [nil]
54 | #
55 | # @version SketchUp 6.0
56 | def onShadowInfoChanged(shadow_info, type)
57 | end
58 |
59 | end
60 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/Console.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # The Console class is used by SketchUp to direct $stdout and $stderr to the
5 | # Ruby Console. It is a singleton class that only has one instance available.
6 | # This instance is accessible via the SKETCHUP_CONSOLE constant.
7 | #
8 | # In SketchUp 2014 methods were added to allow developers to control the
9 | # visibility of the Ruby Console.
10 | #
11 | # Also note that in SketchUp 2014, writing to the console does not work from
12 | # within Ruby threads other than the main thread. So the following code will
13 | # not produce any output.
14 | #
15 | # @example
16 | # # By default $stdout is directed to SKETCHUP_CONSOLE.
17 | # p $stdout
18 | #
19 | # # $stdout can however be redirected so the safe way to access the
20 | # # SketchUp console is by using the SKETCHUP_CONSOLE constant.
21 | # p SKETCHUP_CONSOLE
22 | #
23 | # @example
24 | # t = Thread.new { puts 'This will not be written to the console.' }
25 | # t.join
26 | #
27 | # @version SketchUp 2014
28 | class Sketchup::Console
29 |
30 | # Instance Methods
31 |
32 | # Clears the contents of SketchUp's Ruby Console.
33 | #
34 | # @example
35 | # SKETCHUP_CONSOLE.clear
36 | #
37 | # @return true.
38 | #
39 | # @version SketchUp 2014
40 | def clear
41 | end
42 |
43 | # Hides the SketchUp Ruby Console.
44 | #
45 | # @example
46 | # SKETCHUP_CONSOLE.hide
47 | #
48 | # @return true.
49 | #
50 | # @version SketchUp 2014
51 | def hide
52 | end
53 |
54 | # Displays the SketchUp Ruby Console.
55 | #
56 | # @example
57 | # SKETCHUP_CONSOLE.show
58 | #
59 | # @return true.
60 | #
61 | # @version SketchUp 2014
62 | def show
63 | end
64 |
65 | # Returns the visibility state of the SketchUp Ruby Console.
66 | #
67 | # @example
68 | # puts SKETCHUP_CONSOLE.visible?
69 | #
70 | # @return [Boolean] true if visible, false if not.
71 | #
72 | # @version SketchUp 2014
73 | def visible?
74 | end
75 |
76 | end
77 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/OptionsProviderObserver.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # This observer interface is implemented to react to operations provider
5 | # events. What this means is that you can watch as the user changes SketchUp
6 | # options and react to them. The following {Sketchup::OptionsProviders} are
7 | # defined in the API:
8 | #
9 | # - "UnitsOptions"
10 | # - "PrintOptions"
11 | # - "PageOptions"
12 | # - "SlideshowOptions"
13 | # - "NamedOptions"
14 | #
15 | # Each of these has a list of specific options that the user can set. See the
16 | # {Sketchup::OptionsManager} and {Sketchup::OptionsProvider} classes for more
17 | # details.
18 | #
19 | # @abstract To implement this observer, create a Ruby class of this type,
20 | # override the desired methods, and add an instance of the observer to the
21 | # objects of interests.
22 | #
23 | # @example
24 | # class MyOptionsProviderObserver < Sketchup::OptionsProviderObserver
25 | # def onOptionsProviderChanged(provider, name)
26 | # puts "onOptionsProviderChanged: #{name}"
27 | # end
28 | # end
29 | #
30 | # # Detect when the end user changes their units settings.
31 | # options_provider = Sketchup.active_model.options["UnitsOptions"]
32 | # options_provider.add_observer(MyOptionsProviderObserver.new)
33 | #
34 | # @version SketchUp 6.0
35 | class Sketchup::OptionsProviderObserver
36 |
37 | # Instance Methods
38 |
39 | # The {#onOptionsProviderChanged} method is invoked when a property of an
40 | # {Sketchup::OptionsProvider} changes.
41 | #
42 | # @example
43 | # def onOptionsProviderChanged(provider, name)
44 | # puts "onOptionsProviderChanged: #{name}"
45 | # end
46 | #
47 | # @param [Sketchup::OptionsProvider] provider
48 | #
49 | # @param [String] name
50 | # The name of the specific option that was changed.
51 | #
52 | # @return [nil]
53 | #
54 | # @version SketchUp 6.0
55 | def onOptionsProviderChanged(provider, name)
56 | end
57 |
58 | end
59 |
--------------------------------------------------------------------------------
/pages/importer_options.md:
--------------------------------------------------------------------------------
1 | # @title Importer Options
2 |
3 | # Importer Options
4 |
5 | The SketchUp Ruby API provides access to several importers that are shipped with SketchUp. Lists of valid options supported by each importer are given below.
6 |
7 | # Note
8 | The option `merge_coplaner_faces` was a typo in SketchUp 2018. This option will still work in the current SketchUp, but has been changed to `merge_coplanar_faces`.
9 |
10 | ## All Importers
11 | - `show_summary` - Boolean to indicate whether to show the summary dialog.
12 |
13 | ## 3ds Max (3DS)
14 | - `units` - Specifies the import units.
15 | - values: `"model"`, `"inch"`, `"foot"`, `"yard"`, `"mile"`, `"mm"`, `"cm"`, `"m"`, or `"km"`
16 | - `merge_coplanar_faces` - Boolean to indicate whether to merge coplanar faces.
17 |
18 | ## Collada (DAE)
19 | - `validate_dae` - Boolean to indicate whether to validate the input file.
20 | - `merge_coplanar_faces` - Boolean to indicate whether to merge coplanar faces.
21 |
22 | ## Digital Elevation Model (DEM/DDF)
23 | - `max_points` - Integer to specify the number of TIN points.
24 | - `generate_texture` - Boolean to indicate whether to generate gradient textures.
25 |
26 | ## 3D Autocad (DWG/DXF)
27 | - `import_materials` - Boolean to indicate whether to import materials. Added in SU2019.
28 | - `merge_coplanar_faces` - Boolean to indicate whether to merge coplanar faces.
29 | - `orient_faces` - Boolean to indicate whether to orient faces consistently.
30 | - `preserve_origin` - Boolean to indicate whether to preserve drawing origin.
31 |
32 | ## Industry Foundation Classes (IFC)
33 | - No options are supported for this type on import.
34 |
35 | ## Google Earth (KMZ)
36 | - `validate_kmz` - Boolean to indicate whether to validate the input file.
37 | - `merge_coplanar_faces` - Boolean to indicate whether to merge coplanar faces.
38 |
39 | ## STereoLithography (STL)
40 | - `units` - Specifies the import units.
41 | - values: `"inch"`, `"feet"`, `"mm"`, `"cm"`, `"m"`
42 | - `merge_coplanar_faces` - Boolean to indicate whether to merge coplanar faces.
43 | - `preserve_origin` - Boolean to indicate whether to preserve drawing origin.
44 | - `swap_yz` - Boolean to indicate whether to swap Y and Z coordinates (Y is up).
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/PagesObserver.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # This observer interface is implemented to react to pages events.
5 | #
6 | # @abstract To implement this observer, create a Ruby class of this type, override the
7 | # desired methods, and add an instance of the observer to the objects of
8 | # interests.
9 | #
10 | # @example
11 | # # This is an example of an observer that watches the pages for new ones.
12 | # class MyPagesObserver < Sketchup::PagesObserver
13 | # def onElementAdded(pages, page)
14 | # puts "onElementAdded: #{page}"
15 | # end
16 | # end
17 | #
18 | # # Attach the observer.
19 | # Sketchup.active_model.pages.add_observer(MyPagesObserver.new)
20 | #
21 | # @version SketchUp 6.0
22 | class Sketchup::PagesObserver < Sketchup::EntitiesObserver
23 |
24 | # Instance Methods
25 |
26 | # The {#onContentsModified} method is invoked whenever the pages change.
27 | #
28 | # @example
29 | # def onContentsModified(pages)
30 | # puts "onContentsModified: #{pages}"
31 | # end
32 | #
33 | # @param [Sketchup::Pages] pages
34 | #
35 | # @return [nil]
36 | #
37 | # @version SketchUp 6.0
38 | def onContentsModified(pages)
39 | end
40 |
41 | # The {#onElementAdded} method is invoked when an element is added to a
42 | # {Sketchup::Pages} object.
43 | #
44 | # @example
45 | # def onElementAdded(pages, page)
46 | # puts "onElementAdded: #{page}"
47 | # end
48 | #
49 | # @param [Sketchup::Pages] pages
50 | #
51 | # @param [Sketchup::Page] page
52 | #
53 | # @return [nil]
54 | #
55 | # @version SketchUp 6.0
56 | def onElementAdded(pages, page)
57 | end
58 |
59 | # The {#onElementRemoved} method is invoked when an element is removed from a
60 | # {Sketchup::Pages} object.
61 | #
62 | # @example
63 | # def onElementRemoved(pages, page)
64 | # puts "onElementRemoved: #{page}"
65 | # end
66 | #
67 | # @param [Sketchup::Pages] pages
68 | #
69 | # @param [Sketchup::Page] page
70 | #
71 | # @return [nil]
72 | #
73 | # @version SketchUp 6.0
74 | def onElementRemoved(pages, page)
75 | end
76 |
77 | end
78 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionObserver.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # This observer interface is implemented to react to component definition
5 | # events.
6 | #
7 | # @abstract To implement this observer, create a Ruby class of this type,
8 | # override the desired methods, and add an instance of the observer to the
9 | # definitions of interests.
10 | #
11 | # @example
12 | # # This is an example of an observer that watches a specific definition
13 | # # for new component insertions.
14 | # class MyDefObserver < Sketchup::DefinitionObserver
15 | # def onComponentInstanceAdded(definition, instance)
16 | # puts "onComponentInstanceAdded(#{definition}, #{instance})"
17 | # end
18 | # end
19 | #
20 | # # Attach the observer
21 | # Sketchup.active_model.definitions[0].add_observer(MyDefObserver.new)
22 | #
23 | # @version SketchUp 6.0
24 | class Sketchup::DefinitionObserver < Sketchup::EntityObserver
25 |
26 | # Instance Methods
27 |
28 | # The {#onComponentInstanceAdded} method is called when a new component
29 | # instance is added to a model.
30 | #
31 | # @example
32 | # def onComponentInstanceAdded(definition, instance)
33 | # puts "onComponentInstanceAdded(#{definition}, #{instance})"
34 | # end
35 | #
36 | # @param [Sketchup::ComponentDefinition] definition
37 | # The definition of the
38 | # added instance
39 | #
40 | # @param [Sketchup::ComponentInstance] instance
41 | # The added instance
42 | #
43 | # @return [nil]
44 | #
45 | # @version SketchUp 6.0
46 | def onComponentInstanceAdded(definition, instance)
47 | end
48 |
49 | # The {#onComponentInstanceRemoved} method is called when a component
50 | # instance is removed from a model.
51 | #
52 | # @example
53 | # def onComponentInstanceRemoved(definition, instance)
54 | # puts "onComponentInstanceRemoved(#{definition}, #{instance})"
55 | # end
56 | #
57 | # @note Due to the underlying way that the SketchUp Move Tool is
58 | # implemented, this method is fired on a Move + Copy operation even
59 | # though no {Sketchup::ComponentInstance} is apparently removed.
60 | #
61 | # @param [Sketchup::ComponentDefinition] definition
62 | # The definition of the
63 | # instance removed
64 | #
65 | # @param [Sketchup::ComponentInstance] instance
66 | # The removed instance
67 | #
68 | # @return [nil]
69 | #
70 | # @version SketchUp 6.0
71 | def onComponentInstanceRemoved(definition, instance)
72 | end
73 |
74 | end
75 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/DimensionRadial.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # The DimensionRadial class represents radius and diameter dimensions on
5 | # arcs and circles.
6 | #
7 | # @version SketchUp 2014
8 | class Sketchup::DimensionRadial < Sketchup::Dimension
9 |
10 | # Instance Methods
11 |
12 | # The arc_curve method returns the ArcCurve object to which this dimension is
13 | # attached.
14 | #
15 | # @example
16 | # arc = dim.arc_curve
17 | #
18 | # @return The ArcCurve object to which the dimension is attached.
19 | #
20 | # @version SketchUp 2014
21 | def arc_curve
22 | end
23 |
24 | # The arc_curve= method is used to set the ArcCurve object to which this
25 | # dimension is attached.
26 | #
27 | # @example
28 | # dim.arc_curve = arc
29 | #
30 | # @param arc_curve
31 | # The ArcCurve object to which the dimension is to be
32 | # attached.
33 | #
34 | # @return The ArcCurve object to which the dimension was attached.
35 | #
36 | # @version SketchUp 2014
37 | def arc_curve=(arc_curve)
38 | end
39 |
40 | # The leader_break_point method returns the break point on the leader where the
41 | # dimension text is attached.
42 | #
43 | # @example
44 | # pt = dim.leader_break_point
45 | # puts "Break point is #{pt}"
46 | #
47 | # @return the leader break point
48 | #
49 | # @version SketchUp 2014
50 | def leader_break_point
51 | end
52 |
53 | # The leader_break_point= method is used to set the break point on the leader
54 | # where the dimension text is attached.
55 | #
56 | # @example
57 | # dim.leader_break_point = [10, 0, 0]
58 | #
59 | # @param point
60 | # the point to be set
61 | #
62 | # @return the point that was set
63 | #
64 | # @version SketchUp 2014
65 | def leader_break_point=(point)
66 | end
67 |
68 | # The leader_points method returns the 3 significant points along the dimension
69 | # line in world coordinates.
70 | #
71 | # @example
72 | # pts = dim.leader_points
73 | # puts "Break point is #{pts[0]}"
74 | # puts "Attach point is #{pts[1]}"
75 | # puts "Opposite point is #{pts[2]}"
76 | #
77 | # @return Array of 3 Point3d objects. Point 0: leader break point,
78 | # where the text extension attaches. Point 1: attach point,
79 | # where leader touches the arc/circle. Point 2: opposite
80 | # point, where the diameter leader touches the circle on
81 | # the opposite side.
82 | #
83 | # @version SketchUp 2014
84 | def leader_points
85 | end
86 |
87 | end
88 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/UVHelper.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # The UV Helper class contains methods allowing you to determine the location
5 | # (UV coordinates) of a texture on a face. This class is particularly useful
6 | # in determining how textures that have been manipulated using the Texture
7 | # Tweaker should appear when exported to another file type
8 | #
9 | # Use the Face.get_UVHelper method to create a UVHelper for a given face.
10 | # See the TextureWriter class as well.
11 | #
12 | # @version SketchUp 6.0
13 | class Sketchup::UVHelper
14 |
15 | # Instance Methods
16 |
17 | # The {#get_back_UVQ} method is used to get the UV texture coordinates on the
18 | # back of a face.
19 | #
20 | # @example
21 | # uv_helper = face.get_UVHelper(true, true, my_texture_writer)
22 | # face.outer_loop.vertices.each do |vert|
23 | # uvq = uv_helper.get_back_UVQ(vert.position)
24 | # # "Normalize" UVQ to UV.
25 | # # #x, #y and #z corresponds to U, V and Q respectively,
26 | # # as SketchUp re-uses the normal Point3d objects for UVQs
27 | # u = uvq.x / uvq.z
28 | # v = uvq.y / uvq.z
29 | # puts "u=#{u} v=#{v}""
30 | # end
31 | #
32 | # @note To convert UVQ coordinates to UV,
33 | # divide U and V by Q.
34 | # u = uvq.u / uvq.q
35 | # v = uvq.v / uvq.q
36 | #
37 | # @param [Geom::Point3d] point
38 | # A point on the face.
39 | #
40 | # @return [Geom::Point3d] Point where X represents U, Y represents V and Z represents Q.
41 | #
42 | # @version SketchUp 6.0
43 | def get_back_UVQ(point)
44 | end
45 |
46 | # The {#get_front_UVQ} method is used to get the UV texture coordinates on the
47 | # front of a face.
48 | #
49 | # @example
50 | # uv_helper = face.get_UVHelper(true, true, my_texture_writer)
51 | # face.outer_loop.vertices.each do |vert|
52 | # uvq = uv_helper.get_front_UVQ(vert.position)
53 | # # "Normalize" UVQ to UV.
54 | # # #x, #y and #z corresponds to U, V and Q respectively,
55 | # # as SketchUp re-uses the normal Point3d objects for UVQs
56 | # u = uvq.x / uvq.z
57 | # v = uvq.y / uvq.z
58 | # puts "u=#{u} v=#{v}""
59 | # end
60 | #
61 | # @note To convert UVQ coordinates to UV,
62 | # divide U and V by Q.
63 | # u = uvq.u / uvq.q
64 | # v = uvq.v / uvq.q
65 | #
66 | # @param [Geom::Point3d] point
67 | # A point on the face.
68 | #
69 | # @return [Geom::Point3d] Point where X represents U, Y represents V and Z represents Q.
70 | #
71 | # @version SketchUp 6.0
72 | def get_front_UVQ(point)
73 | end
74 |
75 | end
76 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/Menu.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # An interface to a menu.
5 | #
6 | # @version SketchUp 6.0
7 | class Sketchup::Menu
8 |
9 | # Instance Methods
10 |
11 | # The {#add_item} method is used to add a menu item to the specified menu.
12 | #
13 | # This method takes a block that defines the action to perform when the menu
14 | # item is selected.
15 | #
16 | # The item id that is returned can be used when adding an optional
17 | # validation procedure for the menu item.
18 | #
19 | # @example
20 | # menu = UI.menu('Plugins')
21 | # menu.add_item("Test") { puts 'Hello World' }
22 | #
23 | # @overload add_item(title, &block)
24 | #
25 | # @param [String] title
26 | # @yield A block that will be invoked when the menu item is selected.
27 | # @return [Integer] A unique integer id for the added menu item.
28 | #
29 | # @overload add_item(command)
30 | #
31 | # @param [UI::Command] command
32 | # @return [Integer] A unique integer id for the added menu item.
33 | #
34 | # @version SketchUp 6.0
35 | def add_item(*args)
36 | end
37 |
38 | # The {#add_separator} method is used to add a menu separator to a menu.
39 | #
40 | # @example
41 | # plugins_menu = UI.menu("Plugins")
42 | # plugins_menu.add_separator
43 | #
44 | # @return [nil]
45 | #
46 | # @version SketchUp 6.0
47 | def add_separator
48 | end
49 |
50 | # The {#add_submenu} method is used to add a sub-menu to a menu.
51 | #
52 | # @example
53 | # plugins_menu = UI.menu("Plugins")
54 | # submenu = plugins_menu.add_submenu("Test")
55 | # submenu.add_item("Hello World") {
56 | # UI.messagebox("Hi there!")
57 | # }
58 | #
59 | # @param [String] title
60 | # The title of the sub menu.
61 | #
62 | # @return [Sketchup::Menu] a Menu object
63 | #
64 | # @version SketchUp 6.0
65 | def add_submenu(title)
66 | end
67 |
68 | # The {#set_validation_proc} method is used to specify the menu validation
69 | # procedure. Your procedure should return either MF_ENABLED, MF_DISABLED,
70 | # MF_CHECKED, MF_UNCHECKED, or MF_GRAYED.
71 | #
72 | # @example
73 | # plugins_menu = UI.menu("Plugins")
74 | # item = plugins_menu.add_item("Test") { UI.messagebox "My Test Item"}
75 | # status = plugins_menu.set_validation_proc(item) {
76 | # if Sketchup.is_pro?
77 | # MF_ENABLED
78 | # else
79 | # MF_GRAYED
80 | # end
81 | # }
82 | #
83 | # @param [Integer] item
84 | # The numerical identifier for the menu item.
85 | #
86 | # @version SketchUp 6.0
87 | #
88 | # @yield A method that will be invoked when the menu item is
89 | # selected.
90 | def set_validation_proc(item, &block)
91 | end
92 |
93 | end
94 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/InstanceObserver.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # This observer interface is implemented to react to component instance
5 | # events.
6 | #
7 | # Note that you may also attach {Sketchup::InstanceObserver}s to
8 | # {Sketchup::Group}s.
9 | #
10 | # @abstract To implement this observer, create a Ruby class of this type,
11 | # override the desired methods, and add an instance of the observer to the
12 | # objects of interests.
13 | #
14 | # @example
15 | # # This is an example of an observer that watches a specific instance
16 | # # for open edit actions and shows a messagebox.
17 | # class MyInstanceObserver < Sketchup::InstanceObserver
18 | # def onOpen(instance)
19 | # puts "onOpen: #{instance}"
20 | # end
21 | #
22 | # def onClose(instance)
23 | # puts "onClose: #{instance}"
24 | # end
25 | # end
26 | #
27 | # # Attach the observer. (This example assumes that your first definition
28 | # # in the model contains an instance to attach the observer to. This
29 | # # example should work with a model where Sang or Bryce are present in
30 | # # the template.)
31 | # model = Sketchup.active_model
32 | # model.definitions[0].instances[0].add_observer(MyInstanceObserver.new)
33 | #
34 | # @version SketchUp 6.0
35 | class Sketchup::InstanceObserver < Sketchup::EntityObserver
36 |
37 | # Instance Methods
38 |
39 | # The {#onClose} method is called when an instance is "closed," meaning an end
40 | # user was editing a component's geometry and then exited back into the
41 | # parent's editing space.
42 | #
43 | # @example
44 | # def onClose(instance)
45 | # puts "onClose: #{instance}"
46 | # end
47 | #
48 | # @param [Sketchup::ComponentInstance] instance
49 | # The instance that was just
50 | # closed
51 | #
52 | # @return [nil]
53 | #
54 | # @version SketchUp 6.0
55 | def onClose(instance)
56 | end
57 |
58 | # The {#onOpen} method is called when an instance is "opened," meaning an end
59 | # user has double clicked on it to edit its geometry. This is particularly
60 | # useful if your plugin is dynamically drawing geometry or performing
61 | # transformations in global space, since when in "edit component" mode all
62 | # transformations and positions are returned in relation to the current
63 | # component's origin.
64 | #
65 | # This method will tell you when a user has entered edit mode, and you can
66 | # then use {Sketchup::Model#active_path} and {Sketchup::Model#edit_transform}
67 | # methods to determine any corrections you need to make to your
68 | # transformations.
69 | #
70 | # @example
71 | # def onOpen(instance)
72 | # puts "onOpen: #{instance}"
73 | # end
74 | #
75 | # @param [Sketchup::ComponentInstance] instance
76 | # The instance that was opened
77 | #
78 | # @return [nil]
79 | #
80 | # @version SketchUp 6.0
81 | def onOpen(instance)
82 | end
83 |
84 | end
85 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Layout/ConnectionPoint.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # This is the interface to a LayOut Connection Point. A
5 | # {Layout::ConnectionPoint} defines a target point to which a {Layout::Label}
6 | # or {Layout::LinearDimension} can connect.
7 | #
8 | # @example
9 | # doc = Layout::Document.open("C:/path/to/document.layout")
10 | # entity = doc.pages.first.entities.first
11 | # point = [2, 2]
12 | # # Create a Connection Point to LayOut Entity in the document
13 | # cp = Layout::ConnectionPoint.new(entity, point)
14 | # # If the entity is a [Layout::SketchUpModel], then we can use a 3D point
15 | # # in model space along with the PID of the entity in the model to make a
16 | # # deep connection.
17 | # point3D = [100, 200, 300]
18 | # pid = "1345"
19 | # cp2 = Layout::ConnectionPoint.new(entity, point3D, pid)
20 | # # This point can then be used to connect a label or linear dimension to
21 | # # the entity.
22 | # leader_type = Layout::Label::LEADER_LINE_TYPE_BEZIER
23 | # target_point = Geom::Point2d.new(1, 1)
24 | # bounds = Geom::Bounds2d.new(2, 1, 1, 1)
25 | # label = Layout::Label.new(text, leader_type, target_point, bounds)
26 | # label.connect(cp)
27 | #
28 | # @version LayOut 2018
29 | class Layout::ConnectionPoint
30 |
31 | # Instance Methods
32 |
33 | # The {#initialize} method creates a new {Layout::ConnectionPoint}.
34 | #
35 | # @example
36 | # doc = Layout::Document.open("C:/path/to/document.layout")
37 | # entity = doc.pages.first.entities.first
38 | # point = [2, 2]
39 | # # Create a Connection Point to LayOut Entity in the document
40 | # cp = Layout::ConnectionPoint.new(entity, point)
41 | #
42 | # @overload initialize(entity, point, aperture = 0.0001)
43 | #
44 | # @param [Layout::Entity] entity
45 | # @param [Geom::Point2d] point The position on the entity to connect to.
46 | # @param [Numeric] aperture The search radius to find the entity provided. If
47 | # no aperture value is provided, a default value of 0.0001 will be used.
48 | # The value provided must be greater than zero.
49 | # @return [Layout::ConnectionPoint]
50 | #
51 | # @raise [ArgumentError] if point passed in is not within the bounds of entity
52 | # @raise [ArgumentError] if aperture is not greater than zero
53 | # @raise [ArgumentError] if entity is not in a document
54 | #
55 | # @overload initialize(model, point3d, pid = nil)
56 | #
57 | # @param [Layout::SketchUpModel] model
58 | # @param [Geom::Point3d] point3d The 3D point in model space to connect to.
59 | # @param [String, nil] pid The persistent ID of the entity to connect to in
60 | # the model, if any.
61 | # @return [Layout::ConnectionPoint]
62 | #
63 | # @raise [ArgumentError] if entity is not in a document
64 | # @raise [ArgumentError] if the provided pid does not exist in the model
65 | #
66 | # @version LayOut 2018
67 | def initialize(*args)
68 | end
69 |
70 | end
71 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # @title SketchUp Ruby API
2 |
3 | # SketchUp Ruby API
4 |
5 | The SketchUp Ruby API allows you to interact with SketchUp models and the SketchUp application. It is available from within SketchUp, it cannot be used by itself.
6 |
7 |
8 | Get started with the Ruby API Overview.
9 |
10 |
11 | Visit our [SketchUp Developer Center](https://developer.sketchup.com) for more information and resources on SketchUp's APIs.
12 |
13 | ## LayOut API
14 |
15 | As of SketchUp 2018 you can also create and manipulate LayOut documents. For more information refer to the {file:LayOut.md LayOut API Overview}.
16 |
17 | Currently the LayOut Ruby API is only available from SketchUp.
18 |
19 | ## Examples and Tutorials
20 |
21 | ### Getting Started
22 |
23 | To get you started we have a collection of examples of tutorials. These will take you through various common scenarios and concepts of the SketchUp API.
24 |
25 | https://github.com/SketchUp/sketchup-ruby-api-tutorials
26 |
27 | ### Ruby C Extensions within SketchUp
28 |
29 | Ruby itself allows you to work with Ruby code via C (and C++). This allows for more complex functionality and possible performance improvements. We provide examples on how to create Ruby C Extensions that work with various SketchUp versions and platforms:
30 |
31 | https://github.com/SketchUp/ruby-c-extension-examples
32 |
33 | ## Debugging
34 |
35 | To make debugging SketchUp Ruby extensions easier we have a Ruby debugger interface that can be added to your SketchUp installation. This will let you use the debugging functionality of IDEs/editors that support the Ruby Debug protocol:
36 |
37 | https://github.com/SketchUp/sketchup-ruby-debugger
38 |
39 | We also have a guide on setting up RubyMine as an example of how you can set up your debugger:
40 |
41 | https://github.com/SketchUp/sketchup-ruby-api-tutorials/wiki/RubyMine-Debugger-Setup
42 |
43 | ## Testing
44 |
45 | The standard testing frameworks for Ruby usually assume your tests are run from Ruby's console interpreter. This pose a problem when you want to set up unit tests for your code that needs to run within SketchUp.
46 |
47 | To address this we created TestUp, a wrapper on top of {https://github.com/seattlerb/minitest Minitest} that works within SketchUp along with a GUI interface to manage your tests.
48 |
49 | https://github.com/SketchUp/testup-2
50 |
51 | ## Tools
52 |
53 | Give your IDE insight to the SketchUp Ruby API by feeding it stubs:
54 |
55 | https://github.com/SketchUp/ruby-api-stubs
56 |
57 | As an example of how to set up your IDE we created an example that describe the process for RubyMine:
58 |
59 | https://github.com/SketchUp/sketchup-ruby-api-tutorials/wiki/RubyMine-Project-Setup#making-the-ide-sketchup-api-aware
60 |
61 | VSCode example:
62 |
63 | https://github.com/SketchUp/sketchup-extension-vscode-project
64 |
65 | ## Documentation
66 |
67 | If you find a typo, unclear description etc in the documentation, please log a new issue in the issue tracker for our APIs: https://github.com/SketchUp/api-issue-tracker/issues
68 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/OverlaysManager.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # An overlay added to a model is invalidated once it's removed from the model.
5 | # It cannot be re-added or added to another model. Create another unique
6 | # instance for that.
7 | #
8 | # Contains the registered overlays for a model along with methods to manage
9 | # them.
10 | #
11 | # A model can not have multiple overlays with the same id.
12 | #
13 | # @api Overlays
14 | #
15 | # @example
16 | # Sketchup.active_model.overlays.each { |overlay|
17 | # puts "#{overlay.name} (#{overlay.overlay_id}) Enabled: #{overlay.enabled?}"
18 | # }
19 | #
20 | # @see Sketchup::Overlay
21 | # Documentation for overlays for more details.
22 | #
23 | # @version SketchUp 2023.0
24 | class Sketchup::OverlaysManager
25 |
26 | # Includes
27 |
28 | include Enumerable
29 |
30 | # Instance Methods
31 |
32 | #
33 | # @api Overlays
34 | #
35 | # @example
36 | # overlay = Sketchup.active_model.overlays[0]
37 | #
38 | # @return [Sketchup::Overlay]
39 | #
40 | # @version SketchUp 2023.0
41 | def [](index)
42 | end
43 | alias_method :at, :[]
44 |
45 | #
46 | # @api Overlays
47 | #
48 | # @example
49 | # class ExampleOverlay < Sketchup::Overlay
50 | # def initialize
51 | # super('example_inc.my_overlay', 'Example Overlay')
52 | # end
53 | # end
54 | #
55 | # overlay = ExampleOverlay.new
56 | # Sketchup.active_model.overlays.add(overlay)
57 | #
58 | # @raise [ArgumentError] If the overlay is already added to a model.
59 | #
60 | # @return [Boolean] +false+ if an overlay with the same id already exists.
61 | #
62 | # @version SketchUp 2023.0
63 | def add(service)
64 | end
65 |
66 | #
67 | # @api Overlays
68 | #
69 | # @example
70 | # Sketchup.active_model.overlays.each { |overlay|
71 | # puts "#{overlay.name} (#{overlay.overlay_id}) Enabled: #{overlay.enabled?}"
72 | # }
73 | #
74 | # @return [nil]
75 | #
76 | # @version SketchUp 2023.0
77 | #
78 | # @yieldparam [Sketchup::Overlay] overlay
79 | def each
80 | end
81 |
82 | #
83 | # @api Overlays
84 | #
85 | # @example
86 | # class ExampleOverlay < Sketchup::Overlay
87 | # def initialize
88 | # super('example_inc.my_overlay', 'Example Overlay')
89 | # end
90 | # end
91 | #
92 | # overlay = ExampleOverlay.new
93 | # Sketchup.active_model.overlays.add(overlay)
94 | #
95 | # Sketchup.active_model.overlays.remove(overlay)
96 | #
97 | # @return [Boolean]
98 | #
99 | # @version SketchUp 2023.0
100 | def remove(service)
101 | end
102 |
103 | #
104 | # @api Overlays
105 | #
106 | # @example
107 | # num_overlays = Sketchup.active_model.overlays.size
108 | #
109 | # @return [Integer]
110 | #
111 | # @version SketchUp 2023.0
112 | def size
113 | end
114 | alias_method :length, :size
115 |
116 | end
117 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Layout/ReferenceEntity.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # An entity that represents the data inserted from an external file.
5 | #
6 | # @example
7 | # doc = Layout::Document.open("C:/path/to/document.layout")
8 | # reference_entity = doc.pages.first.entities.first
9 | # clip_mask = reference_entity.clip_mask
10 | # if clip_mask.is_a?(Layout::Rectangle)
11 | # point1 = Geom::Point2d.new(1, 1)
12 | # point2 = Geom::Point2d.new(2, 2)
13 | # bounds = [point1, point2]
14 | # reference_entity.clip_mask = Layout::Ellipse.new(bounds)
15 | # end
16 | #
17 | # @version LayOut 2023.0
18 | class Layout::ReferenceEntity < Layout::Entity
19 |
20 | # Instance Methods
21 |
22 | # The {#clip_mask} method returns the clip mask of the {Layout::ReferenceEntity}, or
23 | # +nil+ if it does not have a clip mask.
24 | #
25 | # @example
26 | # doc = Layout::Document.open("C:/path/to/document.layout")
27 | # reference_entity = doc.pages.first.entities.first
28 | # clip_mask = image.clip_mask
29 | #
30 | # @return [Layout::Entity] The clip mask can be a {Layout::Path},
31 | # {Layout::Rectangle}, or {Layout::Ellipse}.
32 | #
33 | # @version LayOut 2023.0
34 | def clip_mask
35 | end
36 |
37 | # The {#clip_mask=} method sets the clip mask of the {Layout::ReferenceEntity}. clip_mask
38 | # can be a {Layout::Rectangle}, {Layout::Ellipse}, or {Layout::Path}, or +nil+,
39 | # and it must not currently exist in a {Layout::Document}, or {Layout::Group}.
40 | #
41 | # @example
42 | # doc = Layout::Document.open("C:/path/to/document.layout")
43 | # reference_entity = doc.pages.first.entities.first
44 | # point1 = Geom::Point2d.new(1, 1)
45 | # point2 = Geom::Point2d.new(2, 2)
46 | # bounds = [point1, point2]
47 | # clip_mask = Layout::Rectangle.new(bounds)
48 | # reference_entity.clip_mask = clip_mask
49 | #
50 | # @param [Layout::Entity, nil] clip_mask
51 | # The clip mask can be a {Layout::Path},
52 | # {Layout::Rectangle}, {Layout::Ellipse}, or +nil+.
53 | #
54 | # @raise [ArgumentError] if clip mask is already in a {Layout::Document} or
55 | # {Layout::Group}
56 | #
57 | # @raise [ArgumentError] if clip mask is not a {Layout::Path},
58 | # {Layout::Rectangle}, or {Layout::Ellipse}
59 | #
60 | # @raise [LockedLayerError] if the {Layout::ReferenceEntity} is on a locked {Layout::Layer}
61 | #
62 | # @raise [LockedEntityError] if the {Layout::ReferenceEntity} is locked
63 | #
64 | # @version LayOut 2023.0
65 | def clip_mask=(clip_mask)
66 | end
67 |
68 | # The {#entities} method returns the {Layout::Group} that represents the
69 | # {Layout::ReferenceEntity} in its exploded form.
70 | #
71 | # @example
72 | # doc = Layout::Document.open("C:/path/to/document.layout")
73 | # reference_entity = doc.pages.first.entities.first
74 | # entities = reference_entity.entities
75 | #
76 | # @return [Layout::Group]
77 | #
78 | # @version LayOut 2023.0
79 | def entities
80 | end
81 |
82 | end
83 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Layout/Image.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # A raster image entity.
5 | #
6 | # @example
7 | # image = Layout::Image.new("my_image.png", [[1, 1], [3, 3]])
8 | # clip_mask = image.clip_mask
9 | # if clip_mask.is_a?(Layout::Rectangle)
10 | # point1 = Geom::Point2d.new(1, 1)
11 | # point2 = Geom::Point2d.new(2, 2)
12 | # bounds = [point1, point2]
13 | # image.clip_mask = Layout::Ellipse.new(bounds)
14 | # end
15 | #
16 | # @version LayOut 2018
17 | class Layout::Image < Layout::Entity
18 |
19 | # Instance Methods
20 |
21 | # The {#clip_mask} method returns the clip mask of the {Layout::Image}, or
22 | # +nil+ if it does not have a clip mask.
23 | #
24 | # @example
25 | # image = Layout::Image.new("my_image.png", [[1, 1], [3, 3]])
26 | # clip_mask = image.clip_mask
27 | #
28 | # @return [Layout::Entity] The clip mask can be a {Layout::Path},
29 | # {Layout::Rectangle}, or {Layout::Ellipse}.
30 | #
31 | # @version LayOut 2018
32 | def clip_mask
33 | end
34 |
35 | # The {#clip_mask=} method sets the clip mask of the {Layout::Image}. clip_mask
36 | # can be a {Layout::Rectangle}, {Layout::Ellipse}, or {Layout::Path}, or +nil+,
37 | # and it must not currently exist in a {Layout::Document}, or {Layout::Group}.
38 | #
39 | # @example
40 | # image = Layout::Image.new("my_image.png", [[1, 1], [3, 3]])
41 | # point1 = Geom::Point2d.new(1, 1)
42 | # point2 = Geom::Point2d.new(2, 2)
43 | # bounds = [point1, point2]
44 | # clip_mask = Layout::Rectangle.new(bounds)
45 | # image.clip_mask = clip_mask
46 | #
47 | # @note +clip_mask+ may be +nil+ as of LayOut 2020.1.
48 | #
49 | # @param [Layout::Entity, nil] clip_mask
50 | # The clip mask can be a {Layout::Path},
51 | # {Layout::Rectangle}, {Layout::Ellipse}, or +nil+.
52 | #
53 | # @raise [ArgumentError] if clip mask is already in a {Layout::Document} or
54 | # {Layout::Group}
55 | #
56 | # @raise [ArgumentError] if clip mask is not a {Layout::Path},
57 | # {Layout::Rectangle}, or {Layout::Ellipse}
58 | #
59 | # @raise [LockedLayerError] if the {Layout::Image} is on a locked {Layout::Layer}
60 | #
61 | # @raise [LockedEntityError] if the {Layout::Image} is locked
62 | #
63 | # @version LayOut 2018
64 | def clip_mask=(clip_mask)
65 | end
66 |
67 | # The {#initialize} method creates a new {Layout::Image} from a given image
68 | # file.
69 | #
70 | # @example
71 | # image = Layout::Image.new("my_image.png", [[1, 1], [3, 3]])
72 | #
73 | # @param [String] path
74 | # The path to the file
75 | #
76 | # @param [Geom::Bounds2d] bounds
77 | #
78 | # @raise [ArgumentError] if bounds are zero size
79 | #
80 | # @raise [ArgumentError] if there was an error reading the image file, such as
81 | # the file name being invalid
82 | #
83 | # @raise [RuntimeError] if there was an error allocating memory for the image
84 | #
85 | # @return [Layout::Image]
86 | #
87 | # @version LayOut 2018
88 | def initialize(path, bounds)
89 | end
90 |
91 | end
92 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Geom/OrientedBounds2d.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # The OrientedBounds2d class is a bounding box represented by four
5 | # {Geom::Point2d} objects, upper left, upper right, lower left and lower right
6 | # positions.
7 | #
8 | # @version LayOut 2018
9 | class Geom::OrientedBounds2d
10 |
11 | # Instance Methods
12 |
13 | # The {#==} method checks to see if the two {Geom::OrientedBounds2d}s are
14 | # equal. This checks whether the point values are the same.
15 | #
16 | # @example
17 | # entity.bounds == entity.untransformed_bounds
18 | #
19 | # @param [Geom::OrientedBounds2d] other
20 | #
21 | # @return [Boolean]
22 | #
23 | # @version LayOut 2018
24 | def ==(other)
25 | end
26 |
27 | # The {#lower_left} method returns the {Geom::Point2d} of the lower left
28 | # corner of the {Geom::OrientedBounds2d}.
29 | #
30 | # @example
31 | # doc = Layout::Document.open("C:/path/to/document.layout")
32 | # entity = doc.shared_enities.first
33 | # bounds = entity.drawing_bounds
34 | # l_l = bounds.lower_left
35 | #
36 | # @return [Geom::Point2d]
37 | #
38 | # @version LayOut 2018
39 | def lower_left
40 | end
41 |
42 | # The {#lower_right} method returns the {Geom::Point2d} of the lower right
43 | # corner of the {Geom::OrientedBounds2d}.
44 | #
45 | # @example
46 | # doc = Layout::Document.open("C:/path/to/document.layout")
47 | # entity = doc.shared_enities.first
48 | # bounds = entity.drawing_bounds
49 | # l_r = bounds.lower_right
50 | #
51 | # @return [Geom::Point2d]
52 | #
53 | # @version LayOut 2018
54 | def lower_right
55 | end
56 |
57 | # The {#to_a} method returns an array which contains the {Geom::Point2d} that
58 | # define the {Geom::OrientedBounds2d}.
59 | #
60 | # @example
61 | # doc = Layout::Document.open("C:/path/to/document.layout")
62 | # entity = doc.shared_enities.first
63 | # bounds = entity.drawing_bounds
64 | # bounds.to_a.each { |point| p point.to_s }
65 | #
66 | # @return [Array(Geom::Point2d, Geom::Point2d, Geom::Point2d, Geom::Point2d)]
67 | #
68 | # @version LayOut 2018
69 | def to_a
70 | end
71 |
72 | # The {#upper_left} method returns the {Geom::Point2d} of the upper left corner
73 | # of the {Geom::OrientedBounds2d}.
74 | #
75 | # @example
76 | # doc = Layout::Document.open("C:/path/to/document.layout")
77 | # entity = doc.shared_enities.first
78 | # bounds = entity.drawing_bounds
79 | # u_l = bounds.upper_left
80 | #
81 | # @return [Geom::Point2d]
82 | #
83 | # @version LayOut 2018
84 | def upper_left
85 | end
86 |
87 | # The {#upper_right} method returns the {Geom::Point2d} of the upper right
88 | # corner of the {Geom::OrientedBounds2d}.
89 | #
90 | # @example
91 | # doc = Layout::Document.open("C:/path/to/document.layout")
92 | # entity = doc.shared_enities.first
93 | # bounds = entity.drawing_bounds
94 | # u_r = bounds.upper_right
95 | #
96 | # @return [Geom::Point2d]
97 | #
98 | # @version LayOut 2018
99 | def upper_right
100 | end
101 |
102 | end
103 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/Licensing/ExtensionLicense.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # The Sketchup::Licensing::ExtensionLicense class is used to store extension
5 | # license information. An instance of this class is returned by
6 | # Sketchup::Licensing.get_extension_license. Note that this is a temporary
7 | # object representing the extension licensing state for the moment it was
8 | # returned. It will not reflect any licensing state changes that may occur.
9 | #
10 | # @version SketchUp 2015
11 | class Sketchup::Licensing::ExtensionLicense
12 |
13 | # Instance Methods
14 |
15 | # The days_remaining method is used to get the number of days remaining until
16 | # license expiration.
17 | #
18 | # @example
19 | # ext_id = "4e215280-dd23-40c4-babb-b8a8dd29d5ee"
20 | # ext_lic = Sketchup::Licensing.get_extension_license(ext_id)
21 | # if ext_lic.days_remaining != 0
22 | # puts "The license will expire in #{ext_lic.days_remaining} days."
23 | # end
24 | #
25 | # @return Integer - Number of days until license expiration. Zero
26 | # if a permanent license or not licensed.
27 | #
28 | # @version SketchUp 2015
29 | def days_remaining
30 | end
31 |
32 | # The error_description method is used to obtain error information in case of
33 | # failure to acquire a license. This is meant to aid in debugging only.
34 | # Extensions should not rely on any exact error description.
35 | #
36 | # @example
37 | # ext_id = "4e215280-dd23-40c4-babb-b8a8dd29d5ee"
38 | # ext_lic = Sketchup::Licensing.get_extension_license(ext_id)
39 | # if !ext_lic.licensed?
40 | # puts ext_lic.error_description
41 | # end
42 | #
43 | # @return String - error description.
44 | #
45 | # @version SketchUp 2015
46 | def error_description
47 | end
48 |
49 | # The licensed? method is used to decide whether the extension is licensed to
50 | # run or not.
51 | #
52 | # @example
53 | # ext_id = "4e215280-dd23-40c4-babb-b8a8dd29d5ee"
54 | # ext_lic = Sketchup::Licensing.get_extension_license(ext_id)
55 | # if ext_lic.licensed?
56 | # puts "Extension is licensed."
57 | # end
58 | #
59 | # @return [Boolean] Boolean - true if the extension is allowed to run, false
60 | # if it is not licensed and should quit.
61 | #
62 | # @version SketchUp 2015
63 | def licensed?
64 | end
65 |
66 | # The state method returns a constant indicating the specific licensing state.
67 | # These should be used for informational purposes only and not to decide if
68 | # the extension is licensed to run. For that, please use the licensed? method.
69 | #
70 | # @example
71 | # ext_id = "4e215280-dd23-40c4-babb-b8a8dd29d5ee"
72 | # ext_lic = Sketchup::Licensing.get_extension_license(ext_id)
73 | # if ext_lic.state == Sketchup::Licensing::TRIAL_EXPIRED
74 | # puts "Trial period has expired."
75 | # end
76 | #
77 | # @return Integer - One of Sketchup::Licensing::LICENSED,
78 | # Sketchup::Licensing::EXPIRED, Sketchup::Licensing::TRIAL,
79 | # Sketchup::Licensing::TRIAL_EXPIRED,
80 | # Sketchup::Licensing::NOT_LICENSED
81 | #
82 | # @version SketchUp 2015
83 | def state
84 | end
85 |
86 | end
87 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/LineStyles.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # Provides access to the different line style objects in the model.
5 | #
6 | # @version SketchUp 2019
7 | class Sketchup::LineStyles < Sketchup::Entity
8 |
9 | # Includes
10 |
11 | include Enumerable
12 |
13 | # Instance Methods
14 |
15 | # The {#[]} method lets you retrieve a line style by name or index.
16 | #
17 | # The {#at} method is an alias of {#[]}.
18 | #
19 | # @example
20 | # solid_style = Sketchup.active_model.line_styles["Solid Basic"]
21 | # line_style = Sketchup.active_model.line_styles[1]
22 | #
23 | # @overload [](name)
24 | #
25 | # @param [String] name The name of the line style to retrieve.
26 | #
27 | # @overload [](index)
28 | #
29 | # @param [Integer] index The index of the line style to retrieve.
30 | #
31 | # @raise [IndexError] If index is out of bounds.
32 | #
33 | # @return [Sketchup::LineStyle, nil] The line style retrieved. +nil+ if the name
34 | # couldn't be retrieved.
35 | #
36 | # @version SketchUp 2019
37 | def [](arg)
38 | end
39 |
40 | # The {#[]} method lets you retrieve a line style by name or index.
41 | #
42 | # The {#at} method is an alias of {#[]}.
43 | #
44 | # @example
45 | # solid_style = Sketchup.active_model.line_styles["Solid Basic"]
46 | # line_style = Sketchup.active_model.line_styles[1]
47 | #
48 | # @overload [](name)
49 | #
50 | # @param [String] name The name of the line style to retrieve.
51 | #
52 | # @overload [](index)
53 | #
54 | # @param [Integer] index The index of the line style to retrieve.
55 | #
56 | # @raise [IndexError] If index is out of bounds.
57 | #
58 | # @return [Sketchup::LineStyle, nil] The line style retrieved. +nil+ if the name
59 | # couldn't be retrieved.
60 | #
61 | # @version SketchUp 2019
62 | def at(arg)
63 | end
64 |
65 | # The {#each} method is used to iterate through all the line styles.
66 | #
67 | # @example
68 | # line_styles = Sketchup.active_model.line_styles
69 | # line_styles.each{ |line_style| p line_style.name }
70 | #
71 | # @return [nil]
72 | #
73 | # @version SketchUp 2019
74 | #
75 | # @yieldparam [Sketchup::LineStyle] linestyle
76 | def each
77 | end
78 |
79 | # The {#names} method return the support line styles as strings.
80 | #
81 | # @example
82 | # Sketchup.active_model.line_styles.names
83 | #
84 | # @return [Array]
85 | #
86 | # @version SketchUp 2019
87 | def names
88 | end
89 |
90 | # The {#size} method returns the number of line styles that SketchUp supports.
91 | #
92 | # @example
93 | # line_styles = Sketchup.active_model.line_styles
94 | # line_styles.size
95 | #
96 | # @return [Integer] The count of line styles.
97 | #
98 | # @version SketchUp 2019
99 | def size
100 | end
101 | alias_method :length, :size
102 |
103 | # The {#to_a} method returns an array of all the line styles.
104 | #
105 | # @example
106 | # line_styles = Sketchup.active_active_model.line_styles.to_a
107 | #
108 | # @return [Array] Containing all the line style objects.
109 | #
110 | # @version SketchUp 2019
111 | def to_a
112 | end
113 |
114 | end
115 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/Classifications.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # The Classifications class is a container/manager for all classifications in
5 | # a model.
6 | #
7 | # @version SketchUp 2015
8 | class Sketchup::Classifications
9 |
10 | # Includes
11 |
12 | include Enumerable
13 |
14 | # Instance Methods
15 |
16 | # The [] method is used to get a classification schema by name or index.
17 | #
18 | # @example
19 | # # Get schema by name:
20 | # schema = Sketchup.active_model.classifications["IFC 2x3"]
21 | #
22 | # # Get schema by index:
23 | # schema = Sketchup.active_model.classifications[1]
24 | #
25 | # @param index_or_name
26 | # The index or name of the ClassificationSchema object.
27 | #
28 | # @return schema - a ClassificationSchema object if
29 | # successful, otherwise nil.
30 | #
31 | # @version SketchUp 2015
32 | def [](index_or_name)
33 | end
34 |
35 | # The {#each} method is used to iterate through loaded classification schemas.
36 | #
37 | # @example
38 | # Sketchup.active_model.classifications.each { |schema|
39 | # puts schema.name
40 | # }
41 | #
42 | # @return [nil]
43 | #
44 | # @version SketchUp 2015
45 | #
46 | # @yieldparam [Sketchup::ClassificationSchema] schema
47 | def each
48 | end
49 |
50 | # The keys method is used to get a list of keys in the Classifications class,
51 | # which are the same as the names of the schemas.
52 | #
53 | # @example
54 | # schema_names = Sketchup.active_model.classifications.keys
55 | #
56 | # @return keys - Array of string keys
57 | #
58 | # @version SketchUp 2015
59 | def keys
60 | end
61 |
62 | # The {#length} method returns the number of loaded classification schemas.
63 | #
64 | # @example
65 | # Sketchup.active_model.classifications.length
66 | #
67 | # @return [Integer]
68 | #
69 | # @see #size
70 | #
71 | # @version SketchUp 2015
72 | def length
73 | end
74 |
75 | # The load_schema method is used to load a classification schema into a
76 | # model.
77 | #
78 | # @example
79 | # c = Sketchup.active_model.classifications
80 | # file = Sketchup.find_support_file('IFC 4.skc', 'Classifications')
81 | # status = c.load_schema(file) if !file.nil?
82 | #
83 | # @param file
84 | # Full path to the schema file
85 | #
86 | # @return True if successful.
87 | #
88 | # @version SketchUp 2015
89 | def load_schema(file)
90 | end
91 |
92 | # The {#size} method returns the number of loaded classification schemas.
93 | #
94 | # @example
95 | # Sketchup.active_model.classifications.size
96 | #
97 | # @return [Integer]
98 | #
99 | # @see #length
100 | #
101 | # @version SketchUp 2015
102 | def size
103 | end
104 |
105 | # The unload_schema method is used to unload a classification schema that was
106 | # previously loaded into a model.
107 | #
108 | # @example
109 | # c = Sketchup.active_model.classifications
110 | # status = c.unload_schema('IFC 2x3')
111 | #
112 | # @param schema_name
113 | # Name of the schema to unload
114 | #
115 | # @return True if successful.
116 | #
117 | # @version SketchUp 2015
118 | def unload_schema(schema_name)
119 | end
120 |
121 | end
122 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Geom/LatLong.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # The LatLong class contains various methods for creating and manipulating
5 | # latitude and longitude coordinates.
6 | #
7 | # @version SketchUp 6.0
8 | class Geom::LatLong
9 |
10 | # Instance Methods
11 |
12 | # The new method creates a LatLong object.
13 | #
14 | # @example
15 | # ll = [40.01700, 105.28300]
16 | # latlong = Geom::LatLong.new(ll)
17 | # if (latlong)
18 | # UI.messagebox(latlong)
19 | # else
20 | # UI.messagebox("Failure")
21 | # end
22 | #
23 | # @overload initialize
24 | #
25 | # @return [Geom::LatLong]
26 | #
27 | # @overload initialize(latlong)
28 | #
29 | # @param [Geom::LatLong] latlong
30 | # @return [Geom::LatLong]
31 | #
32 | # @overload initialize(latlong_array)
33 | #
34 | # @param [Array(Numeric, Numeric)] latlong_array
35 | # @return [Geom::LatLong]
36 | #
37 | # @overload initialize(lat, long)
38 | #
39 | # @param [Numeric] lat
40 | # @param [Numeric] long
41 | # @return [Geom::LatLong]
42 | #
43 | # @version SketchUp 6.0
44 | def initialize(*args)
45 | end
46 |
47 | # The Latitude method retrieves the latitude coordinate from a LatLong object.
48 | #
49 | # @example
50 | # ll = [40.01700, 105.28300]
51 | # latlong = Geom::LatLong.new(ll)
52 | # latitude = latlong.latitude
53 | # if (latitude)
54 | # UI.messagebox(latitude)
55 | # else
56 | # UI.messagebox("Failure")
57 | # end
58 | #
59 | # @return [Float] a latitude coordinate value
60 | #
61 | # @version SketchUp 6.0
62 | def latitude
63 | end
64 |
65 | # The Latitude method retrieves the longitude coordinate from a LatLong
66 | # object.
67 | #
68 | # @example
69 | # ll = [40.01700, 105.28300]
70 | # latlong = Geom::LatLong.new(ll)
71 | # longitude = latlong.longitude
72 | # if (longitude)
73 | # UI.messagebox(longitude)
74 | # else
75 | # UI.messagebox("Failure")
76 | # end
77 | #
78 | # @return [Float] a latitude coordinate value
79 | #
80 | # @version SketchUp 6.0
81 | def longitude
82 | end
83 |
84 | # The {#to_a} method converts a LatLong object to an array of two values.
85 | #
86 | # @example
87 | # latlong = Geom::LatLong.new([40.01700, 105.28300])
88 | # array = latlong.to_a
89 | #
90 | # @return [Array(Float, Float)] an array of latitude and longitude
91 | #
92 | # @version SketchUp 6.0
93 | def to_a
94 | end
95 |
96 | # The {#to_s} method converts a LatLong object to a {String}.
97 | #
98 | # @example
99 | # latlong = Geom::LatLong.new([40.01700, 105.28300])
100 | # string = latlong.to_s
101 | #
102 | # @return [String]
103 | #
104 | # @version SketchUp 6.0
105 | def to_s
106 | end
107 |
108 | # The to_utm method converts a LatLong object to a UTM object.
109 | #
110 | # @example
111 | # ll = [40.01700, 105.28300]
112 | # latlong = Geom::LatLong.new(ll)
113 | # utm = latlong.to_utm
114 | # if (utm)
115 | # UI.messagebox(utm)
116 | # else
117 | # UI.messagebox("Failure")
118 | # end
119 | #
120 | # @return [Geom::UTM]
121 | #
122 | # @version SketchUp 6.0
123 | def to_utm
124 | end
125 |
126 | end
127 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/LanguageHandler.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # The LanguageHandler class contains methods used to help make SketchUp
5 | # extensions easier to localize across different languages. It looks for
6 | # translated resources within the Resources folder in the extension's directory
7 | # structure. All translated resources should be located within the appropriate
8 | # language folder and encoded in UTF-8. The strings file should include
9 | # "key"="value" string pairs in the following format:
10 | #
11 | # language code gocorp_swiveldriver/Resources/fr/swiveldriver.strings
12 | # gocorp_swiveldriver/Resources/es/swiveldriver.strings
13 | #
14 | # @example Example code that uses LanguageHandler:
15 | # # Create a global language handler object
16 | # swiveldriver_lang_handler = LanguageHandler.new('swiveldriver.strings')
17 | #
18 | # # Get localized string
19 | # localizedStr = swiveldriver_lang_handler.GetString('String 1')
20 | #
21 | # @example
22 | # "String 1"="Localized String 1";
23 | # "String 2"="Localized String 2";
24 | #
25 | # @example Here's an example extension directory structure:
26 | # gocorp_swiveldriver.rb <- creates the SketchupExtension instance
27 | # gocorp_swiveldriver/
28 | # gocorp_swiveldriver/Resources/
29 | # gocorp_swiveldriver/Resources/en/swiveldriver.strings <- OPTIONAL localization files by
30 | #
31 | # @version SketchUp 2014
32 | class LanguageHandler
33 |
34 | # Instance Methods
35 |
36 | # Looks up and returns the localized version of a given string, based on the
37 | # language SketchUp is currently running in, and the available translations
38 | # in the Resources folder.
39 | #
40 | # @example
41 | # swiveldriver_lang_handler = LanguageHandler.new('swiveldriver.strings')
42 | # localized_string = swiveldriver_lang_handler['String 1']
43 | #
44 | # @param [String] key
45 | # The key for the string to be retrieved.
46 | #
47 | # @return [String] the localized string.
48 | #
49 | # @version SketchUp 2014
50 | def [](key)
51 | end
52 |
53 | # The new method is used to create a new LanguageHandler object.
54 | #
55 | # @example
56 | # swiveldriver_lang_handler = LanguageHandler.new('swiveldriver.strings')
57 | #
58 | # @param [String] filename
59 | # The name of the file that contains the localized strings
60 | # with their keys in UTF-8 encoding.
61 | #
62 | # @return [LanguageHandler] the new LanguageHandler object
63 | #
64 | # @version SketchUp 2014
65 | def initialize(filename)
66 | end
67 |
68 | # Returns a string containing the path to the given filename if it can be found
69 | # in the Resources folder.
70 | #
71 | # @example
72 | # swiveldriver_lang_handler = LanguageHandler.new('swiveldriver.strings')
73 | # image = swiveldriver_lang_handler.resource_path('fancy_image.png')
74 | #
75 | # @return [String] the location of the file in the Resources folder.
76 | #
77 | # @version SketchUp 2014
78 | def resource_path
79 | end
80 |
81 | # Returns a Hash object containing the localization dictionary.
82 | #
83 | # @example
84 | # swiveldriver_lang_handler = LanguageHandler.new('swiveldriver.strings')
85 | # hash = swiveldriver_lang_handler.strings
86 | #
87 | # @return [Hash] the localization dictionary.
88 | #
89 | # @version SketchUp 2014
90 | def strings
91 | end
92 |
93 | end
94 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/ExtensionsManager.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # The ExtensionsManager class provides a way of accessing the
5 | # SketchupExtensions that have been registered via the
6 | # Sketchup.register_extension method.
7 | #
8 | # There is only one ExtensionsManager available. You access it via the
9 | # Sketchup.extensions method.
10 | #
11 | # @version SketchUp 8.0 M2
12 | class Sketchup::ExtensionsManager
13 |
14 | # Includes
15 |
16 | include Enumerable
17 |
18 | # Instance Methods
19 |
20 | # The [] method is used to get an extension by name, index or ID.
21 | #
22 | # @example
23 | # manager = Sketchup.extensions
24 | # extension = manager[1]
25 | # if (extension)
26 | # puts extension.name
27 | # else
28 | # puts "No Extensions installed"
29 | # end
30 | #
31 | # # You can also get extensions by name.
32 | # solarnorth = manager['Solar North Toolbar']
33 | #
34 | # # You can also get extensions by ID.
35 | # my_extension = manager['2475A758-6503-46D5-AC5E-16AEA0A3162A']
36 | #
37 | # @note Index starts at 1.
38 | #
39 | # @param [Integer, String] index_or_name
40 | # The index, name or ID of the SketchupExtension object.
41 | #
42 | # @return [SketchupExtension, nil]
43 | #
44 | # @version SketchUp 8.0 M2
45 | def [](index_or_name)
46 | end
47 |
48 | #
49 | # @example
50 | # manager = Sketchup.extensions
51 | # number = manager.count
52 | #
53 | # @note Since SketchUp 2014 the count method is inherited from Ruby's
54 | # +Enumerable+ mix-in module. Prior to that the {#count} method is an alias
55 | # for {#length}.
56 | #
57 | # @return [Integer]
58 | #
59 | # @see #length
60 | #
61 | # @version SketchUp 8.0 M2
62 | def count
63 | end
64 |
65 | # The {#each} method is used to iterate through extensions.
66 | #
67 | # @example
68 | # manager = Sketchup.extensions
69 | # # Retrieves each extension
70 | # manager.each { |extension| puts extension.name }
71 | #
72 | # @return [nil]
73 | #
74 | # @version SketchUp 8.0 M2
75 | #
76 | # @yieldparam [SketchupExtension] extension
77 | def each
78 | end
79 |
80 | # The keys method is used to get a list of keys in the ExtensionsManager,
81 | # which are the same as the names of the extensions.
82 | #
83 | # @example
84 | # manager = Sketchup.extensions
85 | # keys = manager.keys
86 | # for key in keys
87 | # UI.messagebox('The next extension is named: ' + key)
88 | # end
89 | #
90 | # @return keys - Array of string keys
91 | #
92 | # @version SketchUp 8.0 M2
93 | def keys
94 | end
95 |
96 | # The {#length} method returns the number of {SketchupExtension} objects inside
97 | # this ExtensionsManager.
98 | #
99 | # @example
100 | # manager = Sketchup.extensions
101 | # number = manager.length
102 | #
103 | # @return [Integer]
104 | #
105 | # @see #size
106 | #
107 | # @version SketchUp 8.0 M2
108 | def length
109 | end
110 |
111 | # The {#size} method is an alias of {#length}.
112 | #
113 | # @example
114 | # manager = Sketchup.extensions
115 | # number = manager.size
116 | #
117 | # @return [Integer]
118 | #
119 | # @see #length
120 | #
121 | # @version SketchUp 8.0 M2
122 | def size
123 | end
124 |
125 | end
126 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionsObserver.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # This observer interface is implemented to react to events on a definitions
5 | # collection.
6 | #
7 | # @abstract To implement this observer, create a Ruby class of this type,
8 | # override the desired methods, and add an instance of the observer to the
9 | # collection of interest.
10 | #
11 | # @example
12 | # class MyDefinitionsObserver < Sketchup::DefinitionsObserver
13 | # def onComponentAdded(definitions, definition)
14 | # puts "onComponentAdded: #{definition.name}"
15 | # end
16 | # end
17 | #
18 | # Sketchup.active_model.definitions.add_observer(MyDefinitionsObserver.new)
19 | #
20 | # @version SketchUp 6.0
21 | class Sketchup::DefinitionsObserver
22 |
23 | # Instance Methods
24 |
25 | # The {#onComponentAdded} method is called whenever a definition is added to
26 | # the definitions collection.
27 | #
28 | # @example
29 | # def onComponentAdded(definitions, definition)
30 | # puts "onComponentAdded: #{definition}"
31 | # end
32 | #
33 | # @param [Sketchup::DefinitionList] definitions
34 | #
35 | # @param [Sketchup::ComponentDefinition] definition
36 | #
37 | # @return [nil]
38 | #
39 | # @version SketchUp 6.0
40 | def onComponentAdded(definitions, definition)
41 | end
42 |
43 | # The {#onComponentPropertiesChanged} method is called whenever a definition's
44 | # name or description are changed.
45 | #
46 | # This does not fire when "Glue To", "Cuts Opening", or "Face Camera" settings
47 | # are changed.
48 | #
49 | # @example
50 | # def onComponentPropertiesChanged(definitions, definition)
51 | # puts "onComponentPropertiesChanged: #{definition}"
52 | # end
53 | #
54 | # @param [Sketchup::DefinitionList] definitions
55 | #
56 | # @param [Sketchup::ComponentDefinition] definition
57 | #
58 | # @return [nil]
59 | #
60 | # @version SketchUp 6.0
61 | def onComponentPropertiesChanged(definitions, definition)
62 | end
63 |
64 | # The {#onComponentAdded} method is called whenever a definition is removed
65 | # from the definitions collection.
66 | #
67 | # @example
68 | # def onComponentRemoved(definitions, definition)
69 | # puts "onComponentRemoved: #{definition}"
70 | # end
71 | #
72 | # @note This methods fires twice for each Component/Group erased.
73 | #
74 | # @param [Sketchup::DefinitionList] definitions
75 | #
76 | # @param [Sketchup::ComponentDefinition] definition
77 | #
78 | # @return [nil]
79 | #
80 | # @version SketchUp 6.0
81 | def onComponentRemoved(definitions, definition)
82 | end
83 |
84 | # The {#onComponentTypeChanged} event is fired when a component is converted to
85 | # a group or vice versa. (In the underlying implementation, {Sketchup::Group}s
86 | # are just a special kind of definition that is allowed to only have a single
87 | # instance.)
88 | #
89 | # @example
90 | # def onComponentTypeChanged(definitions, definition)
91 | # puts "onComponentTypeChanged: #{definition}"
92 | # end
93 | #
94 | # @param [Sketchup::DefinitionList] definitions
95 | #
96 | # @param [Sketchup::ComponentDefinition] definition
97 | #
98 | # @return [nil]
99 | #
100 | # @version SketchUp 6.0
101 | def onComponentTypeChanged(definitions, definition)
102 | end
103 |
104 | end
105 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/OptionsManager.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # The OptionsManager class manages various kinds of OptionsProviders on a
5 | # Model.
6 | #
7 | # @version SketchUp 6.0
8 | class Sketchup::OptionsManager
9 |
10 | # Includes
11 |
12 | include Enumerable
13 |
14 | # Instance Methods
15 |
16 | # The [] method is used to get an option provider by name or index.
17 | #
18 | # For example, to get the UnitsOptions on the Model, you could use the
19 | # command:
20 | #
21 | # @example
22 | # Sketchup.active_model.options["UnitsOptions"]
23 | #
24 | # @example
25 | # model = Sketchup.active_model
26 | # manager = model.options
27 | # provider = manager[0]
28 | # if (provider)
29 | # UI.messagebox provider.name
30 | # else
31 | # UI.messagebox "Failure"
32 | # end
33 | #
34 | # @overload [](index)
35 | #
36 | # @param index The index of the OptionsProvider object.
37 | # @return optionprovider - an OptionsProvider object if
38 | # successful, otherwise nil.
39 | #
40 | # @overload [](name)
41 | #
42 | # @param name The name of the OptionsProvider object.
43 | # @return optionprovider - an OptionsProvider object if
44 | # successful, otherwise nil.
45 | #
46 | # @version SketchUp 6.0
47 | def [](arg)
48 | end
49 |
50 | #
51 | # @example
52 | # optionsmanager = Sketchup.active_model.options
53 | # number = manager.count
54 | #
55 | # @note Since SketchUp 2014 the count method is inherited from Ruby's
56 | # +Enumerable+ mix-in module. Prior to that the {#count} method is an alias
57 | # for {#length}.
58 | #
59 | # @return integer - number of OptionsProvider objects if
60 | # successful
61 | #
62 | # @see #length
63 | #
64 | # @version SketchUp 6.0
65 | def count
66 | end
67 |
68 | # The {#each} method is used to iterate through options providers.
69 | #
70 | # @example
71 | # model = Sketchup.active_model
72 | # manager = model.options
73 | # manager.each { |provider| puts provider.name }
74 | #
75 | # @return [nil]
76 | #
77 | # @version SketchUp 6.0
78 | #
79 | # @yieldparam [Sketchup::OptionsProvider] provider
80 | def each
81 | end
82 |
83 | # The keys method is used to get a list of keys in the OptionsManager.
84 | #
85 | # @example
86 | # model = Sketchup.active_model
87 | # manager = model.options
88 | # optionproviderarray = manager.keys
89 | # if (optionproviderarray)
90 | # UI.messagebox optionproviderarray
91 | # else
92 | # UI.messagebox "Failure"
93 | # end
94 | #
95 | # @return keys - Array of string keys
96 | #
97 | # @version SketchUp 6.0
98 | def keys
99 | end
100 |
101 | # The {#length} method is an alias of {#size}.
102 | #
103 | # @example
104 | # optionsmanager = Sketchup.active_model.options
105 | # number = manager.length
106 | #
107 | # @return [Integer]
108 | #
109 | # @see #size
110 | #
111 | # @version SketchUp 2014
112 | def length
113 | end
114 |
115 | # The {#size} method returns the number of {OptionsProvider} objects inside
116 | # this {OptionsManager}.
117 | #
118 | # @example
119 | # optionsmanager = Sketchup.active_model.options
120 | # number = manager.size
121 | #
122 | # @return [Integer]
123 | #
124 | # @see #length
125 | #
126 | # @version SketchUp 6.0
127 | def size
128 | end
129 |
130 | end
131 |
--------------------------------------------------------------------------------
/Documentation Guide.md:
--------------------------------------------------------------------------------
1 | # Documentation Guide
2 |
3 | The Ruby API docs was originally generated using a custom proprietary tool which loosely used RDoc syntax.
4 |
5 | In 2016 they got migrated to use YARD as documentation engine, still using RDoc syntax.
6 |
7 | The documentation is generated from our internal C++ source code. These stubs are generated automatically using a [custom YARD template](https://github.com/SketchUp/sketchup-yard-template).
8 |
9 | We accept improvements to the API documentations via Pull Requests to the https://github.com/SketchUp/ruby-api-stubs repository.
10 |
11 | Upon a Pull Request we will review the changes and maybe request some tweaks. Once we're ready to merge this we will pull your development branch and run a tool which will back-port the documentation changes to our C++ source.
12 |
13 | Then we'll regenerate the documentation and stubs - finally closing the Pull Request.
14 |
15 | ## Syntax Style
16 |
17 | This document will act as a guide for how we want the documentation to be formatted. We will expand upon it as we go along and questions arise. Feel free to contribute with suggestions.
18 |
19 | One recent class to refer to for examples is `UI::HtmlDialog`.
20 |
21 | ## References
22 |
23 | - YARD tags: http://www.rubydoc.info/gems/yard/file/docs/Tags.md
24 | - YARD types parser: http://yardoc.org/types.html
25 |
26 | - RDoc syntax: http://docs.seattlerb.org/rdoc/RDoc/Markup.html
27 |
28 |
29 | ## Tag Descriptions
30 |
31 | Tag descriptions should be full sentence (capitalized with proper punctuation.)
32 |
33 | Examples:
34 |
35 | **Not so good**
36 |
37 | ` - the entities search context, or {Model#entities} if none.`
38 |
39 | **Better**
40 |
41 | `The entities context in which to search. (Defaults to the current model's entities.)`
42 |
43 |
44 | ## `@param` tags
45 |
46 | `@param` tags should follow this format:
47 |
48 | `@param [types] name Full sentence (capitalized with proper punctuation.)`
49 |
50 | Example (imagine a search or find method):
51 |
52 | **Not so good**
53 |
54 | `@param [Sketchup::Entities] entities - the {Sketchup::Entities} search context, or Model{Model#entities} if none.`
55 | - The dash separating the param name and description is frivolous. This is syntax formatting inherited from the previous documentation engine. We will try to eliminate it as we work out way through the docs.
56 | - The second class link is unneeded because the class in the TypeList will be automatically linked by YARD.
57 |
58 | **Better**
59 |
60 | `# @param [Sketchup::Entities] entities The entities context in which to search. Defaults to the current model's entities.`
61 | - No dash need even be considered as the Typelist separates the parameter name from the description.
62 | - The descriptions are proper grammatical sentences, that can be more easily translated using online translators.
63 |
64 |
65 | ## `@return` tags
66 |
67 | Often the `@return` tag doesn't need much more than the type returned as the method name and description is enough information:
68 |
69 | #
70 | #
71 | # @return [Geom::Transformation]
72 | def transformation
73 | end
74 |
75 | In the existing docs there will often be methods that return `true` or `false` to indicate success. In these cases there is no need to express that in the documentation comments. When a method return a boolean the convention is so common that there is no need to repeat it.
76 |
77 | # @return [Boolean]
78 | def add_observer
79 | end
80 |
81 | _Ref:_
82 | * [**YARD**: Tag List - @return](http://www.rubydoc.info/gems/yard/file/docs/Tags.md#return)
83 | * [**YARD**: Type List Conventions - Literals](http://www.rubydoc.info/gems/yard/file/docs/Tags.md#Literals)
84 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/SelectionObserver.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # This observer interface is implemented to react to selection events.
5 | #
6 | # @abstract To implement this observer, create a Ruby class of this type, override the
7 | # desired methods, and add an instance of the observer to the objects of
8 | # interests.
9 | #
10 | # @example
11 | # # This is an example of an observer that watches the selection for
12 | # # changes.
13 | # class MySelectionObserver < Sketchup::SelectionObserver
14 | # def onSelectionBulkChange(selection)
15 | # puts "onSelectionBulkChange: #{selection}"
16 | # end
17 | # end
18 | #
19 | # # Attach the observer.
20 | # Sketchup.active_model.selection.add_observer(MySelectionObserver.new)
21 | #
22 | # @version SketchUp 6.0
23 | class Sketchup::SelectionObserver
24 |
25 | # Instance Methods
26 |
27 | #
28 | # @example
29 | # def onSelectionAdded(selection, entity)
30 | # puts "onSelectionAdded: #{entity}"
31 | # end
32 | #
33 | # @note This event might not trigger even if a single element is selected. For
34 | # instance the Selection tool will trigger {#onSelectionBulkChange} regardless.
35 | #
36 | # @param [Sketchup::Selection] selection
37 | #
38 | # @param [Sketchup::Entity] entity
39 | #
40 | # @return [nil]
41 | #
42 | # @see onSelectionBulkChange
43 | #
44 | # @version SketchUp 6.0
45 | def onSelectionAdded(selection, entity)
46 | end
47 |
48 | # The {#onSelectionBulkChange} method is called whenever items are added or
49 | # removed from the selection set.
50 | #
51 | # The {#onSelectionBulkChange} callback will not trigger if the selection
52 | # is cleared by clicking on empty model space. Use the {#onSelectionCleared}
53 | # method to catch this case.
54 | #
55 | # @example
56 | # def onSelectionBulkChange(selection)
57 | # puts "onSelectionBulkChange: #{selection}"
58 | # end
59 | #
60 | # @param [Sketchup::Selection] selection
61 | #
62 | # @return [nil]
63 | #
64 | # @version SketchUp 6.0
65 | def onSelectionBulkChange(selection)
66 | end
67 |
68 | # The {#onSelectionCleared} method is called when the selection is completely
69 | # emptied.
70 | #
71 | # @example
72 | # def onSelectionCleared(selection)
73 | # puts "onSelectionCleared: #{selection}"
74 | # end
75 | #
76 | # @param [Sketchup::Selection] selection
77 | #
78 | # @return [nil]
79 | #
80 | # @version SketchUp 6.0
81 | def onSelectionCleared(selection)
82 | end
83 |
84 | #
85 | # @bug Due to a bug in SketchUp this event doesn't trigger. Instead
86 | # +onSelectedRemoved+ is called.
87 | #
88 | # @example
89 | # class MySelectionObserver < Sketchup::SelectionObserver
90 | # def onSelectionRemoved(selection, entity)
91 | # puts "onSelectionRemoved: #{entity}"
92 | # end
93 | #
94 | # # Due to a SketchUp bug, this method is called by the wrong name.
95 | # alias_method :onSelectedRemoved, :onSelectionRemoved
96 | # end
97 | #
98 | # # Attach the observer.
99 | # Sketchup.active_model.selection.add_observer(MySelectionObserver.new)
100 | #
101 | # @note This event might not trigger even if a single element is deselected.
102 | # For instance the Selection tool will trigger {#onSelectionBulkChange}
103 | # regardless.
104 | #
105 | # @param [Sketchup::Selection] selection
106 | #
107 | # @param [Sketchup::Entity] entity
108 | #
109 | # @return [nil]
110 | #
111 | # @version SketchUp 6.0
112 | def onSelectionRemoved(selection, entity)
113 | end
114 |
115 | end
116 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/Tools.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # The Tools class contains methods to manipulate a collection of SketchUp
5 | # tools. You access this collection by calling the Model.tools method.
6 | #
7 | # @example
8 | # tools = Sketchup.active_model.tools
9 | #
10 | # @version SketchUp 6.0
11 | class Sketchup::Tools
12 |
13 | # Instance Methods
14 |
15 | # The {#active_tool} method is used to obtain the active Ruby tool.
16 | #
17 | # @example
18 | # tools = Sketchup.active_model.tools
19 | # tool = tools.active_tool
20 | #
21 | # @return [Object, nil] Returns the active Ruby tool, or `nil` otherwise.
22 | #
23 | # @version SketchUp 2019
24 | def active_tool
25 | end
26 |
27 | # The active_tool_id method is used to retrieve the active tool's id.
28 | #
29 | # @example
30 | # tools = Sketchup.active_model.tools
31 | # id = tools.active_tool_id
32 | #
33 | # @return id - the active tool's id.
34 | #
35 | # @version SketchUp 6.0
36 | def active_tool_id
37 | end
38 |
39 | # The active_tool_name method is used to retrieve the active tool's name.
40 | #
41 | # @example
42 | # tools = Sketchup.active_model.tools
43 | # if tools.active_tool_id.equal? 0
44 | # puts "Tools collection is empty"
45 | # else
46 | # name = tools.active_tool_name
47 | # end
48 | #
49 | # @return name = the active tool's name.
50 | #
51 | # @version SketchUp 6.0
52 | def active_tool_name
53 | end
54 |
55 | # The add_observer method is used to add an observer to the current object.
56 | #
57 | # @example
58 | # tools = Sketchup.active_model.tools
59 | # observer = Sketchup::ToolsObserver.new
60 | # status = tools.add_observer observer
61 | #
62 | # @param observer
63 | # An observer.
64 | #
65 | # @return status - true if successful, false if unsuccessful.
66 | #
67 | # @version SketchUp 6.0
68 | def add_observer(observer)
69 | end
70 |
71 | # The model method is used to get the model associated with this tools object.
72 | #
73 | # @example
74 | # tools = Sketchup.active_model.tools
75 | # model = tools.model
76 | #
77 | # @return model - the Model object associated with this tools
78 | # collection.
79 | #
80 | # @version SketchUp 6.0
81 | def model
82 | end
83 |
84 | # The pop_tool method is used to pop the last pushed tool on the tool stack.
85 | #
86 | # @example
87 | # tools = Sketchup.active_model.tools
88 | # tool = tools.pop_tool
89 | #
90 | # @return the last pushed Tool object, if it is a Ruby tool. If a
91 | # native tool is active, selects the default native tool
92 | # and returns nil.
93 | #
94 | # @version SketchUp 6.0
95 | def pop_tool
96 | end
97 |
98 | # The push_tool method is used to push (aka activate) a user-defined tool.
99 | # See the Tool interface for details on creating your own SketchUp tool.
100 | #
101 | # @example
102 | # tools = Sketchup.active_model.tools
103 | # status = tools.push_tool tool
104 | #
105 | # @param tool
106 | # A user.
107 | #
108 | # @return status - true if successful, false if unsuccessful.
109 | #
110 | # @version SketchUp 6.0
111 | def push_tool(tool)
112 | end
113 |
114 | # The remove_observer method is used to remove an observer from the current
115 | # object.
116 | #
117 | # @example
118 | # tools = Sketchup.active_model.tools
119 | # observer = Sketchup::ToolsObserver.new
120 | # tools.add_observer observer
121 | # status = tools.remove_observer observer
122 | #
123 | # @param observer
124 | # An observer.
125 | #
126 | # @return true if successful, false if unsuccessful.
127 | #
128 | # @version SketchUp 6.0
129 | def remove_observer(observer)
130 | end
131 |
132 | end
133 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Layout/TableRow.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # A {Layout::TableColumn} is a single row from a table.
5 | #
6 | # @example
7 | # bounds = Geom::Bounds2d.new(1, 1, 4, 4)
8 | # rows = 4
9 | # columns = 4
10 | # table = Layout::Table.new(bounds, rows, columns)
11 | # rows.times { |index|
12 | # row = table.row(index)
13 | # }
14 | #
15 | # @version LayOut 2018
16 | class Layout::TableRow
17 |
18 | # Instance Methods
19 |
20 | # The {#bottom_edge_style} method returns the {Layout::Style} of a
21 | # {Layout::TableRow}'s bottom edge.
22 | #
23 | # @example
24 | # bounds = Geom::Bounds2d.new(1, 1, 4, 4)
25 | # rows = 4
26 | # columns = 4
27 | # table = Layout::Table.new(bounds, rows, columns)
28 | # style = table.get_row(1).bottom_edge_style
29 | #
30 | # @return [Layout::Style]
31 | #
32 | # @version LayOut 2018
33 | def bottom_edge_style
34 | end
35 |
36 | # The {#bottom_edge_style=} method sets the {Layout::Style} of a
37 | # {Layout::TableRow}'s bottom edge.
38 | #
39 | # @example
40 | # bounds = Geom::Bounds2d.new(1, 1, 4, 4)
41 | # rows = 4
42 | # columns = 4
43 | # table = Layout::Table.new(bounds, rows, columns)
44 | # style = Layout::Style.new
45 | # style.stroke_width = 2.0
46 | # table.get_row(1).bottom_edge_style = style
47 | #
48 | # @param [Layout::Style] style
49 | #
50 | # @raise [LockedLayerError] if the {Layout::Table} is on a locked
51 | # {Layout::Layer}
52 | #
53 | # @raise [LockedEntityError] if the {Layout::Table} is locked
54 | #
55 | # @version LayOut 2018
56 | def bottom_edge_style=(style)
57 | end
58 |
59 | # The {#height} method returns the height of the {Layout::TableRow}.
60 | #
61 | # @example
62 | # bounds = Geom::Bounds2d.new(1, 1, 4, 4)
63 | # rows = 4
64 | # columns = 4
65 | # table = Layout::Table.new(bounds, rows, columns)
66 | # height = table.get_row(1).height
67 | #
68 | # @return [Float]
69 | #
70 | # @version LayOut 2018
71 | def height
72 | end
73 |
74 | # The {#height=} method sets the height of the {Layout::TableRow}.
75 | #
76 | # @example
77 | # bounds = Geom::Bounds2d.new(1, 1, 4, 4)
78 | # rows = 4
79 | # columns = 4
80 | # table = Layout::Table.new(bounds, rows, columns)
81 | # table.get_row(1).height = 3.0
82 | #
83 | # @param [Float] height
84 | #
85 | # @raise [ArgumentError] if height is not a valid height
86 | #
87 | # @raise [LockedLayerError] if the {Layout::Table} is on a locked
88 | # {Layout::Layer}
89 | #
90 | # @raise [LockedEntityError] if the {Layout::Table} is locked
91 | #
92 | # @version LayOut 2018
93 | def height=(height)
94 | end
95 |
96 | # The {#top_edge_style} method returns the {Layout::Style} of a
97 | # {Layout::TableRow}'s top edge.
98 | #
99 | # @example
100 | # bounds = Geom::Bounds2d.new(1, 1, 4, 4)
101 | # rows = 4
102 | # columns = 4
103 | # table = Layout::Table.new(bounds, rows, columns)
104 | # style = table.get_row(1).top_edge_style
105 | #
106 | # @return [Layout::Style]
107 | #
108 | # @version LayOut 2018
109 | def top_edge_style
110 | end
111 |
112 | # The {#top_edge_style=} method sets the {Layout::Style} of a
113 | # {Layout::TableRow}'s top edge.
114 | #
115 | # @example
116 | # bounds = Geom::Bounds2d.new(1, 1, 4, 4)
117 | # rows = 4
118 | # columns = 4
119 | # table = Layout::Table.new(bounds, rows, columns)
120 | # style = Layout::Style.new
121 | # style.stroke_width = 2.0
122 | # table.get_row(1).top_edge_style = style
123 | #
124 | # @param [Layout::Style] style
125 | #
126 | # @raise [LockedLayerError] if the {Layout::Table} is on a locked
127 | # {Layout::Layer}
128 | #
129 | # @raise [LockedEntityError] if the {Layout::Table} is locked
130 | #
131 | # @version LayOut 2018
132 | def top_edge_style=(style)
133 | end
134 |
135 | end
136 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/EntitiesObserver.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # This observer interface is implemented to react to {Sketchup::Entities}
5 | # collection events.
6 | #
7 | # @abstract To implement this observer, create a Ruby class of this
8 | # type, override the desired methods, and add an instance of the observer to
9 | # the objects of interests.
10 | #
11 | # @example
12 | # # This is an example of an observer that watches the entities collection
13 | # # new added elements and writes a message on the console.
14 | # class MyEntitiesObserver < Sketchup::EntitiesObserver
15 | # def onElementAdded(entities, entity)
16 | # puts "onElementAdded: #{entity}"
17 | # end
18 | # end
19 | #
20 | # # Attach the observer
21 | # Sketchup.active_model.entities.add_observer(MyEntitiesObserver.new)
22 | #
23 | # @note The methods of this observer fire in such a way that making changes
24 | # to the model while inside of them is dangerous. If you experience sudden
25 | # crashes, it could be because of this observer. A potential workaround is to
26 | # use a {Sketchup::ToolsObserver} to watch what the user is doing instead.
27 | #
28 | # @version SketchUp 6.0
29 | class Sketchup::EntitiesObserver
30 |
31 | # Instance Methods
32 |
33 | # The {#onActiveSectionPlaneChanged} method is invoked when a section plane
34 | # within this entities is activated or the active one is deactivated.
35 | #
36 | # @example
37 | # def onActiveSectionPlaneChanged(entities)
38 | # sp = entities.active_section_plane
39 | # if sp.nil?
40 | # puts "Section plane is deactivated on #{entities}"
41 | # else
42 | # puts "#{sp} is activated on #{entities}"
43 | # end
44 | # end
45 | #
46 | # @param [Sketchup::Entities] entities
47 | #
48 | # @return [nil]
49 | #
50 | # @version SketchUp 2014
51 | def onActiveSectionPlaneChanged(entities)
52 | end
53 |
54 | # The onElementAdded method is invoked when a single element is added
55 | # to the {Sketchup::Entities} collection.
56 | #
57 | # @example
58 | # def onElementAdded(entities, entity)
59 | # puts "onElementAdded: #{entity}"
60 | # end
61 | #
62 | # @param [Sketchup::Entities] entities
63 | #
64 | # @param [Sketchup::Entity] entity
65 | #
66 | # @return [nil]
67 | #
68 | # @version SketchUp 6.0
69 | def onElementAdded(entities, entity)
70 | end
71 |
72 | # The {#onElementModified} method is invoked whenever one or more elements in
73 | # the collection are modified.
74 | #
75 | # @example
76 | # def onElementModified(entities, entity)
77 | # puts "onElementModified: #{entity}"
78 | # end
79 | #
80 | # @param [Sketchup::Entities] entities
81 | #
82 | # @param [Sketchup::Entity] entity
83 | #
84 | # @return [nil]
85 | #
86 | # @version SketchUp 8.0
87 | def onElementModified(entities, entity)
88 | end
89 |
90 | # The {#onElementRemoved} method is invoked when a single element is removed
91 | # from the {Sketchup::Entities} collection. Note that the entity has been
92 | # deleted and should not be used in anyway except to know that the entity has
93 | # been deleted.
94 | #
95 | # @example
96 | # def onElementRemoved(entities, entity_id)
97 | # puts "onElementRemoved: #{entity_id}"
98 | # end
99 | #
100 | # @param [Sketchup::Entities] entities
101 | #
102 | # @param [Sketchup::Entity] entity_id
103 | # The id of the entity that was
104 | # deleted/removed.
105 | #
106 | # @return [nil]
107 | #
108 | # @version SketchUp 6.0
109 | def onElementRemoved(entities, entity_id)
110 | end
111 |
112 | # The {#onEraseEntities} method is invoked when one or more entities are erased.
113 | #
114 | # @example
115 | # def onEraseEntities(entities)
116 | # puts "onEraseEntities: #{entities}"
117 | # end
118 | #
119 | # @param [Sketchup::Entities] entities
120 | #
121 | # @return [nil]
122 | #
123 | # @version SketchUp 6.0
124 | def onEraseEntities(entities)
125 | end
126 |
127 | end
128 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Geom/UTM.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # The UTM class lets you work with UTM map coordinates.
5 | #
6 | # @note Valid ranges for {#zone_number} and {#zone_letter} are 1-60 and C-X
7 | # (omitting I and O). Valid ranges for {#x} and {#y} are 100000-899999.
8 | #
9 | # @version SketchUp 6.0
10 | class Geom::UTM
11 |
12 | # Instance Methods
13 |
14 | # The {#initialize} method is used to create a new UTM coordinate. You will
15 | # often create UTM objects by calling the method {Sketchup::Model#point_to_utm}
16 | # instead of calling this method.
17 | #
18 | # @example
19 | # # Create a copy of an existing UTM object.
20 | # utm = Geom::UTM.new(utm2)
21 | #
22 | # # Create a new UTM object from scratch.
23 | # utm = Geom::UTM.new(13, "T", 475849.37521, 4429682.73749)
24 | #
25 | # @overload initialize(zone_number, zone_letter, x, y)
26 | #
27 | # @param [Integer] zone_number A zone number or a UTM object.
28 | # @param [String] zone_letter A zone letter.
29 | # @param [Float] x The x position.
30 | # @param [Float] y The y position.
31 | #
32 | # @overload initialize(utm)
33 | #
34 | # @param [Geom::UTM] utm A UTM object.
35 | #
36 | # @overload initialize(array)
37 | #
38 | # @param [Array(Integer, String, Float, Float)] An array containing the zone
39 | # number, zone letter, x and y positions.
40 | #
41 | # @return [Geom::UTM]
42 | #
43 | # @version SketchUp 6.0
44 | def initialize(*args)
45 | end
46 |
47 | # The {#to_a} method returns a UTM coordinate as a 4 element array. The Array
48 | # elements are the zone number, the zone letter, the x coordinate and the y
49 | # coordinate.
50 | #
51 | # @example
52 | # # Create a new UTM object from scratch.
53 | # utm = Geom::UTM.new(13, "T", 475849.37521, 4429682.73749)
54 | # a = utm.to_a
55 | #
56 | # @return [Array(Integer, String, Float, Float)]
57 | #
58 | # @version SketchUp 6.0
59 | def to_a
60 | end
61 |
62 | # The {#to_latlong} method is used to convert UTM coordinates to latitude
63 | # and longitude. See the LatLong class for more information.
64 | #
65 | # @example
66 | # # Create a new UTM object from scratch.
67 | # utm = Geom::UTM.new(13, "T", 475849.37521, 4429682.73749)
68 | # ll = utm.to_latlong
69 | #
70 | # @return [Geom::LatLong]
71 | #
72 | # @version SketchUp 6.0
73 | def to_latlong
74 | end
75 |
76 | # The {#to_s} method is used to retrieve a string representation of a UTM.
77 | #
78 | # @example
79 | # # Create a new UTM object from scratch.
80 | # utm = Geom::UTM.new(13, "T", 475849.37521, 4429682.73749)
81 | # string = utm.to_s
82 | #
83 | # @return [String]
84 | #
85 | # @version SketchUp 6.0
86 | def to_s
87 | end
88 |
89 | # The {#x} method returns the UTM x coordinate.
90 | #
91 | # @example
92 | # # Create a new UTM object from scratch.
93 | # utm = Geom::UTM.new(13, "T", 475849.37521, 4429682.73749)
94 | # x = utm.x
95 | #
96 | # @return [Float]
97 | #
98 | # @version SketchUp 6.0
99 | def x
100 | end
101 |
102 | # The {#y} method returns the UTM y coordinate.
103 | #
104 | # @example
105 | # # Create a new UTM object from scratch.
106 | # utm = Geom::UTM.new(13, "T", 475849.37521, 4429682.73749)
107 | # y = utm.y
108 | #
109 | # @return [Float]
110 | #
111 | # @version SketchUp 6.0
112 | def y
113 | end
114 |
115 | # The {#zone_letter} method returns the UTM zone letter.
116 | #
117 | # @example
118 | # # Create a new UTM object from scratch.
119 | # utm = Geom::UTM.new(13, "T", 475849.37521, 4429682.73749)
120 | # zl = utm.zone_letter
121 | #
122 | # @return [String]
123 | #
124 | # @version SketchUp 6.0
125 | def zone_letter
126 | end
127 |
128 | # The {#zone_number} method returns the UTM zone number.
129 | #
130 | # @example
131 | # # Create a new UTM object from scratch.
132 | # utm = Geom::UTM.new(13, "T", 475849.37521, 4429682.73749)
133 | # zn = utm.zone_number
134 | #
135 | # @return [Integer]
136 | #
137 | # @version SketchUp 6.0
138 | def zone_number
139 | end
140 |
141 | end
142 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/Vertex.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # A Vertex. A Vertex represents the end of an Edge or a point inside a Face.
5 | #
6 | # @version SketchUp 6.0
7 | class Sketchup::Vertex < Sketchup::Entity
8 |
9 | # Instance Methods
10 |
11 | # The common_edge method is used to find a common edge that is defined by this
12 | # vertex and another vertex
13 | #
14 | # @example
15 | # edge = entities[0]
16 | # # returns array of vertices that make up the line
17 | # verticies = edge.vertices
18 | # vertex1 = verticies[0]
19 | # vertex2 = verticies[1]
20 | # edge = vertex1.common_edge vertex2
21 | # if (edge)
22 | # UI.messagebox edge
23 | # else
24 | # UI.messagebox "Failure"
25 | # end
26 | #
27 | # @param [Sketchup::Vertex] vertex2
28 | # A Vertex object.
29 | #
30 | # @return [Sketchup::Edge, nil] an Edge object common to both vertices if
31 | # successful. Returns nil if there is no edge between the
32 | # two vertices.
33 | #
34 | # @version SketchUp 6.0
35 | def common_edge(vertex2)
36 | end
37 |
38 | # The {#curve_interior?} method is used to determine if this vertex is on the
39 | # interior of a Curve.
40 | #
41 | # @example
42 | # edge = entities[0]
43 | # # returns array of vertices that make up the line
44 | # verticies = edge.vertices
45 | # vertex1 = verticies[0]
46 | # status = vertex1.curve_interior?
47 | # if (status)
48 | # UI.messagebox status
49 | # else
50 | # #returns nil if vertex is not on interior of a Curve
51 | # UI.messagebox "Failure"
52 | # end
53 | #
54 | # @note This method doesn't actually return a boolean as the question mark
55 | # post-fix would normally indicate. But the result still evaluates to
56 | # truthy or falsy.
57 | #
58 | # @return [Boolean]
59 | #
60 | # @version SketchUp 6.0
61 | def curve_interior?
62 | end
63 |
64 | # The edges method is used to retrieve an Array of edges that use the Vertex.
65 | #
66 | # @example
67 | # edge = entities[0]
68 | # # Returns array of vertices that make up the line.
69 | # verticies = edge.vertices
70 | # vertex1 = verticies[0]
71 | # edges = vertex1.edges
72 | #
73 | # @return [Array] an Array of edge objects if successful
74 | #
75 | # @version SketchUp 6.0
76 | def edges
77 | end
78 |
79 | # The faces method is used to retrieve an Array of faces that use the vertex.
80 | #
81 | # @example
82 | # edge = entities[0]
83 | # # Returns array of vertices that make up the line.
84 | # verticies = edge.vertices
85 | # vertex1 = verticies[0]
86 | # faces = vertex1.faces
87 | #
88 | # @return [Array] an Array of faces that use the vertex if
89 | # successful
90 | #
91 | # @version SketchUp 6.0
92 | def faces
93 | end
94 |
95 | # The loops method is used to retrieve an Array of loops that use the vertex.
96 | #
97 | # @example
98 | # edge = entities[0]
99 | # # Returns array of vertices that make up the line.
100 | # verticies = edge.vertices
101 | # vertex1 = verticies[0]
102 | # loops = vertex1.loops
103 | #
104 | # @return [Array] an Array of loops that use the vertex if
105 | # successful
106 | #
107 | # @version SketchUp 6.0
108 | def loops
109 | end
110 |
111 | # The position method is used to retrieve the Point3d position of a vertex.
112 | #
113 | # @example
114 | # edge = entities[0]
115 | # # Returns array of vertices that make up the line.
116 | # verticies = edge.vertices
117 | # vertex1 = verticies[0]
118 | # position = vertex1.position
119 | #
120 | # @return [Geom::Point3d] a Point3d object representing the position of
121 | # the vertex if successful
122 | #
123 | # @version SketchUp 6.0
124 | def position
125 | end
126 |
127 | # The used_by? method is used to determine if the Vertex is used by a given
128 | # Edge or Face.
129 | #
130 | # @example
131 | # used = vertex1.used_by? my_face
132 | #
133 | # @param [Sketchup::Edge, Sketchup::Face] face_or_edge
134 | # A Face or Edge ot test against.
135 | #
136 | # @return [Boolean]
137 | #
138 | # @version SketchUp 6.0
139 | def used_by?(face_or_edge)
140 | end
141 |
142 | end
143 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Layout/TableColumn.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # A {Layout::TableColumn} is a single column from a table.
5 | #
6 | # @example
7 | # bounds = Geom::Bounds2d.new(1, 1, 4, 4)
8 | # rows = 4
9 | # columns = 4
10 | # table = Layout::Table.new(bounds, rows, columns)
11 | # columns.times { |index|
12 | # column = table.column(index)
13 | # }
14 | #
15 | # @version LayOut 2018
16 | class Layout::TableColumn
17 |
18 | # Instance Methods
19 |
20 | # The {#left_edge_style} method returns the {Layout::Style} of a
21 | # {Layout::TableColumn}'s left edge. If this is the first column of the table,
22 | # this method will return the style of the table border.
23 | #
24 | # @example
25 | # bounds = Geom::Bounds2d.new(1, 1, 4, 4)
26 | # rows = 4
27 | # columns = 4
28 | # table = Layout::Table.new(bounds, rows, columns)
29 | # style = table.get_column(1).edge_style
30 | #
31 | # @return [Layout::Style]
32 | #
33 | # @version LayOut 2018
34 | def left_edge_style
35 | end
36 |
37 | # The {#left_edge_style=} method sets the {Layout::Style} of a
38 | # {Layout::TableColumn}'s left edge. If this is the first column of the table,
39 | # this method will set the style for the table border.
40 | #
41 | # @example
42 | # bounds = Geom::Bounds2d.new(1, 1, 4, 4)
43 | # rows = 4
44 | # columns = 4
45 | # table = Layout::Table.new(bounds, rows, columns)
46 | # style = Layout::Style.new
47 | # style.stroke_width = 2.0
48 | # table.get_column(1).edge_style = style
49 | #
50 | # @param [Layout::Style] style
51 | #
52 | # @raise [LockedLayerError] if the {Layout::Table} is on a locked
53 | # {Layout::Layer}
54 | #
55 | # @raise [LockedEntityError] if the {Layout::Table} is locked
56 | #
57 | # @version LayOut 2018
58 | def left_edge_style=(style)
59 | end
60 |
61 | # The {#right_edge_style} method returns the {Layout::Style} of a
62 | # {Layout::TableColumn}'s right edge. If this is the last column of the table,
63 | # this method will return the style of the table border.
64 | #
65 | # @example
66 | # bounds = Geom::Bounds2d.new(1, 1, 4, 4)
67 | # rows = 4
68 | # columns = 4
69 | # table = Layout::Table.new(bounds, rows, columns)
70 | # style = table.get_column(1).edge_style
71 | #
72 | # @return [Layout::Style]
73 | #
74 | # @version LayOut 2018
75 | def right_edge_style
76 | end
77 |
78 | # The {#right_edge_style=} method sets the {Layout::Style} of a
79 | # {Layout::TableColumn}'s right edge. If this is the last column of the table,
80 | # this method will set the style for the table border.
81 | #
82 | # @example
83 | # bounds = Geom::Bounds2d.new(1, 1, 4, 4)
84 | # rows = 4
85 | # columns = 4
86 | # table = Layout::Table.new(bounds, rows, columns)
87 | # style = Layout::Style.new
88 | # style.stroke_width = 2.0
89 | # table.get_column(1).edge_style = style
90 | #
91 | # @param [Layout::Style] style
92 | #
93 | # @raise [LockedLayerError] if the {Layout::Table} is on a locked
94 | # {Layout::Layer}
95 | #
96 | # @raise [LockedEntityError] if the {Layout::Table} is locked
97 | #
98 | # @version LayOut 2018
99 | def right_edge_style=(style)
100 | end
101 |
102 | # The {#width} method returns the width of the {Layout::TableColumn}.
103 | #
104 | # @example
105 | # bounds = Geom::Bounds2d.new(1, 1, 4, 4)
106 | # rows = 4
107 | # columns = 4
108 | # table = Layout::Table.new(bounds, rows, columns)
109 | # width = table.get_column(1).width
110 | #
111 | # @return [Float]
112 | #
113 | # @version LayOut 2018
114 | def width
115 | end
116 |
117 | # The {#width=} method sets the width of the {Layout::TableColumn}.
118 | #
119 | # @example
120 | # bounds = Geom::Bounds2d.new(1, 1, 4, 4)
121 | # rows = 4
122 | # columns = 4
123 | # table = Layout::Table.new(bounds, rows, columns)
124 | # table.get_column(1).width = 6.0
125 | #
126 | # @param [Float] width
127 | #
128 | # @raise [ArgumentError] if width is not a valid width
129 | #
130 | # @raise [LockedLayerError] if the {Layout::Table} is on a locked
131 | # {Layout::Layer}
132 | #
133 | # @raise [LockedEntityError] if the {Layout::Table} is locked
134 | #
135 | # @version LayOut 2018
136 | def width=(width)
137 | end
138 |
139 | end
140 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/MaterialsObserver.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # This observer interface is implemented to react to materials events.
5 | #
6 | # @abstract To implement this observer, create a Ruby class of this type, override the
7 | # desired methods, and add an instance of the observer to the objects of
8 | # interests.
9 | #
10 | # @example
11 | # class MyMaterialsObserver < Sketchup::MaterialsObserver
12 | # def onMaterialAdd(materials, material)
13 | # puts "onMaterialAdd: #{material}"
14 | # end
15 | # end
16 | #
17 | # Sketchup.active_model.materials.add_observer(MyMaterialsObserver.new)
18 | #
19 | # @note The callback +onMaterialRemoveAll+ has been deprecated, we recommend using
20 | # {#onMaterialRemove} instead.
21 | #
22 | # @version SketchUp 6.0
23 | class Sketchup::MaterialsObserver
24 |
25 | # Instance Methods
26 |
27 | # The {#onMaterialAdd} method is invoked whenever a new material is added.
28 | #
29 | # @example
30 | # def onMaterialAdd(materials, material)
31 | # puts "onMaterialAdd: #{material}"
32 | # end
33 | #
34 | # @param [Sketchup::Materials] materials
35 | #
36 | # @param [Sketchup::Material] material
37 | #
38 | # @return [nil]
39 | #
40 | # @version SketchUp 6.0
41 | def onMaterialAdd(materials, material)
42 | end
43 |
44 | # The {#onMaterialChange} method is invoked whenever a material's texture image
45 | # is altered.
46 | #
47 | # @example
48 | # def onMaterialChange(materials, material)
49 | # puts "onMaterialChange: #{material}"
50 | # end
51 | #
52 | # @param [Sketchup::Materials] materials
53 | #
54 | # @param [Sketchup::Material] material
55 | #
56 | # @return [nil]
57 | #
58 | # @version SketchUp 6.0
59 | def onMaterialChange(materials, material)
60 | end
61 |
62 | # The {#onMaterialRefChange} method is invoked whenever the number of entities
63 | # that a material is painted on changes. This could be due to the user
64 | # manually painting something, but it could also be when faces are split,
65 | # pasted, push-pulled, deleted, etc.
66 | #
67 | # @example
68 | # def onMaterialRefChange(materials, material)
69 | # puts "onMaterialRefChange: #{material}"
70 | # end
71 | #
72 | # @param [Sketchup::Materials] materials
73 | #
74 | # @param [Sketchup::Material] material
75 | #
76 | # @return [nil]
77 | #
78 | # @version SketchUp 6.0
79 | def onMaterialRefChange(materials, material)
80 | end
81 |
82 | # The {#onMaterialRemove} method is invoked whenever a material is deleted.
83 | #
84 | # @example
85 | # def onMaterialRemove(materials, material)
86 | # puts "onMaterialRemove: #{material}"
87 | # end
88 | #
89 | # @param [Sketchup::Materials] materials
90 | #
91 | # @param [Sketchup::Material] material
92 | #
93 | # @return [nil]
94 | #
95 | # @version SketchUp 6.0
96 | def onMaterialRemove(materials, material)
97 | end
98 |
99 | # The {#onMaterialSetCurrent} method is invoked whenever a different material
100 | # is selected in the Materials dialog.
101 | #
102 | # The materials parameter might be Nil when the material is picked from the
103 | # materials libraries and not yet added to the model.
104 | #
105 | # @example
106 | # def onMaterialSetCurrent(materials, material)
107 | # puts "onMaterialSetCurrent: #{material}"
108 | # end
109 | #
110 | # @param [Sketchup::Materials] materials
111 | #
112 | # @param [Sketchup::Material] material
113 | #
114 | # @return [nil]
115 | #
116 | # @version SketchUp 6.0
117 | def onMaterialSetCurrent(materials, material)
118 | end
119 |
120 | # The {#onMaterialUndoRedo} method is invoked whenever a material is altered
121 | # and then those changes are undone or redone.
122 | #
123 | # @example
124 | # def onMaterialUndoRedo(materials, material)
125 | # puts "onMaterialUndoRedo: #{material}"
126 | # end
127 | #
128 | # @note Due to a bug, this callback does not fire in SU6 or SU7. You can use
129 | # the {Sketchup::ModelObserver#onTransactionStart} to capture all undo
130 | # events.
131 | #
132 | # @param [Sketchup::Materials] materials
133 | #
134 | # @param [Sketchup::Material] material
135 | #
136 | # @return [nil]
137 | #
138 | # @version SketchUp 6.0
139 | def onMaterialUndoRedo(materials, material)
140 | end
141 |
142 | end
143 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Layout/LayerInstance.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # References an instance of a {Layout::Layer}. A {Layout::LayerInstance}
5 | # provides access to the {Layout::Entity}s that are on it, as well as their
6 | # draw order. {Layout::Group}s are not included in the list of {Layout::Entity}s
7 | # associated with a {Layout::LayerInstance}, since the group hierarchy has no
8 | # effect on entity draw order. Each {Layout::Page} has one
9 | # {Layout::LayerInstance} for each {Layout::Layer} in the {Layout::Document}.
10 | # Non-shared {Layout::LayerInstance}s are unique per {Layout::Page}, while
11 | # shared {Layout::LayerInstance}s are shared across all {Layout::Page}s of the
12 | # {Layout::Document}.
13 | #
14 | # @example
15 | # doc = Layout::Document.open("C:/path/to/document.layout")
16 | # layers = doc.layers
17 | # pages = doc.pages
18 | # layers.each do |layer|
19 | # layer_instance = layer.layer_instance(pages.first)
20 | # entities = layer_instance.entities
21 | # entities.each do |entity|
22 | # new_index = rand(entities.length - 1)
23 | # layer_instance.reorder_entity(entity, new_index)
24 | # end
25 | # end
26 | #
27 | # @version LayOut 2018
28 | class Layout::LayerInstance
29 |
30 | # Instance Methods
31 |
32 | # The {#==} method checks to see if the two {Layout::LayerInstance}s are equal.
33 | # This checks whether the Ruby Objects are pointing to the same internal
34 | # object.
35 | #
36 | # @example
37 | # doc = Layout::Document.open("C:/path/to/document.layout")
38 | # document = doc.pages.first.document
39 | # doc.page.layer_instances.first == document.page.layer_instances.first
40 | #
41 | # @param [Layout::LayerInstance] other
42 | #
43 | # @return [Boolean]
44 | #
45 | # @version LayOut 2018
46 | def ==(other)
47 | end
48 |
49 | # The {#definition} method returns the {Layout::Layer} of the
50 | # {Layout::LayerInstance}.
51 | #
52 | # @example
53 | # layer_def = layer_instance.definition
54 | #
55 | # @return [Layout::Layer]
56 | #
57 | # @version LayOut 2018
58 | def definition
59 | end
60 |
61 | # The {#entities} method returns the {Layout::Entities} on the
62 | # {Layout::LayerInstance}.
63 | #
64 | # @example
65 | # doc = Layout::Document.open("C:/path/to/document.layout")
66 | # layers = doc.layers
67 | # pages = doc.pages
68 | # first_layer = layers.first
69 | # entities = first_layer.layer_instance.entities
70 | #
71 | # @return [Layout::Entities]
72 | #
73 | # @version LayOut 2018
74 | def entities
75 | end
76 |
77 | # The {#entity_index} method returns the index of the {Layout::Entity} on the
78 | # {Layout::LayerInstance}.
79 | #
80 | # @example
81 | # doc = Layout::Document.open("C:/path/to/document.layout")
82 | # layers = doc.layers
83 | # pages = doc.pages
84 | # instance = layers.first.layer_instance
85 | # instance.entities.each_with_index { |entity, index|
86 | # puts "#{index} == #{instance.entity_index(entity)}"
87 | # }
88 | #
89 | # @param [Layout::Entity] entity
90 | # The entity to get the index of.
91 | #
92 | # @raise [ArgumentError] if entity is not on the {Layout::LayerInstance}
93 | #
94 | # @return [Integer]
95 | #
96 | # @version LayOut 2018
97 | def entity_index(entity)
98 | end
99 |
100 | # The {#reorder_entity} method moves the {Layout::Entity} to the specified
101 | # index.
102 | #
103 | # @example
104 | # doc = Layout::Document.open("C:/path/to/document.layout")
105 | # layers = doc.layers
106 | # pages = doc.pages
107 | # first_layer = layers.first
108 | # first_layer.set_shared(pages.first, SHARELAYERACTION_KEEPONEPAGE);
109 | # layer_instance = first_layer.layer_instance
110 | # entities = layer_instance.entities
111 | # # put the first entity into the back of the layer
112 | # layer_instance.reorder_entity(entities.first, (entities.length - 1))
113 | #
114 | # @param [Layout::Entity] entity
115 | # The {Layout::Entity} to reorder
116 | #
117 | # @param [Integer] index
118 | # The desired index of the {Layout::Entity}
119 | #
120 | # @raise [ArgumentError] if entity is not on the {Layout::LayerInstance}
121 | #
122 | # @raise [IndexError] if index is out of range
123 | #
124 | # @version LayOut 2018
125 | def reorder_entity(entity, index)
126 | end
127 |
128 | end
129 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/FrameChangeObserver.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # This observer interface is implemented to react to changes in camera
5 | # position (a frame) between one scene page and another. This observer's
6 | # callback method is called when the user manually makes a scene change,
7 | # or the internal animation feature runs.
8 | #
9 | # This abstract observer is any object that implements a callback method
10 | # +frameChange+ with 3 arguments: +from_scene+ (the scene that you
11 | # transition from), +to_scene+ (the scene that you transition toward)
12 | # and a +percent_done+ between +0.0+ and +1.0+ (that indicates the percentage
13 | # of transition between the two scenes.)
14 | #
15 | # # Basic Class Definition:
16 | # class MyFrameChangeObserver
17 | # def frameChange(from_scene, to_scene, percent_done)
18 | # # Actual code here.
19 | # end
20 | # end
21 | #
22 | # The observer is attached using the {Sketchup::Pages.add_frame_change_observer}
23 | # class method, which returns an integer id that can be stored and later
24 | # used to detach the observer.
25 | #
26 | # # Attach an observer to the global Pages object:
27 | # @id = Sketchup::Pages.add_frame_change_observer(MyFrameChangeObserver.new)
28 | #
29 | # Later, detaching this observer is done by passing this +id+ reference to
30 | # the {Sketchup::Pages.remove_frame_change_observer} class method.
31 | #
32 | # # Basic Observer Detachment:
33 | # Sketchup::Pages.remove_frame_change_observer(@id)
34 | #
35 | # @abstract Implement the methods described in this class to create a frame
36 | # change observer. You can not sub-class this class because it is not
37 | # defined by the API.
38 | #
39 | # @example Draws a progress bar on the status line.
40 | # class MyFrameChangeObserver
41 | # def frameChange(from_scene, to_scene, percent_done)
42 | # if percent_done == 0.0
43 | # Sketchup.status_text= "% done:"
44 | # if from_scene.nil? # PC bug!
45 | # puts "Animating to page: '#{to_scene.name}'"
46 | # else
47 | # puts "From page '#{from_scene.name}' to '#{to_scene.name}'"
48 | # end
49 | # else
50 | # Sketchup.status_text= "% done: #{'|'*(percent_done*100).to_i}"
51 | # UI.messagebox("All Done!") if percent_done >= 1.0
52 | # end
53 | # end
54 | # end
55 | # @id = Sketchup::Pages.add_frame_change_observer(MyFrameChangeObserver.new)
56 | class Sketchup::FrameChangeObserver
57 |
58 | # Instance Methods
59 |
60 | # This callback method is called during a slide show or creation of an
61 | # animation after the camera has been set up, but before the frame is
62 | # displayed. It gives you a chance to perform your own actions during
63 | # the animation. The arguments for +frameChange+ method are the scene
64 | # page that you transition from (+from_scene+), the scene page that you
65 | # transition to (+to_scene+), and a +percent_done+ between +0.0+ and +1.0+
66 | # that tell you the percentage of the transition between the two scene
67 | # pages.
68 | #
69 | # By watching for +percent_done >= 1.0+, you can activate Ruby code that
70 | # executes as soon as the user's camera has finished animating.
71 | #
72 | # @example
73 | # class MyFrameChangeObserver
74 | # def frameChange(from_scene, to_scene, percent_done)
75 | # if percent_done == 0.0
76 | # puts "Animating to scene '#{to_scene.name}':"
77 | # else
78 | # puts format("% 7.2f %",percent_done*100)
79 | # end
80 | # end
81 | # end
82 | # @id = Sketchup::Pages.add_frame_change_observer(MyFrameChangeObserver.new)
83 | #
84 | # @note The +from_scene+ argument into this callback does not appear to
85 | # be populated on the PC. You can store a variable that keeps track of
86 | # the +to_scene+ and then use that on a subsequent Scene selection to
87 | # determine the last Page that the user was on.
88 | #
89 | # @param [Sketchup::Page, nil] from_scene
90 | # The previous scene page the view is transitioning from.
91 | #
92 | # @param [Sketchup::Page] to_scene
93 | # The selected scene page the view is transitioning towards.
94 | #
95 | # @param [Float] percent_done
96 | # The percentage of transition between the two scene pages.
97 | #
98 | # @version SketchUp 6.0
99 | def frameChange(from_scene, to_scene, percent_done)
100 | end
101 |
102 | end
103 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/Loop.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # Loop is a low level topology class that will not need to be used often. A
5 | # Loop is a chain of Edges that bound a Face.
6 | #
7 | # @version SketchUp 6.0
8 | class Sketchup::Loop < Sketchup::Entity
9 |
10 | # Instance Methods
11 |
12 | # Determine if the loop is convex.
13 | #
14 | # @example
15 | # entities = Sketchup.active_model.active_entities
16 | # points = []
17 | # points << Geom::Point3d.new(0, 0, 0)
18 | # points << Geom::Point3d.new(100, 0, 0)
19 | # points << Geom::Point3d.new(100, 200, 0)
20 | # points << Geom::Point3d.new(0, 200, 0)
21 | # face = entities.add_face(points)
22 | # loop = face.outer_loop
23 | # if loop.convex?
24 | # puts "Loop is convex."
25 | # else
26 | # puts "Loop is not convex."
27 | # end
28 | #
29 | # @return [Boolean] status - true if convex, false if not convex.
30 | #
31 | # @version SketchUp 6.0
32 | def convex?
33 | end
34 |
35 | # Get an array of the edges that define the loop in an ordered sequence.
36 | #
37 | # @example
38 | # entities = Sketchup.active_model.active_entities
39 | # points = []
40 | # points << Geom::Point3d.new(0, 0, 0)
41 | # points << Geom::Point3d.new(100, 0, 0)
42 | # points << Geom::Point3d.new(100, 200, 0)
43 | # points << Geom::Point3d.new(0, 200, 0)
44 | # face = entities.add_face(points)
45 | # loop = face.outer_loop
46 | # edges = loop.edges
47 | #
48 | # @return edges - an array of Edge objects if successful.
49 | #
50 | # @version SketchUp 6.0
51 | def edges
52 | end
53 |
54 | # Get an array of the EdgeUse objects that define this loop in an ordered
55 | # sequence.
56 | #
57 | # @example
58 | # entities = Sketchup.active_model.active_entities
59 | # points = []
60 | # points << Geom::Point3d.new(0, 0, 0)
61 | # points << Geom::Point3d.new(100, 0, 0)
62 | # points << Geom::Point3d.new(100, 200, 0)
63 | # points << Geom::Point3d.new(0, 200, 0)
64 | # face = entities.add_face(points)
65 | # loop = face.outer_loop
66 | # edgeuses = loop.edgeuses
67 | #
68 | # @return edgeuses - an array of EdgeUse objects if successful.
69 | #
70 | # @version SketchUp 6.0
71 | def edgeuses
72 | end
73 |
74 | # Get the Face object that is bounded by this loop.
75 | #
76 | # @example
77 | # entities = Sketchup.active_model.active_entities
78 | # points = []
79 | # points << Geom::Point3d.new(0, 0, 0)
80 | # points << Geom::Point3d.new(100, 0, 0)
81 | # points << Geom::Point3d.new(100, 200, 0)
82 | # points << Geom::Point3d.new(0, 200, 0)
83 | # face = entities.add_face(points)
84 | # loop = face.outer_loop
85 | # loop_face = loop.face
86 | #
87 | # @return face - a Face object if successful
88 | #
89 | # @version SketchUp 6.0
90 | def face
91 | end
92 |
93 | # Determine if this is an outer loop. Each face has one outer loop, and will
94 | # have one loop for each hole.
95 | #
96 | # @example
97 | # entities = Sketchup.active_model.active_entities
98 | # points = []
99 | # points << Geom::Point3d.new(0, 0, 0)
100 | # points << Geom::Point3d.new(100, 0, 0)
101 | # points << Geom::Point3d.new(100, 200, 0)
102 | # points << Geom::Point3d.new(0, 200, 0)
103 | # face = entities.add_face(points)
104 | # loop = face.outer_loop
105 | # if loop.outer?
106 | # puts "Loop is an outer loop."
107 | # else
108 | # puts "Loop is not an outer loop."
109 | # end
110 | #
111 | # @return [Boolean] status - true if the loop is an outer loop, false if it
112 | # is not an outer loop.
113 | #
114 | # @version SketchUp 6.0
115 | def outer?
116 | end
117 |
118 | # Get an array of the vertices that define the loop in an ordered sequence.
119 | #
120 | # @example
121 | # entities = Sketchup.active_model.active_entities
122 | # points = []
123 | # points << Geom::Point3d.new(0, 0, 0)
124 | # points << Geom::Point3d.new(100, 0, 0)
125 | # points << Geom::Point3d.new(100, 200, 0)
126 | # points << Geom::Point3d.new(0, 200, 0)
127 | # face = entities.add_face(points)
128 | # loop = face.outer_loop
129 | # vertices = loop.vertices
130 | #
131 | # @return vertices - an array of Vertex objects if successful.
132 | #
133 | # @version SketchUp 6.0
134 | def vertices
135 | end
136 |
137 | end
138 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/Axes.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # SketchUp's drawing axes consist of three colored lines (red, green, blue),
5 | # usually perpendicular to each other, displayed in the drawing area. The
6 | # exception is when the user open an instance with a non-orthogonal
7 | # transformation. The root model transformation is always orthogonal.
8 | #
9 | # The drawing axes are used by drawing tools to align the geometry it creates
10 | # as well as affecting the inference engine.
11 | #
12 | # The plane where the red and green axes lines lie is called the ground plane.
13 | # The term origin, is used to define the place where all of axes lines start or
14 | # originate.
15 | #
16 | # @version SketchUp 2016
17 | class Sketchup::Axes < Sketchup::Entity
18 |
19 | # Instance Methods
20 |
21 | # The axes method returns the vectors representing the directions of the axes.
22 | #
23 | # @example
24 | # xaxis, yaxis, zaxis = Sketchup.active_model.axes.axes
25 | #
26 | # @return Array - an array of three vectors.
27 | #
28 | # @version SketchUp 2016
29 | def axes
30 | end
31 |
32 | # The origin method returns the origin of the axes.
33 | #
34 | # @example
35 | # point = Sketchup.active_model.axes.origin
36 | #
37 | # @return Point3d - the origin for the axes.
38 | #
39 | # @version SketchUp 2016
40 | def origin
41 | end
42 |
43 | # The set method allows the axes to be manipulated. The axes must always be
44 | # orthogonal, otherwise an error is thrown.
45 | #
46 | # @example
47 | # xaxis = Geom::Vector3d.new(3, 5, 0)
48 | # yaxis = xaxis * Z_AXIS
49 | # Sketchup.active_model.axes.set([10,0,0], xaxis, yaxis, Z_AXIS)
50 | #
51 | # @param origin
52 | # Point3d - The origin to set.
53 | #
54 | # @param xaxis
55 | # Vector3d - The x axis to set.
56 | #
57 | # @param yaxis
58 | # Vector3d - The y axis to set.
59 | #
60 | # @param zaxis
61 | # Vector3d - The z axis to set.
62 | #
63 | # @return Axes - the axes object being set.
64 | #
65 | # @version SketchUp 2016
66 | def set(origin, xaxis, yaxis, zaxis)
67 | end
68 |
69 | # The sketch_plane method returns a plane representing the ground plane of the
70 | # axes.
71 | #
72 | # @example
73 | # plane = Sketchup.active_model.axes.sketch_plane
74 | #
75 | # @return Array - of 4 numbers that give the coefficients of a
76 | # plane equation.
77 | #
78 | # @version SketchUp 2016
79 | def sketch_plane
80 | end
81 |
82 | # The axes method returns the origin and vectors representing the axes.
83 | #
84 | # @example
85 | # point, xaxis, yaxis, zaxis = Sketchup.active_model.axes.to_a
86 | #
87 | # @return Array - an array of a point and three vectors.
88 | #
89 | # @version SketchUp 2016
90 | def to_a
91 | end
92 |
93 | # The transformation method returns the transformation of the axes. This is
94 | # useful when creating tools that respect the model's drawing axes.
95 | #
96 | # @example
97 | # # Point for a rectangle.
98 | # points = [
99 | # Geom::Point3d.new( 0, 0, 0),
100 | # Geom::Point3d.new(10, 0, 0),
101 | # Geom::Point3d.new(10, 20, 0),
102 | # Geom::Point3d.new( 0, 20, 0)
103 | # ]
104 | # # Transform the points so they are local to the model axes. Otherwise
105 | # # they would be local to the model origin.
106 | # tr = Sketchup.active_model.axes.transformation
107 | # points.each { |point| point.transform!(tr) }
108 | # Sketchup.active_model.active_entities.add_face(points)
109 | #
110 | # @return Transformation - the transformation for the axes.
111 | #
112 | # @version SketchUp 2016
113 | def transformation
114 | end
115 |
116 | # The xaxis method returns the x axis of the axes.
117 | #
118 | # @example
119 | # vector = Sketchup.active_model.axes.xaxis
120 | #
121 | # @return Vector3d - the x axis for the axes.
122 | #
123 | # @version SketchUp 2016
124 | def xaxis
125 | end
126 |
127 | # The yaxis method returns the y axis of the axes.
128 | #
129 | # @example
130 | # vector = Sketchup.active_model.axes.yaxis
131 | #
132 | # @return Vector3d - the y axis for the axes.
133 | #
134 | # @version SketchUp 2016
135 | def yaxis
136 | end
137 |
138 | # The zaxis method returns the z axis of the axes.
139 | #
140 | # @example
141 | # vector = Sketchup.active_model.axes.zaxis
142 | #
143 | # @return Vector3d - the z axis for the axes.
144 | #
145 | # @version SketchUp 2016
146 | def zaxis
147 | end
148 |
149 | end
150 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/SectionPlane.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # The SectionPlane class represents a section plane in a SketchUp model. Note
5 | # that prior to SketchUp 2014 there was no way to create a SectionPlane object
6 | # using Ruby. For older versions of SketchUp, you must manually create a
7 | # section plane with the Section Plane Tool in SketchUp and then query the
8 | # entities array to find the SectionPlane object.
9 | #
10 | # @version SketchUp 6.0
11 | class Sketchup::SectionPlane < Sketchup::Drawingelement
12 |
13 | # Instance Methods
14 |
15 | # The activate method is used to make the section plane the active one of its
16 | # parent component/group.
17 | #
18 | # @example
19 | # entities = Sketchup.active_model.entities
20 | # sp = entities.add_section_plane([50, 50, 0], [1.0, 1.0, 0])
21 | # sp.activate
22 | #
23 | # @return self if successful
24 | #
25 | # @version SketchUp 2014
26 | def activate
27 | end
28 |
29 | # The active? method indicates whether the section plane is active or not.
30 | #
31 | # @example
32 | # entities = Sketchup.active_model.entities
33 | # sp = entities.add_section_plane([50, 50, 0], [1.0, 1.0, 0])
34 | # sp.activate
35 | # if sp.active?
36 | # puts "Yes, it is active"
37 | # end
38 | #
39 | # @return [Boolean] boolean - true if active
40 | #
41 | # @version SketchUp 2014
42 | def active?
43 | end
44 |
45 | # The get_plane method is used to retrieve the plane that the section plane is
46 | # on.
47 | #
48 | # @example
49 | # model = Sketchup.active_model
50 | # entities = model.active_entities
51 | # # Grab the first section plane from the model.
52 | # sp = entities.grep(Sketchup::SectionPlane).first
53 | # plane = sp.get_plane
54 | # if (plane)
55 | # puts plane.to_s
56 | # else
57 | # puts 'Failure'
58 | # end
59 | #
60 | # @return plane - a plane. See the Geom module and Array class
61 | # for further information on planes.
62 | #
63 | # @version SketchUp 6.0
64 | def get_plane
65 | end
66 |
67 | # The {#name} method is used to retrieve the name of the section plane.
68 | #
69 | # @example
70 | # model = Sketchup.active_model
71 | # entities = model.active_entities
72 | # # Grab the first section plane from the model.
73 | # section_plane = entities.grep(Sketchup::SectionPlane).first
74 | # name = section_plane.name
75 | #
76 | # @return [String]
77 | #
78 | # @version SketchUp 2018
79 | def name
80 | end
81 |
82 | # The {#name=} method is used to set the name of a section plane.
83 | #
84 | # @example
85 | # model = Sketchup.active_model
86 | # entities = Sketchup.active_model.entities
87 | # # Grab the first section plane from the model.
88 | # section_plane = entities.grep(Sketchup::SectionPlane).first
89 | # section_plane.name = "my section plane"
90 | #
91 | # @param [String] name
92 | # The new name for the section plane object.
93 | #
94 | # @version SketchUp 2018
95 | def name=(name)
96 | end
97 |
98 | # The set_plane method is used to set the plane that the section plane is
99 | # on.
100 | #
101 | # @example
102 | # model = Sketchup.active_model
103 | # entities = model.active_entities
104 | # # Grab the first section plane from the model.
105 | # sp = entities.grep(Sketchup::SectionPlane).first
106 | # sp = sp.set_plane my_plane_array
107 | #
108 | # @param plane
109 | # An array representing the new plane,
110 | #
111 | # @return section_plane - the updated SectionPlane.
112 | #
113 | # @version SketchUp 6.0
114 | def set_plane(plane)
115 | end
116 |
117 | # The {#symbol} method is used to retrieve the symbol of the section plane.
118 | #
119 | # @example
120 | # model = Sketchup.active_model
121 | # entities = model.active_entities
122 | # # Grab the first section plane from the model.
123 | # section_plane = entities.grep(Sketchup::SectionPlane).first
124 | # symbol = section_plane.symbol
125 | #
126 | # @return [String]
127 | #
128 | # @version SketchUp 2018
129 | def symbol
130 | end
131 |
132 | # The {#symbol=} method is used to set the symbol of a section plane.
133 | #
134 | # @example
135 | # model = Sketchup.active_model
136 | # entities = Sketchup.active_model.entities
137 | # # Grab the first section plane from the model.
138 | # section_plane = entities.grep(Sketchup::SectionPlane).first
139 | # section_plane.symbol = "AB1"
140 | #
141 | # @note The symbol must be three characters or less.
142 | #
143 | # @param [String] symbol
144 | # The new symbol for the section plane object.
145 | #
146 | # @version SketchUp 2018
147 | def symbol=(symbol)
148 | end
149 |
150 | end
151 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/AttributeDictionaries.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # The AttributeDictionaries class is a collection of all of the
5 | # AttributeDictionary objects that are attached to a given Entity object.
6 | #
7 | # The Entity class is a popular parent class in SketchUp, meaning you can
8 | # attach AttributeDictionaries to almost anything, from geometric items
9 | # like edges and faces and components to more conceptual things like pages
10 | # or materials.
11 | #
12 | # You access this class not by performing an AttributeDictionaries.new but
13 | # by grabbing a handle from an existing entity.
14 | #
15 | # @example
16 | # # Grab the first entity from the model.
17 | # my_layer = Sketchup.active_model.entities[0]
18 | #
19 | # # Grab a handle to its attribute dictionaries.
20 | # attrdicts = my_layer.attribute_dictionaries
21 | #
22 | # @version SketchUp 6.0
23 | class Sketchup::AttributeDictionaries < Sketchup::Entity
24 |
25 | # Includes
26 |
27 | include Enumerable
28 |
29 | # Instance Methods
30 |
31 | # Get an AttributeDictionary by name. Returns nil if there is none with the
32 | # given name.
33 | #
34 | # @example
35 | # model = Sketchup.active_model
36 | # attrdicts = model.attribute_dictionaries
37 | # # Iterates through all dictionaries and prints to screen.
38 | # dict = attrdicts['my_dictionary']
39 | # if dict
40 | # UI.messagebox("Found: " + dict.to_s)
41 | # else
42 | # UI.messagebox("No dictionary found.")
43 | # end
44 | #
45 | # @param [String] key
46 | # The name of the attribute dictionary.
47 | #
48 | # @return [Sketchup::AttributeDictionary] the dictionary
49 | #
50 | # @version SketchUp 6.0
51 | def [](key)
52 | end
53 |
54 | # The count method is inherited from the Enumerable mix-in module.
55 | #
56 | # @example
57 | # model = Sketchup.active_model
58 | # model.set_attribute('Example', 'Hello', 'World')
59 | # dictionaries = model.attribute_dictionaries
60 | # number = dictionaries.count
61 | #
62 | # @return [Integer]
63 | #
64 | # @see #length
65 | #
66 | # @version SketchUp 2014
67 | def count
68 | end
69 |
70 | # The delete method destroys a given AttributeDictionary. This
71 | # AttributeDictionary can be passed directly or identified by its
72 | # string name.
73 | #
74 | # In SketchUp 2018, special attribute dictionaries have been added. The name of
75 | # these dictionaries are "SU_InstanceSet" and "SU_DefinitionSet". The
76 | # dictionaries cannot be deleted via ruby and an ArgumentError will be raised.
77 | # The key/value pairs in the dictionary can be deleted safely.
78 | #
79 | # object
80 | #
81 | # @example
82 | # model = Sketchup.active_model
83 | # attrdicts = model.attribute_dictionaries
84 | # # Deletes a dictionary called 'my_dictionary'
85 | # attrdicts.delete 'my_dictionary'
86 | #
87 | # @param [String, Sketchup::AttributeDictionary] key_or_dict
88 | # The name of the attribute dictionary to delete, or
89 | # the dictionary object itself.
90 | #
91 | # @raise ArgumentError if an advanced attribute dictionary is being deleted.
92 | #
93 | # @return [Sketchup::AttributeDictionaries] the modified AttributeDictionaries
94 | #
95 | # @version SketchUp 6.0
96 | def delete(key_or_dict)
97 | end
98 |
99 | # The {#each} method is used to iterate through all of the attributes
100 | # dictionaries.
101 | #
102 | # @example
103 | # model = Sketchup.active_model
104 | # dictionaries = model.attribute_dictionaries
105 | # # Iterates through all dictionaries and prints to screen.
106 | # dictionaries.each { |dictionary| puts dictionary.name }
107 | #
108 | # @return nil
109 | #
110 | # @version SketchUp 6.0
111 | #
112 | # @yieldparam [Sketchup::AttributeDictionary] dictionary
113 | def each
114 | end
115 |
116 | # The {#length} method returns the number of attribute dictionary objects in
117 | # the collection.
118 | #
119 | # @example
120 | # model = Sketchup.active_model
121 | # model.set_attribute('Example', 'Hello', 'World')
122 | # dictionaries = model.attribute_dictionaries
123 | # number = dictionaries.length
124 | #
125 | # @return [Integer] the number of attribute dictionary objects in the
126 | # collection.
127 | #
128 | # @see #size
129 | #
130 | # @version SketchUp 2014
131 | def length
132 | end
133 |
134 | # The {#size} method is an alias of {#length}.
135 | #
136 | # @example
137 | # model = Sketchup.active_model
138 | # model.set_attribute('Example', 'Hello', 'World')
139 | # dictionaries = model.attribute_dictionaries
140 | # number = dictionaries.size
141 | #
142 | # @return [Integer]
143 | #
144 | # @see #length
145 | #
146 | # @version SketchUp 2014
147 | def size
148 | end
149 |
150 | end
151 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/Dimension.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # The Dimension class provides base functionality for classes DimensionLinear
5 | # and DimensionRadial. It's not instantiable.
6 | #
7 | # @version SketchUp 2014
8 | class Sketchup::Dimension < Sketchup::Drawingelement
9 |
10 | # Constants
11 |
12 | ARROW_CLOSED = nil # Stub value.
13 | ARROW_DOT = nil # Stub value.
14 | ARROW_NONE = nil # Stub value.
15 | ARROW_OPEN = nil # Stub value.
16 | ARROW_SLASH = nil # Stub value.
17 |
18 | # Instance Methods
19 |
20 | # The add_observer method is used to add a DimensionObserver to the dimension.
21 | #
22 | # @example
23 | # observer = MyDimObserver.new
24 | # dim = Sketchup.active_model.entities.add_dimension_linear([50, 10, 0],
25 | # [100, 10, 0], [0, 20, 0])
26 | # status = dim.add_observer(observer)
27 | #
28 | # @note If the given observer responds to +onTextChanged+, it will be
29 | # added as a {Sketchup::DimensionObserver}. If not, the base
30 | # {Sketchup::Entity#add_observer} will be called.
31 | #
32 | # @param observer
33 | # A DimensionObserver.
34 | #
35 | # @return true if successful, false if unsuccessful.
36 | #
37 | # @version SketchUp 2014
38 | def add_observer(observer)
39 | end
40 |
41 | # The arrow_type method retrieves the current arrow type of the dimension.
42 | # Valid arrow types are class constants:
43 | # - +Dimension::ARROW_NONE,+
44 | # - +Dimension::ARROW_SLASH+
45 | # - +Dimension::ARROW_DOT+
46 | # - +Dimension::ARROW_CLOSED+
47 | # - +Dimension::ARROW_OPEN+
48 | #
49 | # @example
50 | # type = dim.arrow_type
51 | # if type == Sketchup::Dimension::ARROW_CLOSED
52 | # puts "Arrow type is closed"
53 | # end
54 | #
55 | # @return a numerical representation of the arrow type
56 | #
57 | # @version SketchUp 2014
58 | def arrow_type
59 | end
60 |
61 | # The arrow_type= method sets the arrow type of the dimension.
62 | # Valid arrow types are class constants:
63 | # - +Dimension::ARROW_NONE,+
64 | # - +Dimension::ARROW_SLASH+
65 | # - +Dimension::ARROW_DOT+
66 | # - +Dimension::ARROW_CLOSED+
67 | # - +Dimension::ARROW_OPEN+
68 | #
69 | # @example
70 | # dim.arrow_type = Sketchup::Dimension::ARROW_CLOSED
71 | #
72 | # @param type
73 | # a numerical representation of the arrow type.
74 | #
75 | # @return the arrow type that was set.
76 | #
77 | # @version SketchUp 2014
78 | def arrow_type=(type)
79 | end
80 |
81 | # The has_aligned_text= method accepts true or false indicating whether the
82 | # dimension's text is aligned to the dimension or to the screen.
83 | #
84 | # @example
85 | # dim.has_aligned_text = true
86 | #
87 | # @param [Boolean] value
88 | #
89 | # @return the alignment flag that was set
90 | #
91 | # @version SketchUp 2014
92 | def has_aligned_text=(value)
93 | end
94 |
95 | # The has_aligned_text method is used to determine whether the dimension's text
96 | # is aligned to the dimension or to the screen.
97 | #
98 | # @example
99 | # aligned = dim.has_aligned_text?
100 | #
101 | # @return [Boolean] status - true if text is aligned to the dimension.
102 | # False if dimension text is aligned to the screen.
103 | #
104 | # @version SketchUp 2014
105 | def has_aligned_text?
106 | end
107 |
108 | # The plane method is used to retrieve the plane of the dimension. Refer to the
109 | # Geom module for information on how planes are represented.
110 | #
111 | # @example
112 | # plane = dim.plane
113 | #
114 | # @return the plane of the dimension
115 | #
116 | # @version SketchUp 2014
117 | def plane
118 | end
119 |
120 | # The remove_observer method is used to remove a DimensionObserver from the
121 | # dimension. Note that, if the given observer responds to 'onTextChanged', it
122 | # will be removed as a DimensionObserver. If not, the base
123 | # Entity.remove_observer will be called.
124 | #
125 | # @example
126 | # observer = MyDimObserver.new
127 | # dim = Sketchup.active_model.entities.add_dimension_linear([50, 10, 0],
128 | # [100, 10, 0], [0, 20, 0])
129 | # status = dim.add_observer(observer)
130 | # status = dim.remove_observer(observer)
131 | #
132 | # @param observer
133 | # A DimensionObserver.
134 | #
135 | # @return true if successful, false if unsuccessful.
136 | #
137 | # @version SketchUp 2014
138 | def remove_observer(observer)
139 | end
140 |
141 | # The text method is used to retrieve the dimension text.
142 | #
143 | # @example
144 | # dimtext = dim.text
145 | #
146 | # @return the dimension text
147 | #
148 | # @version SketchUp 2014
149 | def text
150 | end
151 |
152 | # The text= method is used to set an override on the dimension text.
153 | #
154 | # @example
155 | # dim.text= "text"
156 | #
157 | # @param [String] text
158 | #
159 | # @return the newly set text override
160 | #
161 | # @version SketchUp 2014
162 | def text=(text)
163 | end
164 |
165 | end
166 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Geom/Bounds2d.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # The bounds2d class represents an axis aligned bounding box represented by
5 | # two {Geom::Point2d} objects, upper left and lower right positions. The
6 | # units utilized in the creation and modification {Geom::Bounds2d} are inches.
7 | #
8 | # @version LayOut 2018
9 | class Geom::Bounds2d
10 |
11 | # Instance Methods
12 |
13 | # The {#==} method checks to see if the two {Geom::Bounds2d}s are equal. This
14 | # checks whether the point values are the same
15 | #
16 | # @example
17 | # entity.bounds == entity.untransformed_bounds
18 | #
19 | # @param [Geom::Bounds2d] other
20 | #
21 | # @return [Boolean]
22 | #
23 | # @version LayOut 2018
24 | def ==(other)
25 | end
26 |
27 | # The {#height} method returns the height of the {Geom::Bounds2d}.
28 | #
29 | # @example
30 | # bounds = Geom::Bounds2d.new(0.0, 0.0, 1.0, 1.0)
31 | # height = bounds.height
32 | #
33 | # @return [Geom::Point2d]
34 | #
35 | # @version LayOut 2018
36 | def height
37 | end
38 |
39 | # The {#initialize} method creates a new {Geom::Bounds2d}.
40 | #
41 | # @example
42 | # bounds = Geom::Bounds2d.new(0.0, 0.0, 1.0, 1.0)
43 | #
44 | # @overload initialize(other_bounds)
45 | #
46 | # @param [Geom::Bounds2d] other_bounds
47 | # @return [Geom::Bounds2d]
48 | #
49 | # @overload initialize(upper_left, lower_right)
50 | #
51 | # @param [Geom::Point2d] upper_left
52 | # @param [Geom::Point2d] lower_right
53 | # @return [Geom::Bounds2d]
54 | #
55 | # @overload initialize(x, y, width, height)
56 | #
57 | # @param [Float] x
58 | # @param [Float] y
59 | # @param [Float] width
60 | # @param [Float] height
61 | # @return [Geom::Bounds2d]
62 | #
63 | # @overload initialize(point_array)
64 | #
65 | # @param [Array(Geom::Point2d, Geom::Point2d)] point_array An array of two
66 | # {Geom::Point2d}s
67 | # @return [Geom::Bounds2d]
68 | #
69 | # @overload initialize(float_array)
70 | #
71 | # @param [Array(Float, Float, Float, Float)] float_array An array of four
72 | # floats (x, y, width, height)
73 | # @return [Geom::Bounds2d]
74 | #
75 | # @version LayOut 2018
76 | def initialize(*args)
77 | end
78 |
79 | # The {#lower_right} method returns the {Geom::Point2d} of the lower right
80 | # corner of the {Geom::Bounds2d}.
81 | #
82 | # @example
83 | # bounds = Geom::Bounds2d.new(0.0, 0.0, 1.0, 1.0)
84 | # l_r = bounds.lower_right
85 | #
86 | # @return [Geom::Point2d]
87 | #
88 | # @version LayOut 2018
89 | def lower_right
90 | end
91 |
92 | # The {#set!} method sets the {Geom::Bounds2d} to match another one.
93 | # The argument is anything that can be converted into a {Geom::Bounds2d}.
94 | #
95 | # @example
96 | # bounds = Geom::Bounds2d.new(3.0, 3.0, 5.0, 5.0)
97 | # bounds.set!(Geom::Point2d.new(0.0, 0.0), Geom::Point2d.new(2.0, 2.0))
98 | #
99 | # @overload set!(other_bounds)
100 | #
101 | # @param [Geom::Bounds2d] other_bounds
102 | # @return [Geom::Bounds2d]
103 | #
104 | # @overload set!(upper_left, lower_right)
105 | #
106 | # @param [Geom::Point2d] upper_left
107 | # @param [Geom::Point2d] lower_right
108 | # @return [Geom::Bounds2d]
109 | #
110 | # @overload set!(x, y, width, height)
111 | #
112 | # @param [Float] x
113 | # @param [Float] y
114 | # @param [Float] width
115 | # @param [Float] height
116 | # @return [Geom::Bounds2d]
117 | #
118 | # @overload set!(point_array)
119 | #
120 | # @param [Array(Geom::Point2d, Geom::Point2d)] point_array An array of two
121 | # {Geom::Point2d}s
122 | # @return [Geom::Bounds2d]
123 | #
124 | # @overload set!(float_array)
125 | #
126 | # @param [Array(Float, Float, Float, Float)] float_array An array of four
127 | # floats (x, y, width, height)
128 | # @return [Geom::Bounds2d]
129 | #
130 | # @version LayOut 2018
131 | def set!(*args)
132 | end
133 |
134 | # The {#to_a} method returns an array which contains the {Geom::Point2d} that
135 | # define the {Geom::Bounds2d}.
136 | #
137 | # @example
138 | # bounds = Geom::Bounds2d.new
139 | # bounds.to_a.each { |point| p point.to_s }
140 | #
141 | # @return [Array(Geom::Point2d, Geom::Point2d)]
142 | #
143 | # @version LayOut 2018
144 | def to_a
145 | end
146 |
147 | # The {#upper_left} method returns the {Geom::Point2d} of the upper left corner
148 | # of the {Geom::Bounds2d}.
149 | #
150 | # @example
151 | # bounds = Geom::Bounds2d.new(0.0, 0.0, 1.0, 1.0)
152 | # u_l = bounds.upper_left
153 | #
154 | # @return [Geom::Point2d]
155 | #
156 | # @version LayOut 2018
157 | def upper_left
158 | end
159 |
160 | # The {#width} method returns the width of the {Geom::Bounds2d}.
161 | #
162 | # @example
163 | # bounds = Geom::Bounds2d.new(0.0, 0.0, 1.0, 1.0)
164 | # width = bounds.width
165 | #
166 | # @return [Geom::Point2d]
167 | #
168 | # @version LayOut 2018
169 | def width
170 | end
171 |
172 | end
173 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Layout/TableCell.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # A {Layout::TableCell} is a single cell from a table that contains data.
5 | #
6 | # @example
7 | # bounds = Geom::Bounds2d.new(1, 1, 4, 4)
8 | # rows = 4
9 | # columns = 4
10 | # table = Layout::Table.new(bounds, rows, columns)
11 | # table.each { |cell|
12 | # puts cell.data.plain_text
13 | # }
14 | #
15 | # @version LayOut 2018
16 | class Layout::TableCell
17 |
18 | # Constants
19 |
20 | ROTATION_0 = nil # Stub value.
21 | ROTATION_180 = nil # Stub value.
22 | ROTATION_270 = nil # Stub value.
23 | ROTATION_90 = nil # Stub value.
24 |
25 | # Instance Methods
26 |
27 | # The {#data} method creates a copy of the {Layout::FormattedText} for the
28 | # {Layout::TableCell}.
29 | #
30 | # @example
31 | # bounds = Geom::Bounds2d.new(1, 1, 4, 4)
32 | # rows = 4
33 | # columns = 4
34 | # table = Layout::Table.new(bounds, rows, columns)
35 | # cell_entity = table[1, 2].data
36 | #
37 | # @raise [ArgumentError] if the cell {Layout::Entity} is not a
38 | # {Layout::FormattedText}
39 | #
40 | # @version LayOut 2018
41 | def data
42 | end
43 |
44 | # The {#data=} method sets the {Layout::Entity} of a {Layout::TableCell}.
45 | # The text content and fill {Layout::Style} settings will be kept. The bounds
46 | # and other {Layout::Style} settings are controlled by the {Layout::Table}. If
47 | # the specified row and column is within a merged cell, then the merged cell
48 | # itself will be affected.
49 | #
50 | # @example
51 | # bounds = Geom::Bounds2d.new(1, 1, 4, 4)
52 | # rows = 4
53 | # columns = 4
54 | # table = Layout::Table.new(bounds, rows, columns)
55 | # anchor = Geom::Point2d.new(1, 1)
56 | # text_anchor_type = Layout::FormattedText::ANCHOR_TYPE_TOP_LEFT
57 | # text = Layout::FormattedText.new("Test", anchor, text_anchor_type)
58 | # table[1, 2].data = text
59 | #
60 | # @note At the moment, this only works for {Layout::Entity}s that are
61 | # {Layout::FormattedText}s. However, future versions of LayOut may support
62 | # other types of {Layout::Entity}s for {Layout::TableCell}s, so this method
63 | # cannot be assumed to always fail with inputs of other {Layout::Entity}
64 | # types.
65 | #
66 | # @param [Layout::Entity] entity
67 | #
68 | # @raise [LockedLayerError] if the {Layout::Table} is on a locked
69 | # {Layout::Layer}
70 | #
71 | # @raise [LockedEntityError] if the {Layout::Table} is locked
72 | #
73 | # @version LayOut 2018
74 | def data=(entity)
75 | end
76 |
77 | # The {#rotation} method returns the rotation of a {Layout::TableCell}.
78 | #
79 | # The rotation type can be one of the following values:
80 | # [+Layout::TableCell::ROTATION_0+]
81 | # [+Layout::TableCell::ROTATION_90+]
82 | # [+Layout::TableCell::ROTATION_180+]
83 | # [+Layout::TableCell::ROTATION_270+]
84 | #
85 | # @example
86 | # bounds = Geom::Bounds2d.new(1, 1, 4, 4)
87 | # rows = 4
88 | # columns = 4
89 | # table = Layout::Table.new(bounds, rows, columns)
90 | # rotation = table[1, 1].rotation
91 | #
92 | # @raise [ArgumentError] if the cell is invalid due to residing within a
93 | # merged cell
94 | #
95 | # @return [Integer]
96 | #
97 | # @version LayOut 2018
98 | def rotation
99 | end
100 |
101 | # The {#rotation=} method sets the rotation of a {Layout::TableCell}.
102 | #
103 | # The rotation type can be one of the following values:
104 | # [+Layout::TableCell::ROTATION_0+]
105 | # [+Layout::TableCell::ROTATION_90+]
106 | # [+Layout::TableCell::ROTATION_180+]
107 | # [+Layout::TableCell::ROTATION_270+]
108 | #
109 | # @example
110 | # bounds = Geom::Bounds2d.new(1, 1, 4, 4)
111 | # rows = 4
112 | # columns = 4
113 | # table = Layout::Table.new(bounds, rows, columns)
114 | # table[1, 1].rotation = Layout::TableCell::ROTATION_180
115 | #
116 | # @param [Integer] cell_rotation
117 | #
118 | # @raise [ArgumentError] if the cell is invalid due to residing within a
119 | # merged cell
120 | #
121 | # @raise [LockedLayerError] if the {Layout::Table} is on a locked
122 | # {Layout::Layer}
123 | #
124 | # @raise [LockedEntityError] if the {Layout::Table} is locked
125 | #
126 | # @version LayOut 2018
127 | def rotation=(cell_rotation)
128 | end
129 |
130 | # The {#span} method returns the row and column span of a {Layout::TableCell}.
131 | # If the values returned are both 1, then it is a normal, non-merged cell. If
132 | # either of the values are greater than 1, then it is a merged cell. If the
133 | # values are both 0, then it is an unused cell that resides within the inner
134 | # portion of another merged cell.
135 | #
136 | # @example
137 | # bounds = Geom::Bounds2d.new(1, 1, 4, 4)
138 | # rows = 4
139 | # columns = 4
140 | # table = Layout::Table.new(bounds, rows, columns)
141 | # row_span, column_span = table[1, 1].span
142 | #
143 | # @return [Array(Integer, Integer)] Row span and column span.
144 | #
145 | # @version LayOut 2018
146 | def span
147 | end
148 |
149 | end
150 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/Set.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # The set class represents a collection of unique objects. This class is useful
5 | # for keeping track of a group of related entities, kind of like a selection
6 | # set that stays around for as long as you need it to.
7 | #
8 | # To make a set of your own, create an empty one using Sketchup::Set.new, and
9 | # then add items to it.
10 | #
11 | # @deprecated In SketchUp 2014 this class was changed from +Set+
12 | # to +Sketchup::Set+ in order to avoid conflict with the Ruby Standard
13 | # Library. The +Sketchup::Set+ class is deprecated and new extensions should
14 | # make use of Ruby's +Set+ class unless they need backward compatibility.
15 | #
16 | # @example
17 | # set = Sketchup::Set.new
18 | # set.insert(1)
19 | # set.insert(2)
20 | #
21 | # @example Compatibility Shim
22 | # module Example
23 | #
24 | # # Shim for the Set class which was moved in SketchUp 2014
25 | # if defined?(Sketchup::Set)
26 | # # Warning! Do NOT do this in the global namespace!
27 | # Set = Sketchup::Set
28 | # end
29 | #
30 | # def self.test_set_shim
31 | # set = Set.new
32 | # set.insert('Hello')
33 | # set.insert('World')
34 | # puts set.to_a
35 | # end
36 | #
37 | # end
38 | #
39 | # @version SketchUp 6.0
40 | class Sketchup::Set
41 |
42 | # Instance Methods
43 |
44 | # The clear method is used to clear all objects out of the set.
45 | #
46 | # @example
47 | # set = Sketchup::Set.new
48 | # set.insert(1)
49 | # set.insert(2)
50 | # set.insert(3)
51 | # set.clear
52 | #
53 | # @return set - an empty Set object
54 | #
55 | # @version SketchUp 6.0
56 | def clear
57 | end
58 |
59 | # The {#contains?} method is an alias for {#include?}.
60 | #
61 | # @example
62 | # set = Sketchup::Set.new
63 | # set.insert(1)
64 | # set.insert(2)
65 | # set.insert(3)
66 | # p set.contains?(2)
67 | #
68 | # @param [Sketchup::Entity] entity
69 | #
70 | # @return [Boolean]
71 | #
72 | # @see #include?
73 | #
74 | # @version SketchUp 6.0
75 | def contains?(entity)
76 | end
77 |
78 | # The delete object is used to delete or remove an object from the set.
79 | #
80 | # @example
81 | # set = Sketchup::Set.new
82 | # set.insert(1)
83 | # set.insert(2)
84 | # set.delete(1)
85 | #
86 | # @param object
87 | # The object to be deleted.
88 | #
89 | # @return object - the object that was deleted.
90 | #
91 | # @version SketchUp 6.0
92 | def delete(object)
93 | end
94 |
95 | # The each method is used to iterate through all of the objects in the set.
96 | #
97 | # @example
98 | # set = Sketchup::Set.new
99 | # set.insert(1)
100 | # set.insert(2)
101 | # set.insert(3)
102 | # set.each { | item | puts item }
103 | #
104 | # @version SketchUp 6.0
105 | #
106 | # @yield [item]
107 | def each
108 | end
109 |
110 | # The empty? method is used to determine whether the set is empty.
111 | #
112 | # @example
113 | # set = Sketchup::Set.new
114 | # set.insert(1)
115 | # set.insert(2)
116 | # set.insert(3)
117 | # puts set.empty?
118 | #
119 | # @return [Boolean] status - true if the set is empty, false if it is not
120 | # empty.
121 | #
122 | # @version SketchUp 6.0
123 | def empty?
124 | end
125 |
126 | # The {#include?} method is used to determine if the set includes a particular
127 | # object.
128 | #
129 | # @example
130 | # set = Sketchup::Set.new
131 | # set.insert(1)
132 | # set.insert(2)
133 | # set.insert(3)
134 | # p set.include?(2)
135 | #
136 | # @param [Sketchup::Entity] entity
137 | #
138 | # @return [Boolean]
139 | #
140 | # @see #contains?
141 | #
142 | # @version SketchUp 6.0
143 | def include?(entity)
144 | end
145 |
146 | # The insert method is used to insert an object into the set.
147 | #
148 | # @example
149 | # set = Sketchup::Set.new
150 | # set.insert(1)
151 | # set.insert(2)
152 | # set.insert(3)
153 | #
154 | # @param object
155 | # The object to be inserted into the set.
156 | #
157 | # @return size - the number of objects in the set
158 | #
159 | # @version SketchUp 6.0
160 | def insert(object)
161 | end
162 |
163 | # The {#length} method is an alias for {#size}.
164 | #
165 | # @example
166 | # set = Sketchup::Set.new
167 | # set.insert(1)
168 | # set.insert(2)
169 | # set.insert(3)
170 | # puts set.length
171 | #
172 | # @return [Integer]
173 | #
174 | # @see #size
175 | #
176 | # @version SketchUp 6.0
177 | def length
178 | end
179 |
180 | # The {#size} method is used to determine the number of objects in the set.
181 | #
182 | # @example
183 | # set = Sketchup::Set.new
184 | # set.insert(1)
185 | # set.insert(2)
186 | # set.insert(3)
187 | # puts set.size
188 | #
189 | # @return [Integer]
190 | #
191 | # @see #length
192 | #
193 | # @version SketchUp 6.0
194 | def size
195 | end
196 |
197 | # The to_a method is used to get an Array of the entities in your Set.
198 | #
199 | # @example
200 | # set = Sketchup::Set.new
201 | # set.insert('Hello')
202 | # set.insert('World')
203 | # my_array = set.to_a
204 | # UI.messagebox my_array
205 | #
206 | # @return array - The Array of the entities in the Set.
207 | #
208 | # @version SketchUp 6.0
209 | def to_a
210 | end
211 |
212 | end
213 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Layout/Page.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # Class for a single page in a LayOut document.
5 | #
6 | # @version LayOut 2018
7 | class Layout::Page
8 |
9 | # Instance Methods
10 |
11 | # The {#==} method checks to see if the two {Layout::Page}s are equal.
12 | # This checks whether the Ruby Objects are pointing to the same internal
13 | # object.
14 | #
15 | # @example
16 | # doc = Layout::Document.open("C:/path/to/document.layout")
17 | # document = doc.pages.first.document
18 | # doc.pages.first == document.pages.first
19 | #
20 | # @param [Layout::Page] other
21 | #
22 | # @return [Boolean]
23 | #
24 | # @version LayOut 2018
25 | def ==(other)
26 | end
27 |
28 | # The {#document} method returns the {Layout::Document} that the {Layout::Page}
29 | # belongs to.
30 | #
31 | # @example
32 | # doc = Layout::Document.open("C:/path/to/document.layout")
33 | # first_page = doc.pages.first
34 | # # page_doc should reference the same document as doc
35 | # page_doc = first_page.document
36 | #
37 | # @return [Layout::Document]
38 | #
39 | # @version LayOut 2018
40 | def document
41 | end
42 |
43 | # The {#entities} method returns all {Layout::Entity}s that are on the
44 | # {Layout::Page}. This is the equivalent of iterating over all
45 | # {Layout::LayerInstance}s and using {Layout::LayerInstance.entities}.
46 | #
47 | # @example
48 | # doc = Layout::Document.open("C:/path/to/document.layout")
49 | # first_page = doc.pages.first
50 | # entities = first_page.entities
51 | #
52 | # @return [Layout::Entities]
53 | #
54 | # @version LayOut 2018
55 | def entities
56 | end
57 |
58 | # The {#in_presentation=} method sets whether the {Layout::Page} is included in
59 | # presentations.
60 | #
61 | # @example
62 | # doc = Layout::Document.open("C:/path/to/document.layout")
63 | # first_page = doc.pages.first
64 | # first_page.in_presentation = true
65 | #
66 | # @param [Boolean] in_presentation
67 | #
68 | # @version LayOut 2018
69 | def in_presentation=(in_presentation)
70 | end
71 |
72 | # The {#in_presentation?} method returns whether the {Layout::Page} is included
73 | # in presentations.
74 | #
75 | # @example
76 | # doc = Layout::Document.open("C:/path/to/document.layout")
77 | # first_page = doc.pages.first
78 | # in_presentation = first_page.in_presentation?
79 | #
80 | # @return [Boolean]
81 | #
82 | # @version LayOut 2018
83 | def in_presentation?
84 | end
85 |
86 | # The {#layer_instances} method returns an array of the {Layout::LayerInstance}s
87 | # for the {Layout::Page}.
88 | #
89 | # @example
90 | # # An example of page.layer_instances
91 | #
92 | # @return [Array]
93 | #
94 | # @version LayOut 2018
95 | def layer_instances
96 | end
97 |
98 | # The {#layer_visible?} method returns whether a {Layout::Layer} is visible
99 | # on the {Layout::Page}.
100 | #
101 | # @example
102 | # doc = Layout::Document.open("C:/path/to/document.layout")
103 | # first_page = doc.pages.first
104 | # layer = doc.layers.first
105 | # visible = first_page.layer_visible?(layer)
106 | #
107 | # @param [Layout::Layer] layer
108 | #
109 | # @raise [ArgumentError] if layer and page are not in the same document
110 | #
111 | # @return [Boolean]
112 | #
113 | # @version LayOut 2018
114 | def layer_visible?(layer)
115 | end
116 |
117 | # The {#name} method returns the name of the {Layout::Page}.
118 | #
119 | # @example
120 | # doc = Layout::Document.open("C:/path/to/document.layout")
121 | # pages = doc.pages
122 | # first_page_name = pages.first.name
123 | #
124 | # @return [String]
125 | #
126 | # @version LayOut 2018
127 | def name
128 | end
129 |
130 | # The {#name=} method sets the name of a page.
131 | #
132 | # @example
133 | # doc = Layout::Document.open("C:/path/to/document.layout")
134 | # pages = doc.pages
135 | # pages.first.name = "First page"
136 | #
137 | # @param [String] name
138 | #
139 | # @raise [ArgumentError] if name is an empty string
140 | #
141 | # @version LayOut 2018
142 | def name=(name)
143 | end
144 |
145 | # The {#nonshared_entities} method returns the {Layout::Entities}
146 | # unique to the {Layout::Page}.
147 | #
148 | # @example
149 | # doc = Layout::Document.open("C:/path/to/document.layout")
150 | # first_page = doc.pages.first
151 | # entities = first_page.nonshared_entities
152 | #
153 | # @return [Layout::Entities]
154 | #
155 | # @version LayOut 2018
156 | def nonshared_entities
157 | end
158 |
159 | # The {#set_layer_visibility} method sets whether a {Layout::Layer} is visible
160 | # on the {Layout::Page}.
161 | #
162 | # @example
163 | # doc = Layout::Document.open("C:/path/to/document.layout")
164 | # first_page = doc.pages.first
165 | # layer = doc.layers.first
166 | # first_page.set_layer_visibility(layer, false)
167 | #
168 | # @param [Layout::Layer] layer
169 | #
170 | # @param [Boolean] visible
171 | #
172 | # @raise [ArgumentError] if layer and page are not in the same document
173 | #
174 | # @raise [ArgumentError] if layer could not be hidden because there must be at
175 | # least one unlocked, visible layer on each page
176 | #
177 | # @return [Boolean]
178 | #
179 | # @version LayOut 2018
180 | def set_layer_visibility(layer, visible)
181 | end
182 |
183 | end
184 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/Animation.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # The {Sketchup::Animation} interface is implemented to create animations
5 | # inside SketchUp. At any given time, a single animation can be active on a
6 | # {Sketchup::View}. To make your own, build a Ruby class that contains the
7 | # methods described below:
8 | #
9 | # # This is an example of a simple animation that floats the camera up to
10 | # # a z position of 200". The only required method for an animation is
11 | # # nextFrame. It is called whenever you need to show the next frame of
12 | # # the animation. If nextFrame returns false, the animation will stop.
13 | # class FloatUpAnimation
14 | # def nextFrame(view)
15 | # new_eye = view.camera.eye
16 | # new_eye.z = new_eye.z + 1.0
17 | # view.camera.set(new_eye, view.camera.target, view.camera.up)
18 | # view.show_frame
19 | # return new_eye.z < 500.0
20 | # end
21 | # end
22 | #
23 | # # This adds an item to the Camera menu to activate our custom animation.
24 | # UI.menu("Camera").add_item("Run Float Up Animation") {
25 | # Sketchup.active_model.active_view.animation = FloatUpAnimation.new
26 | # }
27 | #
28 | # {Sketchup::Animation} objects are activated by using the
29 | # {Sketchup::View#animation=} method on a {Sketchup::View}
30 | # object. To stop an animation set the view's animation object to +nil+, like
31 | # so:
32 | #
33 | # Sketchup.active_model.active_view.animation = nil
34 | #
35 | # @abstract Implement the methods described in this class to create a an
36 | # animation. You can not sub-class this class because it is not defined by
37 | # the API.
38 | #
39 | # @version SketchUp 6.0
40 | class Sketchup::Animation
41 |
42 | # Instance Methods
43 |
44 | # The {#nextFrame} method is invoked by SketchUp to tell the animation to
45 | # display its next frame. This method should set up the camera and then call
46 | # {Sketchup::View#show_frame}.
47 | #
48 | # The {#nextFrame} method is the only required method of the
49 | # {Sketchup::Animation} interface that you must implement.
50 | #
51 | # @example
52 | # def nextFrame(view)
53 | # # Insert your handler code for updating the camera or other entities.
54 | # view.show_frame
55 | # return true
56 | # end
57 | #
58 | # @param [Sketchup::View] view
59 | # The view for the animation.
60 | #
61 | # @return [Boolean] continue - +true+ if you want the animation to continue
62 | # on to the next frame, +false+ if you want the animation
63 | # to stop after this frame.
64 | #
65 | # @version SketchUp 6.0
66 | #
67 | # @version SketchUp 6.0
68 | def nextFrame(view)
69 | end
70 |
71 | # The {#pause} method is invoked by SketchUp when the animation is paused.
72 | #
73 | # This method is optional (you do not need to implement this method unless you
74 | # want to perform some specialized function when the animation is paused). You
75 | # cannot call this method in your code explicitly and expect an animation to
76 | # pause, only certain SketchUp events cause the method to be called.
77 | #
78 | # @example
79 | # def pause
80 | # # Insert handler code for whatever you need to do when it is paused.
81 | # end
82 | #
83 | # @note The user interface for pausing and resuming animations isn't integrated
84 | # with the Ruby API in the current version, so this method is probably not
85 | # useful to you.
86 | #
87 | # @return [nil]
88 | #
89 | # @version SketchUp 6.0
90 | def pause
91 | end
92 |
93 | # The {#resume} method is invoked by SketchUp when the animation is resumed
94 | # after being paused.
95 | #
96 | # This method is optional (you do not need to implement this method unless you
97 | # want to perform some specialized function when the animation is resumed).
98 | # You cannot call this method in your code explicitly and expect an animation
99 | # to stop, only certain SketchUp events cause the method to be called.
100 | #
101 | # @example
102 | # def resume
103 | # # Insert your handler code for whatever you need to do as you resume.
104 | # end
105 | #
106 | # @note The user interface for pausing and resuming animations isn't integrated
107 | # with the Ruby API in the current version, so this method is probably not
108 | # useful to you.
109 | #
110 | # @return [nil]
111 | #
112 | # @version SketchUp 6.0
113 | def resume
114 | end
115 |
116 | # The {#stop} method is invoked by SketchUp when the animation is stopped.
117 | #
118 | # This method is optional (you do not need to implement this method unless you
119 | # want to perform some specialized function when the animation is stopped). You
120 | # cannot call this method in your code explicitly and expect an animation to
121 | # stop, only certain SketchUp events cause the method to be called.
122 | #
123 | # Perhaps the most common way for this method to be called is when your Ruby
124 | # code sets {Sketchup::View#animation=} to +nil+. See the class comments for
125 | # an example of this.
126 | #
127 | # @example
128 | # class MyAnimation
129 | # def stop
130 | # # Insert your handler code for cleaning up after your animation.
131 | # end
132 | # end
133 | #
134 | # @note Do not call {#Sketchup::View#animation=} from this method. This will
135 | # cause a recursive loop and crash SketchUp 2017 and earlier versions.
136 | # As of SketchUp 2018 this will raise a +RunTimeError+.
137 | #
138 | # @return [nil]
139 | #
140 | # @version SketchUp 6.0
141 | def stop
142 | end
143 |
144 | end
145 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/ToolsObserver.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # This observer interface is implemented to react to tool events.
5 | #
6 | # Some of the code below mentions +tool_names+ and +tool_ids+. Here is a list
7 | # of the common tool IDs and names:
8 | #
9 | # - +21013+ = 3DTextTool
10 | # - +21065+ = ArcTool
11 | # - +10523+ = CameraDollyTool
12 | # - +10508+ = CameraOrbitTool
13 | # - +10525+ = CameraPanTool
14 | # - +21169+ = PositionCameraTool
15 | # - +10520+ = CameraWalkTool
16 | # - +10509+ = CameraZoomTool
17 | # - +10526+ = CameraZoomWindowTool
18 | # - +21096+ = CircleTool
19 | # - +21013+ = ComponentTool
20 | # - +21126+ = ComponentCSTool
21 | # - +21410+ = DimensionTool
22 | # - +21019+ = EraseTool
23 | # - +21031+ = FreehandTool
24 | # - +21525+ = ExtrudeTool
25 | # - +21126+ = SketchCSTool
26 | # - +21048+ = MoveTool
27 | # - +21024+ = MeasureTool
28 | # - +21100+ = OffsetTool
29 | # - +21074+ = PaintTool
30 | # - +21013+ = PasteTool
31 | # - +21095+ = PolyTool
32 | # - +21515+ = PositionTextureTool
33 | # - +21041+ = PushPullTool
34 | # - +21057+ = ProtractorTool
35 | # - +21094+ = RectangleTool
36 | # - +21129+ = RotateTool
37 | # - +21236+ = ScaleTool
38 | # - +21022+ = SelectionTool
39 | # - +21337+ = SectionPlaneTool
40 | # - +21020+ = SketchTool
41 | # - +21405+ = TextTool
42 | #
43 | # @abstract To implement this observer, create a Ruby class of this type,
44 | # override the desired methods, and add an instance of the observer to the
45 | # {Sketchup::Tools} object.
46 | #
47 | # @example
48 | # # This is an example of an observer that watches tool interactions.
49 | # class MyToolsObserver < Sketchup::ToolsObserver
50 | # def onActiveToolChanged(tools, tool_name, tool_id)
51 | # puts "onActiveToolChanged: #{tool_name}"
52 | # end
53 | # end
54 | #
55 | # # Attach the observer.
56 | # Sketchup.active_model.tools.add_observer(MyToolsObserver.new)
57 | #
58 | # @version SketchUp 6.0
59 | class Sketchup::ToolsObserver
60 |
61 | # Instance Methods
62 |
63 | # Once you subclass {Sketchup::ToolsObserver} with your unique class, you can
64 | # override the {#onActiveToolChanged} method to receive tool change
65 | # notifications.
66 | #
67 | # @example
68 | # def onActiveToolChanged(tools, tool_name, tool_id)
69 | # tool_name = fix_mac_tool_name(tool_name)
70 | # puts "onActiveToolChanged: #{tool_name}"
71 | # end
72 | #
73 | # # Returns the "correct" tool name to account for mac API differences.
74 | # #
75 | # # Args:
76 | # # tool_name The tool name to fix
77 | # #
78 | # # Returns
79 | # # string corrected tool name
80 | # def fix_mac_tool_name(tool_name)
81 | # if tool_name == "eTool"
82 | # tool_name = "ScaleTool"
83 | # elsif tool_name == "ool"
84 | # tool_name = "MoveTool"
85 | # elsif tool_name == "onentCSTool"
86 | # tool_name = "ComponentCSTool"
87 | # elsif tool_name == "PullTool"
88 | # tool_name = "PushPullTool"
89 | # end
90 | # return tool_name
91 | # end
92 | #
93 | # @note In SketchUp 6 and SketchUp 7.0, tool names on the Mac have some of
94 | # their first characters truncated. For instance, on Windows, a tool is
95 | # +"CameraOrbit"+. On the Mac, is comes across as +"raOrbit"+. Therefore,
96 | # use the +tool_id+ to keep track of which tool you need to watch for, or use
97 | # logic that corrects for the error. There is an example method of one way to
98 | # do this shown below. (This example is not a comprehensive list of the tool
99 | # names.)
100 | #
101 | # @param [Sketchup::Tools] tools
102 | # A Tools object.
103 | #
104 | # @param [String] tool_name
105 | # The name of the tool.
106 | #
107 | # @param [Integer] tool_id
108 | # The ID of the tool. This is a predefined number
109 | # unique to a given tool. For example, the Materials Browser is tool_id
110 | # 21074.
111 | #
112 | # @return [nil]
113 | #
114 | # @version SketchUp 6.0
115 | def onActiveToolChanged(tools, tool_name, tool_id)
116 | end
117 |
118 | # The {#onToolStateChanged} method is called each time the user performs an
119 | # action with a tool. The actual state that is returned is an internal number
120 | # that varies tool to tool. If you want to watch existing tools for every
121 | # interaction, you will need to experiment with the tool state to determine
122 | # which states you care about. There is little consistency tool to tool.
123 | #
124 | # @example
125 | # def onToolStateChanged(tools, tool_name, tool_id, tool_state)
126 | # puts "onToolStateChanged: #{tool_name}:#{tool_state}"
127 | # end
128 | #
129 | # @note In SketchUp 6 and SketchUp 7, tool names on the Mac have their first
130 | # few characters truncated. For instance, on Windows, a tool is
131 | # +"CameraOrbit".+ On the Mac, is comes across as +"raOrbit"+. Therefore,
132 | # use the tool_id to keep track of which tool you need to watch for, or use
133 | # logic that corrects for the error. This bug was fixed in SketchUp 8.0.
134 | #
135 | # @param [Sketchup::Tools] tools
136 | # A Tools object.
137 | #
138 | # @param [String] tool_name
139 | # The name of the tool.
140 | #
141 | # @param [Integer] tool_id
142 | # The ID of the tool. This is a predefined number
143 | # unique to a given tool. For example, the Materials Browser is tool_id
144 | # 21074.
145 | #
146 | # @param [Integer] tool_state
147 | # A number identifying the state the tool just
148 | # entered.
149 | #
150 | # @return [nil]
151 | #
152 | # @version SketchUp 6.0
153 | def onToolStateChanged(tools, tool_name, tool_id, tool_state)
154 | end
155 |
156 | end
157 |
--------------------------------------------------------------------------------
/pages/intellectual_property.md:
--------------------------------------------------------------------------------
1 | # @title Protecting Intellectual Property
2 |
3 | # Protecting the Intellectual Property in your SketchUp Extensions
4 |
5 | The code you write in your extensions is your intellectual property. You may choose to open source it or you might want to keep it hidden so no one else can see it. In this guide we’ll explain why hiding it can be tricky and what you need to know to protect your IP.
6 |
7 | ## Ruby code is visible. Period.
8 |
9 | If you simply distribute your extension in an .rb file, anyone can open that file and see the code you’ve written. This is true even if your ruby file is wrapped in an .rbz file. This obviously isn’t good if you don’t want people to see your code. You can obscure your code through encryption and that’s a good step but even that’s not perfect protection.
10 |
11 | Unlike languages like C that must be compiled into machine language, Ruby runs inside an interpreter. Even if you’ve encrypted your code it must be decrypted in order to run. If someone is determined enough, there are ways to expose your Ruby code from within the running process.
12 |
13 | So is it hopeless to try to hide your source code? Should you just give up on writing extensions? No! But you should explore the options and choose what works best for you. Read on to learn more.
14 |
15 | ## Encryption can be broken
16 |
17 | No encryption is perfect. Like the lock on your door, it’ll keep out the vast majority of people but if someone is determined enough they’ll find a way in. And there are a lot of determined hackers out there. Some are malicious and some just enjoy solving puzzles but the end result is that secure encryption remains a moving target.
18 |
19 | ## RBS and RBE options
20 |
21 | Over the years we’ve provided two encrypted file formats for SketchUp extensions: .RBS and .RBE files. RBS (which is no longer offered) used a scrambling technology. RBE is the newer format that uses a more sophisticated encryption. Neither of these have been infallible though and we don’t recommend depending solely on them to protect your code.
22 |
23 | ## Encryptors, obfuscators, and minifiers
24 |
25 | Other developers use tools to make their Ruby code harder to understand. Obfuscators make your code more complex, and minifiers remove all unnecessary characters in your code. Both techniques try not to change the functionality of your code but serve to make it harder to read.
26 |
27 | ## Compiling your code into a C library
28 |
29 | One of the best ways to hide your code is to write it in C and compile it into a library. Unlike with Ruby where you need to distribute your source code, your compiled C code has been translated into machine language binary files. The machine instructions are still human readable with the right tools but they are much more difficult to understand than the original C.
30 |
31 | But make no mistake, even this doesn’t completely obscure your logic. Yes, it protects your source code because there’s no way to rehydrate your exact code (including comments and variable names), but a determined hacker can use decompilation to expose your logic. This is true for all software written in compiled code, not just SketchUp extensions. Decompilation is sometimes referred to as turning a sausage back into a pig. There’s only so much that can be done, but with the right tools you can at least get the sausage into the shape of a pig.
32 |
33 | Your C extension will still need Ruby code but if you keep your Ruby simple (e.g. just the UI code) then you have less to lose from someone stealing this code.
34 |
35 | ## Layering multiple levels of protection
36 |
37 | As a best practice we recommend layering multiple levels of protection so you don’t have a single point of failure.
38 |
39 | Also consider what you are protecting against. Are you protecting your license logic from being tampered with, or are you trying to protect the intellectual property in your source code? Not all risks are equal. Your logic for setting up menus and dialogs is not likely to be as important as your algorithms. Focus on protecting the parts of your product that make it special.
40 |
41 | ## Consider Alternatives
42 | Would it be acceptable for you to open source your software? There are businesses that make a living out of producing open source software. They earn their income by selling services and support related to the software, despite the fact that their entire source code is open to everyone, legally free to copy and modify. The experience, service, and support of a product is also a vital part of its value.
43 |
44 | ## Summary
45 | Protecting your software product is a constant arms race, and your time is valuable. You’ll need to decide how important it is to protect your source code. You may also want to keep in mind that not every illegal copy equals a lost sale. Many users of pirated software wouldn't have paid for it in the first place. Giving your code an open source license and allowing others to freely use it can let you avoid the hassles from hiding your code.
46 |
47 | But this isn’t always desirable or even possible. If you need to protect your code from prying eyes, our recommendation for most developers is to use a layered approach. Don't rely on a single solution. Ideally you have control over at least one of these solutions so you can swap it out if needed. In the end this is a cost/effort/gain balance that will differ from case to case.
48 |
49 | ## Further Reading
50 | - [Obfuscation and Decompilation](https://jonskeet.uk/csharp/obfuscation.html)
51 | - [Protecting your code from decompilation](https://stackoverflow.com/a/2478504/486990)
52 | - [Obfuscators](https://stackoverflow.com/a/19525834/486990)
53 | - [NDepend decompilation protection](https://blog.ndepend.com/dont-rely-on-someone-else-to-protect-your-software/)
54 | - [Is obfuscation worth it?](https://security.stackexchange.com/a/107076/87978)
55 | - [Does obfuscation have a security benefit?](https://security.stackexchange.com/a/219347/87978)
56 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Layout/Entities.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # The Entities class is a container class for {Layout::Entity}s. A
5 | # {Layout::Entities} object is different from a SketchUp::Entities object in
6 | # that it is read-only. Adding or removing {Layout::Entity}s from a
7 | # {Layout::Document} happens with the {Layout::Document#add_entity} and
8 | # {Layout::Document#remove_entity} methods.
9 | #
10 | # The {Layout::Entities} from {Layout::AngularDimension#entities},
11 | # {Layout::Label#entities}, {Layout::LinearDimension#entities}, or
12 | # {Layout::Table#entities} contains the {Layout::Entity}s that represent the
13 | # {Layout::Entity} in its exploded form.
14 | #
15 | # The {Layout::Entities} from {Layout::Group#entities} contains all the
16 | # {Layout::Entity}s that belong to the {Layout::Group}.
17 | #
18 | # The {Layout::Entities} from {Layout::Page#entities} contains all of the
19 | # {Layout::Entity}s on both shared and non-shared {Layout::Layer}s. This class
20 | # is used to iterate through the {Layout::Entity}s in draw order or pick order
21 | # (reverse draw order) using the {#each} and {#reverse_each} methods.
22 | #
23 | # The {Layout::Entities} from {Layout::Document#shared_entities} contains all
24 | # of the {Layout::Entity}s that belong on all shared {Layout::Layer}s.
25 | #
26 | # The {Layout::Entities} from {Layout::Page#nonshared_entities} contains all of
27 | # the {Layout::Entity}s that belong to that {Layout::Page}.
28 | #
29 | # The {Layout::Entities} from {Layout::LayerInstance#entities} contains all of
30 | # the {Layout::Entity}s that belong on that {Layout::LayerInstance}.
31 | #
32 | # @example
33 | # # Grab a handle to a pages entities
34 | # doc = Layout::Document.open("C:/path/to/document.layout")
35 | # entities = doc.pages.first.entities
36 | #
37 | # # From here, we can iterate over the entities in draw order or pick order
38 | # entities.each { |entity|
39 | # puts entity
40 | # }
41 | # entities.reverse_each(skip_locked: true) { |entity|
42 | # puts entity
43 | # }
44 | #
45 | # @version LayOut 2018
46 | class Layout::Entities
47 |
48 | # Includes
49 |
50 | include Enumerable
51 |
52 | # Instance Methods
53 |
54 | # The {#[]} method returns the {Layout::Entity} at the given index. This method
55 | # is not valid for use when the {Layout::Entities} object came from a
56 | # {Layout::Page}.
57 | #
58 | # @example
59 | # table = Layout::Table.new([1, 1, 4, 4], 4, 4)
60 | # entities = table.entities
61 | # entity = entities[10]
62 | #
63 | # @param [Integer] index
64 | #
65 | # @raise [ArgumentError] if this came from a {Layout::Page}
66 | #
67 | # @return [Layout::Entity]
68 | #
69 | # @version LayOut 2018
70 | def [](index)
71 | end
72 |
73 | # The {#each} method iterates through all of the {Layout::Entity}s. When
74 | # iterating over a {Layout::LayerInstance}'s {Layout::Entities}, it is not
75 | # necessary to provide a flags Hash. When iterating over a {Layout::Page}'s
76 | # {Layout::Entities}, the flags Hash is optional; providing no Hash will
77 | # result in iterating over all {Layout::Entity}s, including those on hidden or
78 | # locked {Layout::Layer}s. Valid symbols for the Hash are +:skip_hidden+ and
79 | # +:skip_locked+.
80 | #
81 | # @example
82 | # doc = Layout::Document.open("C:/path/to/document.layout")
83 | # flags = { :skip_hidden => true }
84 | # entities = doc.pages.first.entities
85 | # entities.each(flags) { |entity|
86 | # puts entity
87 | # }
88 | #
89 | # @note Don't remove content from this collection while iterating over it with
90 | # {#each}. This would change the size of the collection and cause elements to
91 | # be skipped as the indices change. Instead copy the current collection to an
92 | # array using +to_a+ and then use +each+ on the array, when removing content.
93 | #
94 | # @param [Hash{Symbol => Boolean}] flags
95 | # A hash that allows skipping of
96 | # {Layout::Entity}s on hidden or locked {Layout::Layers}
97 | #
98 | # @version LayOut 2018
99 | #
100 | # @yieldparam [Layout::Entity] entity
101 | def each(flags = {})
102 | end
103 |
104 | # The {#length} method returns the number of {Layout::Entity}s.
105 | #
106 | # @example
107 | # doc = Layout::Document.open("C:/path/to/document.layout")
108 | # entities = doc.shared_entities
109 | # num_entities = entities.length
110 | #
111 | # @return [Integer]
112 | #
113 | # @version LayOut 2018
114 | def length
115 | end
116 | alias_method :size, :length
117 |
118 | # The {#reverse_each} method iterates through all of the {Layout::Entity}s in
119 | # reverse order. When iterating over a {Layout::LayerInstance}'s
120 | # {Layout::Entities}, it is not necessary to provide a flags Hash. When
121 | # iterating over a {Layout::Page}'s {Layout::Entities}, the flags Hash is
122 | # optional; providing no Hash will result in iterating over all
123 | # {Layout::Entity}s, including those on hidden or locked {Layout::Layer}s.
124 | # Valid symbols for the Hash are +:skip_hidden+ and +:skip_locked+.
125 | #
126 | # @example
127 | # doc = Layout::Document.open("C:/path/to/document.layout")
128 | # flags = { :skip_hidden => true, :skip_locked => true }
129 | # entities = doc.pages.first.entities
130 | # entities.reverse_each(flags) { |entity|
131 | # puts entity
132 | # }
133 | #
134 | # @overload reverse_each
135 | #
136 | # @yieldparam [Layout::Entity] entity
137 | #
138 | # @overload reverse_each(flags)
139 | #
140 | # @param [Hash{Symbol => Boolean}] flags A hash that allows skipping of
141 | # {Layout::Entity}s on hidden or locked {Layout::Layers}.
142 | # @yieldparam [Layout::Entity] entity
143 | #
144 | # @version LayOut 2018
145 | def reverse_each(*args)
146 | end
147 |
148 | end
149 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/Styles.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # The Styles class contains methods for manipulating a collection of styles in
5 | # a model. Typically, you will access this via the active_model:
6 | #
7 | # @example
8 | # styles = Sketchup.active_model.styles
9 | # puts "There are #{styles.size} styles in your model."
10 | #
11 | # @version SketchUp 6.0
12 | class Sketchup::Styles < Sketchup::Entity
13 |
14 | # Includes
15 |
16 | include Enumerable
17 |
18 | # Instance Methods
19 |
20 | # The {#[]} method is used to retrieves a style by either name or index.
21 | #
22 | # @example
23 | # styles = Sketchup.active_model.styles
24 | # style1 = styles[0]
25 | # style2 = styles["MyStyle"]
26 | #
27 | # @overload [](name)
28 | #
29 | # @param [String] name The name of the style to retrieve.
30 | # @return [Sketchup::Style, nil]
31 | #
32 | # @overload [](index)
33 | #
34 | # @param [Integer] index The index of the style to retrieve.
35 | # @return [Sketchup::Style, nil]
36 | #
37 | # @version SketchUp 6.0
38 | def [](arg)
39 | end
40 |
41 | # The {#active_style} method is used to retrieve the active style.
42 | #
43 | # While {#selected_style} is the style being selected in the Style Browser,
44 | # the #{active_style} is a different object also including any unsaved style
45 | # changes. These changes are silently dropped once a new style is selected.
46 | # To save these changes to the selected style, call #{update_selected_style}.
47 | #
48 | # @example
49 | # styles = Sketchup.active_model.styles
50 | # style = styles.active_style
51 | #
52 | # @return [Sketchup::Style]
53 | #
54 | # @version SketchUp 6.0
55 | def active_style
56 | end
57 |
58 | # The {#active_style_changed} method tells you if the active style has been
59 | # edited by the user since it was last saved.
60 | #
61 | # @example
62 | # styles = Sketchup.active_model.styles
63 | # style_changed = styles.active_style_changed
64 | #
65 | # @return [Boolean]
66 | #
67 | # @version SketchUp 6.0
68 | def active_style_changed
69 | end
70 |
71 | # The {#add_style} method is used to create and load a style from the given
72 | # file.
73 | #
74 | # @example
75 | # filename = File.expand_path('./MyStyle.style')
76 | # styles = Sketchup.active_model.styles
77 | # status = styles.add_style(filename, true)
78 | #
79 | # @param [String] filename
80 | #
81 | # @param [Boolean] select
82 | # +true+ if you want to set the style to be the
83 | # active style.
84 | #
85 | # @return [Boolean]
86 | #
87 | # @version SketchUp 6.0
88 | def add_style(filename, select)
89 | end
90 |
91 | #
92 | # @example
93 | # styles = Sketchup.active_model.styles
94 | # number = styles.count
95 | #
96 | # @note Since SketchUp 2014 the count method is inherited from Ruby's
97 | # +Enumerable+ mix-in module. Prior to that the {#count} method is an alias
98 | # for {#length}.
99 | #
100 | # @return [Integer]
101 | #
102 | # @version SketchUp 6.0
103 | def count
104 | end
105 |
106 | # The {#each} method is used to iterate through styles.
107 | #
108 | # @example
109 | # styles = Sketchup.active_model.styles
110 | # styles.each { |style|
111 | # puts style.name
112 | # }
113 | #
114 | # @return [nil]
115 | #
116 | # @version SketchUp 6.0
117 | #
118 | # @yieldparam [Sketchup::Style] style
119 | def each
120 | end
121 |
122 | # The {#length} method is an alias of {#size}.
123 | #
124 | # @example
125 | # styles = Sketchup.active_model.styles
126 | # number = styles.length
127 | #
128 | # @return [Integer]
129 | #
130 | # @see #size
131 | #
132 | # @version SketchUp 2014
133 | def length
134 | end
135 |
136 | # The {#parent} method is used to return the model for the styles.
137 | #
138 | # @example
139 | # styles = Sketchup.active_model.styles
140 | # model = styles.parent
141 | #
142 | # @return [Sketchup::Model]
143 | #
144 | # @version SketchUp 6.0
145 | def parent
146 | end
147 |
148 | # The {#purge_unused} method is used to remove unused styles from the model.
149 | #
150 | # @example
151 | # styles = Sketchup.active_model.styles
152 | # styles.purge_unused
153 | #
154 | # @return [true]
155 | #
156 | # @version SketchUp 6.0
157 | def purge_unused
158 | end
159 |
160 | # The {#selected_style} method is used to retrieve the style currently
161 | # selected in the Styles Browser.
162 | #
163 | # @example
164 | # styles = Sketchup.active_model.styles
165 | # style = styles.selected_style
166 | #
167 | # @return [Sketchup::Style] style
168 | #
169 | # @version SketchUp 6.0
170 | def selected_style
171 | end
172 |
173 | # The {#selected_style=} method is used to set the currently selected style.
174 | #
175 | # @example
176 | # styles = Sketchup.active_model.styles
177 | # styles.selected_style = styles.last
178 | #
179 | # @param [Sketchup::Style] style
180 | #
181 | # @return [false]
182 | #
183 | # @version SketchUp 6.0
184 | def selected_style=(style)
185 | end
186 |
187 | # The {#size} method is used to retrieve the number of styles in the
188 | # collection.
189 | #
190 | # @example
191 | # styles = Sketchup.active_model.styles
192 | # number = styles.size
193 | #
194 | # @return [Integer]
195 | #
196 | # @see #length
197 | #
198 | # @version SketchUp 6.0
199 | def size
200 | end
201 |
202 | # The {#update_selected_style} method commits the current style settings to the
203 | # style selected in the Style Browser.
204 | #
205 | # @example
206 | # styles = Sketchup.active_model.styles
207 | # styles.update_selected_style
208 | #
209 | # @return [true]
210 | #
211 | # @see #selected_style
212 | #
213 | # @version SketchUp 6.0
214 | def update_selected_style
215 | end
216 |
217 | end
218 |
--------------------------------------------------------------------------------
/lib/sketchup-api-stubs/stubs/Sketchup/AppObserver.rb:
--------------------------------------------------------------------------------
1 | # Copyright:: Copyright 2024 Trimble Inc.
2 | # License:: The MIT License (MIT)
3 |
4 | # This observer interface is implemented to react to application events.
5 | # This interface is often used to attach other observers to models as they
6 | # are opened or started.
7 | # This ensures that your observers are watching all open models.
8 | #
9 | # For example, when one attaches a {Sketchup::SelectionObserver}, it is only
10 | # attached to the {Sketchup::Selection} collection of a given model. If a 2nd
11 | # model is opened, the new model's selection changes will not fire selection
12 | # callbacks unless you've attached a {Sketchup::SelectionObserver} to the new
13 | # model as well. By watching for {#onNewModel}, you can be sure to do so.
14 | #
15 | # @abstract To implement this observer, create a Ruby class of this type, override the
16 | # desired methods, and add an instance of the observer to the
17 | # application class.
18 | #
19 | # @example
20 | # # This is an example of an observer that watches the application for
21 | # # new models and shows a messagebox.
22 | # class MyAppObserver < Sketchup::AppObserver
23 | # def onNewModel(model)
24 | # puts "onNewModel: #{model}"
25 | #
26 | # # Here is where one might attach other observers to the new model.
27 | # model.selection.add_observer(MySelectionObserver.new)
28 | # end
29 | # end
30 | #
31 | # # Attach the observer
32 | # Sketchup.add_observer(MyAppObserver.new)
33 | #
34 | # @version SketchUp 6.0
35 | class Sketchup::AppObserver
36 |
37 | # Instance Methods
38 |
39 | # The {#expectsStartupModelNotifications} method is called to determine if the
40 | # observer expects to receive {#onNewModel} and {#onOpenModel} calls for the
41 | # models that are created or opened at SketchUp startup. This includes the
42 | # empty initial model, a model opened via command line arguments, or
43 | # auto-restored models on Mac OS X.
44 | #
45 | # @example
46 | # def expectsStartupModelNotifications
47 | # return true
48 | # end
49 | #
50 | # @note Prior to SketchUp 2014, {#onNewModel} and {#onOpenModel} were
51 | # not being called for the startup models. This issue is now fixed but
52 | # observers still need to express their intent to receive these calls. This is
53 | # for back-compatibility with existing scripts which worked around these
54 | # missing calls by other means. For new code, this method should be implemented
55 | # and should return +true+.
56 | #
57 | # @return [Boolean] +true+ to receive {#onNewModel} and {#onOpenModel} calls
58 | # for startup models. Return +false+ or simply not
59 | # implement the method in order to not receive these calls
60 | # (which was the behavior prior to SketchUp 2014).
61 | #
62 | # @version SketchUp 2014
63 | def expectsStartupModelNotifications
64 | end
65 |
66 | # The {#onActivateModel} method is called when an open model is activated. This
67 | # is relevant on Mac only which supports multiple documents to be opened
68 | # simultaneously.
69 | #
70 | # @example
71 | # def onActivateModel(model)
72 | # puts "onActivateModel: #{model}"
73 | # end
74 | #
75 | # @param [Sketchup::Model] model
76 | # The newly-activated model object.
77 | #
78 | # @return [nil]
79 | #
80 | # @version SketchUp 2015
81 | def onActivateModel(model)
82 | end
83 |
84 | # The {#onExtensionsLoaded} method is called when SketchUp has finished loading
85 | # all extensions when the application starts.
86 | #
87 | # @example
88 | # def onExtensionsLoaded
89 | # puts "onExtensionsLoaded"
90 | # end
91 | #
92 | # @version SketchUp 2022.0
93 | def onExtensionsLoaded
94 | end
95 |
96 | # The {#onNewModel} method is called when the application creates a new, empty
97 | # model.
98 | #
99 | # @example
100 | # def onNewModel(model)
101 | # puts "onNewModel: #{model}"
102 | # end
103 | #
104 | # @param [Sketchup::Model] model
105 | # The active model object.
106 | #
107 | # @return [nil]
108 | #
109 | # @version SketchUp 6.0
110 | def onNewModel(model)
111 | end
112 |
113 | # The {#onOpenModel} method is called when the application opens an existing
114 | # model.
115 | #
116 | # @example
117 | # def onOpenModel(model)
118 | # puts "onOpenModel: #{model}"
119 | # end
120 | #
121 | # @note If a skp file is loaded via the command line or double-clicking on
122 | # a skp in explorer (which is also is the command line) then this
123 | # observer will not be called. The Ruby interpreter in SketchUp is
124 | # initialized after command line processing so the observer won't
125 | # be added in time to get the notification.
126 | #
127 | # @param [Sketchup::Model] model
128 | # The active model object.
129 | #
130 | # @return [nil]
131 | #
132 | # @version SketchUp 6.0
133 | def onOpenModel(model)
134 | end
135 |
136 | # The {#onQuit} method is called when SketchUp closes. This is useful if you
137 | # need to clean up anything or store your application state upon close.
138 | #
139 | # @example
140 | # def onQuit()
141 | # puts "onQuit"
142 | # end
143 | #
144 | # @return [nil]
145 | #
146 | # @version SketchUp 6.0
147 | def onQuit
148 | end
149 |
150 | # The {#onUnloadExtension} method is called when the user turns off a Ruby
151 | # extension. This is useful for detecting if the user is deactivating
152 | # some critical set of observers, for example, so you can warn them
153 | # or cache your extension state.
154 | #
155 | # @example
156 | # def onUnloadExtension(extension_name)
157 | # puts "onUnloadExtension: #{extension_name}"
158 | # end
159 | #
160 | # @param [String] extension_name
161 | # The name of the extension just unloaded.
162 | #
163 | # @return [nil]
164 | #
165 | # @version SketchUp 7.0
166 | def onUnloadExtension(extension_name)
167 | end
168 |
169 | end
170 |
--------------------------------------------------------------------------------