sketchup-api-stubs 0.7.6 → 0.7.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sketchup-api-stubs/sketchup.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Geom/BoundingBox.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Geom/Bounds2d.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Geom/LatLong.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Geom/OrientedBounds2d.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Geom/Point2d.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Geom/Point3d.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Geom/PolygonMesh.rb +21 -10
- data/lib/sketchup-api-stubs/stubs/Geom/Transformation.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Geom/Transformation2d.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Geom/UTM.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Layout.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Layout/AngularDimension.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Layout/AutoTextDefinition.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Layout/AutoTextDefinitions.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Layout/ConnectionPoint.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Layout/Document.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Layout/Ellipse.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Layout/Entities.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Layout/Entity.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Layout/FormattedText.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Layout/Grid.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Layout/Group.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Layout/Image.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Layout/Label.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Layout/Layer.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Layout/LayerInstance.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Layout/Layers.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Layout/LinearDimension.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Layout/LockedEntityError.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Layout/LockedLayerError.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Layout/Page.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Layout/PageInfo.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Layout/Pages.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Layout/Path.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Layout/Rectangle.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Layout/SketchUpModel.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Layout/Style.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Layout/Table.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Layout/TableCell.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Layout/TableColumn.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Layout/TableRow.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Animation.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/AppObserver.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/ArcCurve.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/AttributeDictionaries.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/AttributeDictionary.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Axes.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Behavior.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Camera.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/ClassificationSchema.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Classifications.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Color.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/ComponentDefinition.rb +2 -2
- data/lib/sketchup-api-stubs/stubs/Sketchup/ComponentInstance.rb +35 -45
- data/lib/sketchup-api-stubs/stubs/Sketchup/Console.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/ConstructionLine.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/ConstructionPoint.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Curve.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionList.rb +76 -13
- data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionObserver.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionsObserver.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Dimension.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionLinear.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionObserver.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionRadial.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Drawingelement.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Edge.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/EdgeUse.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Entities.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/EntitiesObserver.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Entity.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/EntityObserver.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/ExtensionsManager.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Face.rb +224 -58
- data/lib/sketchup-api-stubs/stubs/Sketchup/FrameChangeObserver.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Group.rb +52 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Http.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Http/Request.rb +48 -41
- data/lib/sketchup-api-stubs/stubs/Sketchup/Http/Response.rb +7 -7
- data/lib/sketchup-api-stubs/stubs/Sketchup/Image.rb +52 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/ImageRep.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Importer.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/InputPoint.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/InstanceObserver.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/InstancePath.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Layer.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/LayerFolder.rb +3 -3
- data/lib/sketchup-api-stubs/stubs/Sketchup/Layers.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/LayersObserver.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Licensing.rb +2 -2
- data/lib/sketchup-api-stubs/stubs/Sketchup/Licensing/ExtensionLicense.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/LineStyle.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/LineStyles.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Loop.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Material.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Materials.rb +2 -2
- data/lib/sketchup-api-stubs/stubs/Sketchup/MaterialsObserver.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Menu.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Model.rb +4 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/ModelObserver.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsManager.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsProvider.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsProviderObserver.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Page.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Pages.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/PagesObserver.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/PickHelper.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/RegionalSettings.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/RenderingOptions.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/RenderingOptionsObserver.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/SectionPlane.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Selection.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/SelectionObserver.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Set.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/ShadowInfo.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/ShadowInfoObserver.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Skp.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Style.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Styles.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Text.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Texture.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/TextureWriter.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Tool.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Tools.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/ToolsObserver.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/UVHelper.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Vertex.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/View.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/ViewObserver.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/UI/Command.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/UI/HtmlDialog.rb +98 -7
- data/lib/sketchup-api-stubs/stubs/UI/Notification.rb +69 -55
- data/lib/sketchup-api-stubs/stubs/UI/Toolbar.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/UI/WebDialog.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/_top_level.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/array.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/geom.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/languagehandler.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/length.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/numeric.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/sketchup.rb +12 -1
- data/lib/sketchup-api-stubs/stubs/sketchupextension.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/string.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/ui.rb +8 -4
- metadata +3 -3
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright:: Copyright
|
1
|
+
# Copyright:: Copyright 2021 Trimble Inc.
|
2
2
|
# License:: The MIT License (MIT)
|
3
3
|
|
4
4
|
# The {Sketchup::ComponentDefinition} class is used to define the contents for
|
@@ -20,7 +20,7 @@
|
|
20
20
|
# will be raised. The key/value pairs in the dictionary can be deleted safely.
|
21
21
|
#
|
22
22
|
# @version SketchUp 6.0
|
23
|
-
class Sketchup::ComponentDefinition <
|
23
|
+
class Sketchup::ComponentDefinition < DrawingElement
|
24
24
|
|
25
25
|
# Includes
|
26
26
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright:: Copyright
|
1
|
+
# Copyright:: Copyright 2021 Trimble Inc.
|
2
2
|
# License:: The MIT License (MIT)
|
3
3
|
|
4
4
|
# The {Sketchup::ComponentInstance} class is used to represent component
|
@@ -123,73 +123,63 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
123
123
|
def explode
|
124
124
|
end
|
125
125
|
|
126
|
-
# The glued_to method is used to retrieve the entity that this instance is
|
126
|
+
# The {#glued_to} method is used to retrieve the entity that this instance is
|
127
127
|
# glued to.
|
128
128
|
#
|
129
|
-
# Returns nil if it is not glued to anything.
|
130
|
-
#
|
131
129
|
# @example
|
132
|
-
# point = Geom::Point3d.new
|
133
|
-
# transform = Geom::Transformation.new
|
130
|
+
# point = Geom::Point3d.new(10, 20, 30)
|
131
|
+
# transform = Geom::Transformation.new(point)
|
134
132
|
# model = Sketchup.active_model
|
135
133
|
# entities = model.active_entities
|
136
|
-
# path = Sketchup.find_support_file
|
137
|
-
# "Components/Components Sampler/"
|
134
|
+
# path = Sketchup.find_support_file("Bed.skp", "Components/Components Sampler/")
|
138
135
|
# definitions = model.definitions
|
139
|
-
# componentdefinition = definitions.load
|
140
|
-
# instance = entities.add_instance
|
136
|
+
# componentdefinition = definitions.load(path)
|
137
|
+
# instance = entities.add_instance(componentdefinition, transform)
|
141
138
|
# status = instance.glued_to
|
142
139
|
#
|
143
|
-
# @return [Sketchup::Face,
|
144
|
-
# to (if successful)
|
140
|
+
# @return [Sketchup::Face, Sketchup::Group, Sketchup::ComponentInstance, Sketchup::Image, nil]
|
145
141
|
#
|
146
142
|
# @version SketchUp 6.0
|
147
143
|
def glued_to
|
148
144
|
end
|
149
145
|
|
150
|
-
# The glued_to= method glues this instance to a
|
146
|
+
# The {glued_to=} method glues this instance to a drawing element.
|
147
|
+
# When moving this other drawing elment with the Move tool, the glued instance moves with it.
|
151
148
|
#
|
152
|
-
#
|
153
|
-
#
|
154
|
-
# doesn't support gluing or if the alignment is wrong.
|
149
|
+
# In SketchUp 2021.1 support for passing {Sketchup::Group}, {Sketchup::ComponentInstance} and
|
150
|
+
# {Sketchup::Image} was added.
|
155
151
|
#
|
156
152
|
# @example
|
157
|
-
# depth = 100
|
158
|
-
# width = 100
|
159
|
-
# path=Sketchup.find_support_file "Bed.skp",
|
160
|
-
# "Components/Components Sampler/"
|
161
153
|
# model = Sketchup.active_model
|
162
154
|
# entities = model.active_entities
|
163
|
-
#
|
164
|
-
#
|
165
|
-
#
|
166
|
-
#
|
167
|
-
#
|
168
|
-
#
|
169
|
-
#
|
170
|
-
#
|
171
|
-
# transform = Geom::Transformation.new point
|
155
|
+
#
|
156
|
+
# # Create a face
|
157
|
+
# face = entities.add_face([[0, 0, 0], [100, 0, 0], [100, 100, 0], [0, 100, 0]])
|
158
|
+
#
|
159
|
+
# # Add component
|
160
|
+
# path = Sketchup.find_support_file("Bed.skp", "Components/Components Sampler/")
|
161
|
+
# point = Geom::Point3d.new(10, 10, 0)
|
162
|
+
# transformation = Geom::Transformation.new(point)
|
172
163
|
# definitions = model.definitions
|
173
|
-
#
|
174
|
-
# instance = entities.add_instance
|
175
|
-
# begin
|
176
|
-
# status = instance.glued_to = face
|
177
|
-
# rescue
|
178
|
-
# UI.messagebox $!.message
|
179
|
-
# end
|
180
|
-
# if (status)
|
181
|
-
# UI.messagebox status.to_s
|
182
|
-
# else
|
183
|
-
# UI.messagebox "Failure"
|
184
|
-
# end
|
164
|
+
# definition = definitions.load(path)
|
165
|
+
# instance = entities.add_instance(definition, transformation)
|
185
166
|
#
|
186
|
-
#
|
167
|
+
# # Make component "gluable"
|
168
|
+
# definition.behavior.is2d = true
|
187
169
|
#
|
188
|
-
#
|
189
|
-
#
|
170
|
+
# # Glue the component to the face.
|
171
|
+
# # If you now move the face, the component will follow.
|
172
|
+
# instance.glued_to = face
|
173
|
+
#
|
174
|
+
# @param [Sketchup::Face, Sketchup::Group, Sketchup::ComponentInstance, Sketchup::Image, nil] drawing_element
|
175
|
+
#
|
176
|
+
# @raise ArgumentError if the {Sketchup::Behavior} for this component doesn't allow gluing,
|
177
|
+
# if the alignment is wrong, or if this would lead to cyclic gluing.
|
178
|
+
#
|
179
|
+
# @return [Sketchup::Face, Sketchup::Group, Sketchup::ComponentInstance, Sketchup::Image, nil] the entity the instance was glued to.
|
190
180
|
#
|
191
181
|
# @version SketchUp 6.0
|
192
|
-
def glued_to=(
|
182
|
+
def glued_to=(drawing_element)
|
193
183
|
end
|
194
184
|
|
195
185
|
# The guid method is used to get the base 64 encoded unique id
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright:: Copyright
|
1
|
+
# Copyright:: Copyright 2021 Trimble Inc.
|
2
2
|
# License:: The MIT License (MIT)
|
3
3
|
|
4
4
|
# A DefinitionList object holds a list of all of the ComponentDefinition
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# definitions from the list.
|
7
7
|
#
|
8
8
|
# @version SketchUp 6.0
|
9
|
-
class Sketchup::DefinitionList <
|
9
|
+
class Sketchup::DefinitionList < Entity
|
10
10
|
|
11
11
|
# Includes
|
12
12
|
|
@@ -153,6 +153,33 @@ class Sketchup::DefinitionList < Sketchup::Entity
|
|
153
153
|
def each
|
154
154
|
end
|
155
155
|
|
156
|
+
# The {#import} method is used to import a (non-SketchUp) 3d model file as a definition.
|
157
|
+
#
|
158
|
+
# Importers using the C API +SketchUpModelImporterInterface+ interface are supported (those in the +Importers/+ directory).
|
159
|
+
#
|
160
|
+
# See the {file:pages/importer_options.md Importer Options} file for information
|
161
|
+
# on creating a valid hash for the various importers.
|
162
|
+
#
|
163
|
+
# For SketchUp models, instead use {#load}.
|
164
|
+
#
|
165
|
+
# @example
|
166
|
+
# path = "C:/circle.dwg"
|
167
|
+
# definition = Sketchup.active_model.definitions.import(path)
|
168
|
+
#
|
169
|
+
# @param [String] path
|
170
|
+
#
|
171
|
+
# @param [Hash] options
|
172
|
+
#
|
173
|
+
# @raise [IOError] if the file is missing.
|
174
|
+
#
|
175
|
+
# @raise [ArgumentError] if no suitable importer could be found.
|
176
|
+
#
|
177
|
+
# @return [Sketchup::ComponentDefinition]
|
178
|
+
#
|
179
|
+
# @version SketchUp 2021.1
|
180
|
+
def import(path, options = {})
|
181
|
+
end
|
182
|
+
|
156
183
|
# The {#length} method is used to retrieve number of component definitions in
|
157
184
|
# the list.
|
158
185
|
#
|
@@ -218,20 +245,28 @@ class Sketchup::DefinitionList < Sketchup::Entity
|
|
218
245
|
end
|
219
246
|
|
220
247
|
# The {#load_from_url} method loads a component from a location specified by
|
221
|
-
# string url.
|
222
|
-
# given, or an error occurs during retrieval from url and a
|
223
|
-
# load_handler was not given. Optional second parameter load_handler can be
|
224
|
-
# used to pass in a ruby object that responds to the following methods:
|
248
|
+
# string url.
|
225
249
|
#
|
226
|
-
#
|
227
|
-
#
|
228
|
-
#
|
229
|
-
#
|
250
|
+
# This method throws an exception if an url string is not
|
251
|
+
# given, or an error occurs during retrieval from URL and a
|
252
|
+
# +load_handler+ was not given. Optional second parameter +load_handler+ can be
|
253
|
+
# used to pass in a Ruby object that responds to the following methods:
|
230
254
|
#
|
231
|
-
#
|
255
|
+
# - +cancelled?+
|
256
|
+
# - +onPercentChange(percent)+
|
257
|
+
# - +onSuccess()+
|
258
|
+
# - +onFailure(message_string)+
|
259
|
+
#
|
260
|
+
# @bug Calling this method from an {UI::HtmlDialog}'s action callback on macOS will cause the
|
261
|
+
# SketchUp application to become unresponsive. To work around this, defer the call from the
|
262
|
+
# action callback with a non-repeating zero-delay timer;
|
263
|
+
# +UI.start_timer(0, false) { method_calling_load_from_url }+
|
264
|
+
#
|
265
|
+
# @example Download a component using a LoadHandler
|
232
266
|
# class LoadHandler
|
233
267
|
# attr_accessor :error
|
234
268
|
#
|
269
|
+
# # @param [Float] percent
|
235
270
|
# def onPercentChange(percent)
|
236
271
|
# Sketchup::set_status_text("loading: #{percent.round}%")
|
237
272
|
# end
|
@@ -247,6 +282,7 @@ class Sketchup::DefinitionList < Sketchup::Entity
|
|
247
282
|
# Sketchup::set_status_text('')
|
248
283
|
# end
|
249
284
|
#
|
285
|
+
# # @param [String] error_message
|
250
286
|
# def onFailure(error_message)
|
251
287
|
# self.error = error_message
|
252
288
|
# Sketchup::set_status_text('')
|
@@ -254,7 +290,7 @@ class Sketchup::DefinitionList < Sketchup::Entity
|
|
254
290
|
# end
|
255
291
|
#
|
256
292
|
# # Replace this with a real URL...
|
257
|
-
# url = '
|
293
|
+
# url = 'https://www.sketchup.com/model.skp'
|
258
294
|
# model = Sketchup.active_model
|
259
295
|
# load_handler = LoadHandler.new
|
260
296
|
# definition = model.definitions.load_from_url(url, load_handler)
|
@@ -263,6 +299,33 @@ class Sketchup::DefinitionList < Sketchup::Entity
|
|
263
299
|
# puts "Error: #{load_handler.error}"
|
264
300
|
# end
|
265
301
|
#
|
302
|
+
# @example Workaround for macOS bug related to HtmlDialog action callbacks
|
303
|
+
# module Example
|
304
|
+
#
|
305
|
+
# def self.open_dialog
|
306
|
+
# @dialog = UI::HtmlDialog.new
|
307
|
+
# @dialog.add_action_callback("say") { |action_context, url|
|
308
|
+
# self.load_component_deferred(url)
|
309
|
+
# }
|
310
|
+
# @dialog.set_file("path/to/file.html")
|
311
|
+
# @dialog.show
|
312
|
+
# end
|
313
|
+
#
|
314
|
+
# def load_component_deferred
|
315
|
+
# # The timer delay is enough to avoid .load_from_url from deadlocking.
|
316
|
+
# UI.start_timer(0, false) do
|
317
|
+
# self.load_component(url)
|
318
|
+
# end
|
319
|
+
# end
|
320
|
+
#
|
321
|
+
# def self.load_component(url)
|
322
|
+
# model = Sketchup.active_model
|
323
|
+
# definition = model.definitions.load_from_url(url)
|
324
|
+
# # ...
|
325
|
+
# end
|
326
|
+
#
|
327
|
+
# end
|
328
|
+
#
|
266
329
|
# @overload load_from_url(url)
|
267
330
|
#
|
268
331
|
# @param [String] url
|
@@ -274,7 +337,7 @@ class Sketchup::DefinitionList < Sketchup::Entity
|
|
274
337
|
# URL to load a .skp file from.
|
275
338
|
# @param [Object] load_handler
|
276
339
|
# Ruby object that has methods defined
|
277
|
-
# as described in the load_from_url details.
|
340
|
+
# as described in the +load_from_url+ details above.
|
278
341
|
#
|
279
342
|
# @return [Sketchup::ComponentDefinition]
|
280
343
|
#
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright:: Copyright
|
1
|
+
# Copyright:: Copyright 2021 Trimble Inc.
|
2
2
|
# License:: The MIT License (MIT)
|
3
3
|
|
4
4
|
# Faces in SketchUp are flat, 2-sided polygons with 3 or more sides.
|
@@ -200,6 +200,21 @@ class Sketchup::Face < Sketchup::Drawingelement
|
|
200
200
|
def classify_point(point)
|
201
201
|
end
|
202
202
|
|
203
|
+
# The {#clear_texture_projection} method is used to clear the texture
|
204
|
+
# projection. This is similar to toggling off Projection from the Position
|
205
|
+
# Texture tool in the UI.
|
206
|
+
#
|
207
|
+
# @param [Boolean] frontside
|
208
|
+
# +true+ for front side, +false+ for back side.
|
209
|
+
#
|
210
|
+
# @see #position_material
|
211
|
+
#
|
212
|
+
# @see #get_texture_projection
|
213
|
+
#
|
214
|
+
# @version SketchUp 2021.1
|
215
|
+
def clear_texture_projection(frontside)
|
216
|
+
end
|
217
|
+
|
203
218
|
# The edges method is used to get an array of edges that bound the face.
|
204
219
|
#
|
205
220
|
# @example
|
@@ -331,7 +346,7 @@ class Sketchup::Face < Sketchup::Drawingelement
|
|
331
346
|
def get_glued_instances
|
332
347
|
end
|
333
348
|
|
334
|
-
# The get_texture_projection method will return a vector representing the
|
349
|
+
# The {#get_texture_projection} method will return a vector representing the
|
335
350
|
# projection for either the front or back side of the face.
|
336
351
|
#
|
337
352
|
# @example
|
@@ -365,9 +380,14 @@ class Sketchup::Face < Sketchup::Drawingelement
|
|
365
380
|
# vector = face.get_texture_projection(true)
|
366
381
|
#
|
367
382
|
# @param [Boolean] frontside
|
368
|
-
# true for front side, false for back side.
|
383
|
+
# +true+ for front side, +false+ for back side.
|
384
|
+
#
|
385
|
+
# @return [Geom::Vector3d, nil] a vector on success, +nil+ if face is not
|
386
|
+
# textured with a projected texture mapping.
|
387
|
+
#
|
388
|
+
# @see #position_material
|
369
389
|
#
|
370
|
-
# @
|
390
|
+
# @see #texture_projected?
|
371
391
|
#
|
372
392
|
# @version SketchUp 2014
|
373
393
|
def get_texture_projection(frontside)
|
@@ -568,25 +588,26 @@ class Sketchup::Face < Sketchup::Drawingelement
|
|
568
588
|
def plane
|
569
589
|
end
|
570
590
|
|
571
|
-
# The position_material method is used to position a material on a face.
|
591
|
+
# The {#position_material} method is used to position a material on a face.
|
572
592
|
#
|
573
|
-
# The
|
574
|
-
# to
|
575
|
-
# first point in each pair is a 3D point in the model.
|
576
|
-
#
|
577
|
-
#
|
593
|
+
# The +points+ argument must contain 2, 4, 6 or 8 points. The points are used
|
594
|
+
# in pairs to describe where a point in the texture image is positioned on the
|
595
|
+
# Face. The first point in each pair is a 3D point in the model. The second
|
596
|
+
# point in each pair of points is a 2D point that gives the (u,v) coordinates
|
597
|
+
# of a point in the image to match up with the 3D point.
|
578
598
|
#
|
579
599
|
# @example
|
580
600
|
# model = Sketchup.active_model
|
581
601
|
# entities = model.active_entities
|
582
602
|
#
|
583
603
|
# # Create a face and add it to the model entities
|
584
|
-
#
|
585
|
-
#
|
586
|
-
#
|
587
|
-
#
|
588
|
-
#
|
589
|
-
#
|
604
|
+
# points = [
|
605
|
+
# Geom::Point3d.new(0, 0, 1),
|
606
|
+
# Geom::Point3d.new(9, 0, 1),
|
607
|
+
# Geom::Point3d.new(9, 9, 1),
|
608
|
+
# Geom::Point3d.new(0, 9, 1),
|
609
|
+
# ]
|
610
|
+
# face = entities.add_face(points)
|
590
611
|
#
|
591
612
|
# # Export an image to use as a texture
|
592
613
|
# path = Sketchup.temp_dir
|
@@ -600,26 +621,64 @@ class Sketchup::Face < Sketchup::Drawingelement
|
|
600
621
|
# # Assign the new material to our face we created
|
601
622
|
# face.material = material
|
602
623
|
#
|
603
|
-
#
|
604
|
-
#
|
605
|
-
#
|
624
|
+
# mapping = [
|
625
|
+
# Geom::Point3d.new(3,0,0), # Model coordinate
|
626
|
+
# Geom::Point3d.new(0,0,0), # UV coordinate
|
627
|
+
# ]
|
606
628
|
# on_front = true
|
607
|
-
# face.position_material(material,
|
629
|
+
# face.position_material(material, mapping, on_front)
|
608
630
|
#
|
609
|
-
# @
|
610
|
-
#
|
631
|
+
# @overload position_material(material, points, on_front)
|
632
|
+
#
|
633
|
+
# This variant positions a material on the face's plane without projection.
|
634
|
+
#
|
635
|
+
# @param [Sketchup::Material] material
|
636
|
+
#
|
637
|
+
# @param [Array<Geom::Point3d>] points
|
638
|
+
# An array of Point3d objects used to position the material.
|
639
|
+
# The points should be on the plane of the face. If they are not they will
|
640
|
+
# be projected to the face's plane.
|
641
|
+
#
|
642
|
+
# @param [Boolean] on_front
|
643
|
+
# +true+ to position the texture on the front of the Face or
|
644
|
+
# +false+ to position it on the back of the Face.
|
611
645
|
#
|
612
|
-
# @
|
613
|
-
# An array of Point3d objects used to position the material.
|
646
|
+
# @overload position_material(material, points, on_front, projection)
|
614
647
|
#
|
615
|
-
#
|
616
|
-
# true to position the texture on the front of the Face or
|
617
|
-
# false to position it on the back of the Face.
|
648
|
+
# This variant positions a material on the face's plane with projection.
|
618
649
|
#
|
619
|
-
#
|
650
|
+
# @param [Sketchup::Material] material
|
651
|
+
#
|
652
|
+
# @param [Array<Geom::Point3d>] points
|
653
|
+
# An array of Point3d objects used to position the material.
|
654
|
+
# The points should be on the same plane. The plane should be parallel to
|
655
|
+
# the +projection+ vector. If they are not on a plane parallel to the
|
656
|
+
# projection vector they will be projected to such a plane.
|
657
|
+
#
|
658
|
+
# @param [Boolean] on_front
|
659
|
+
# +true+ to position the texture on the front of the Face or
|
660
|
+
# +false+ to position it on the back of the Face.
|
661
|
+
#
|
662
|
+
# @param [Geom::Vector3d] projection_vector
|
663
|
+
# The direction of the texture projection.
|
664
|
+
#
|
665
|
+
# @raise ArgumentError if the provided points are not in the size of 2, 4, 6 or 8.
|
666
|
+
#
|
667
|
+
# @raise ArgumentError if the provided points could not be computed to a valid UV mapping.
|
668
|
+
#
|
669
|
+
# @return [Sketchup::Face, false] the face upon success, +false+ if material or
|
670
|
+
# texture if not valid.
|
671
|
+
#
|
672
|
+
# @see #texture_positioned?
|
673
|
+
#
|
674
|
+
# @see #texture_projected?
|
675
|
+
#
|
676
|
+
# @see #get_texture_projection
|
677
|
+
#
|
678
|
+
# @see #clear_texture_projection
|
620
679
|
#
|
621
680
|
# @version SketchUp 6.0
|
622
|
-
def position_material(
|
681
|
+
def position_material(*args)
|
623
682
|
end
|
624
683
|
|
625
684
|
# The pushpull method is used to perform a push/pull on a face.
|
@@ -678,50 +737,157 @@ class Sketchup::Face < Sketchup::Drawingelement
|
|
678
737
|
def reverse!
|
679
738
|
end
|
680
739
|
|
681
|
-
# The set_texture_projection method is used to set the texture projection
|
740
|
+
# The {#set_texture_projection} method is used to set the texture projection
|
682
741
|
# direction.
|
683
742
|
#
|
684
|
-
# @deprecated This function never worked
|
685
|
-
# the position and orientation of the texture.
|
743
|
+
# @deprecated This function never worked correctly. It's not capable of
|
744
|
+
# controlling the position and orientation of the texture. In some cases it
|
745
|
+
# produced an invalid model. After SketchUp 2021.1 the method will raise
|
746
|
+
# +NotImplementedError+.
|
747
|
+
#
|
748
|
+
# @param [Geom::Vector3d] vector
|
749
|
+
# representing the direction of the projection. Use +nil+ to remove the
|
750
|
+
# projection.
|
751
|
+
#
|
752
|
+
# @param [Boolean] frontside
|
753
|
+
# +true+ for front side, +false+ for back side.
|
754
|
+
#
|
755
|
+
# @return [Boolean]
|
756
|
+
#
|
757
|
+
# @see #position_material
|
758
|
+
#
|
759
|
+
# @see #clear_texture_projection
|
760
|
+
#
|
761
|
+
# @version SketchUp 2014
|
762
|
+
def set_texture_projection(vector, frontside)
|
763
|
+
end
|
764
|
+
|
765
|
+
# The {#texture_positioned?} method is used to check if the face has a
|
766
|
+
# texture that is positioned.
|
767
|
+
#
|
768
|
+
# A texture is positioned when it's not using the default texture coordinates.
|
769
|
+
#
|
770
|
+
# When a user uses the Paint Bucket Tool to apply a material sampled from the
|
771
|
+
# Material Browser it will use default texture coordinates and not be
|
772
|
+
# positioned. It will be positioned if the user uses the Position Texture Tool.
|
773
|
+
#
|
774
|
+
# When an API user uses {Sketchup::Drawinglement#material=} the texture is not
|
775
|
+
# positioned. It will be positioned when the API user uses
|
776
|
+
# {Sketchup::Face#position_material}. It it also positioned of the face was
|
777
|
+
# crafted via {Geom::PolygonMesh}.
|
686
778
|
#
|
687
779
|
# @example
|
688
780
|
# model = Sketchup.active_model
|
689
781
|
# entities = model.active_entities
|
690
|
-
#
|
782
|
+
# faces = entities.grep(Sketchup::Face).select { |face|
|
783
|
+
# face.texture_positioned?(true) || face.texture_positioned?(false)
|
784
|
+
# }
|
691
785
|
#
|
692
|
-
#
|
693
|
-
#
|
694
|
-
#
|
695
|
-
# pts[1] = [10, 0, 1]
|
696
|
-
# pts[2] = [10, 10, 1]
|
697
|
-
# face = entities.add_face(pts)
|
786
|
+
# @param [Boolean] front
|
787
|
+
# +true+ Checks the front side of the face, +face+
|
788
|
+
# the back side.
|
698
789
|
#
|
699
|
-
#
|
700
|
-
# path = Sketchup.temp_dir
|
701
|
-
# full_name = File.join(path, "temp_image.jpg")
|
702
|
-
# model.active_view.write_image(full_name, 500, 500, false, 0.0)
|
790
|
+
# @return [Boolean]
|
703
791
|
#
|
704
|
-
#
|
705
|
-
# material = materials.add("Test Material")
|
706
|
-
# material.texture = full_name
|
792
|
+
# @see #position_material
|
707
793
|
#
|
708
|
-
#
|
709
|
-
# face.material = material
|
794
|
+
# @see #material=
|
710
795
|
#
|
711
|
-
#
|
712
|
-
# result = face.set_texture_projection(face.normal, true)
|
796
|
+
# @see #back_material=
|
713
797
|
#
|
714
|
-
# @
|
715
|
-
|
716
|
-
|
798
|
+
# @version SketchUp 2021.1
|
799
|
+
def texture_positioned?(front)
|
800
|
+
end
|
801
|
+
|
802
|
+
# The {#texture_projected?} method is used to check if the face has a
|
803
|
+
# texture that is projected.
|
717
804
|
#
|
718
|
-
#
|
719
|
-
#
|
805
|
+
# A texture is projected when the user enables this property via the
|
806
|
+
# Position Texture Tool.
|
720
807
|
#
|
721
|
-
#
|
808
|
+
# It is also projected when the API user passes a projection vector to
|
809
|
+
# {#position_material}.
|
722
810
|
#
|
723
|
-
# @
|
724
|
-
|
811
|
+
# @param [Boolean] front
|
812
|
+
# +true+ Checks the front side of the face, +face+
|
813
|
+
# the back side.
|
814
|
+
#
|
815
|
+
# @return [Boolean]
|
816
|
+
#
|
817
|
+
# @see #get_texture_projection
|
818
|
+
#
|
819
|
+
# @see #clear_texture_projection
|
820
|
+
#
|
821
|
+
# @see #position_material
|
822
|
+
#
|
823
|
+
# @version SketchUp 2021.1
|
824
|
+
def texture_projected?(front)
|
825
|
+
end
|
826
|
+
|
827
|
+
# The {#uv_tile_at} method is used to get the corner positions (model and UV)
|
828
|
+
# of a UV tile.
|
829
|
+
#
|
830
|
+
# The UV tile bounds the given reference point on the plane of the face. If the
|
831
|
+
# reference isn't on the plane of the face it will be projected onto it.
|
832
|
+
#
|
833
|
+
# The world coordinates are on the plane of the face unless the texture is
|
834
|
+
# projected. When the texture is projected the the world points are on an
|
835
|
+
# arbitrary plane that is perpendicular to the projection direction.
|
836
|
+
#
|
837
|
+
# The returned coordinates are arranged to be compatible with {#position_material}.
|
838
|
+
#
|
839
|
+
# <b>Getting the bounds of the UV tile under the cursor:</b>
|
840
|
+
#
|
841
|
+
# <i>The red quadrilateral represents the model points returned.</i>
|
842
|
+
#
|
843
|
+
# rdoc-image:../images/face-uv-tile-at.png
|
844
|
+
#
|
845
|
+
# @example Copy material from front to back
|
846
|
+
# model = Sketchup.active_model
|
847
|
+
# model.active_entities.grep(Sketchup::Face) { |face|
|
848
|
+
# material = face.material
|
849
|
+
#
|
850
|
+
# if material&.texture.nil?
|
851
|
+
# face.back_material = material
|
852
|
+
# end
|
853
|
+
#
|
854
|
+
# reference = face.vertices.first.position
|
855
|
+
# mapping = face.uv_tile_at(reference, true)
|
856
|
+
# if face.texture_projected?(true)
|
857
|
+
# projection = face.get_texture_projection(true)
|
858
|
+
# face.position_material(material, mapping, false, projection)
|
859
|
+
# else
|
860
|
+
# face.position_material(material, mapping, false)
|
861
|
+
# end
|
862
|
+
# }
|
863
|
+
#
|
864
|
+
# @example Iterate each set of world and UV coordinates
|
865
|
+
# model = Sketchup.active_model
|
866
|
+
# faces = model.active_entities.grep(Sketchup::Face)
|
867
|
+
# face = faces.find { |face| face.material&.texture }
|
868
|
+
# reference = face.vertices.first.position
|
869
|
+
# mapping = face.uv_tile_at(reference, true)
|
870
|
+
# mapping.each_slice(2) { |position, uv|
|
871
|
+
# puts "World: #{position.inspect} - UV: #{uv.inspect}"
|
872
|
+
# }
|
873
|
+
#
|
874
|
+
# @param [Geom::Point3d] position
|
875
|
+
# Model position on the face's plane that will be
|
876
|
+
# bounded by the UV tile.
|
877
|
+
#
|
878
|
+
# @param [Boolean] front
|
879
|
+
# +true+ Checks the front side of the face, +face+
|
880
|
+
# the back side.
|
881
|
+
#
|
882
|
+
# @return [Array<Geom::Point3d>, nil] A set of 8 points. Each stride of two is
|
883
|
+
# first a model space point, the second a UV
|
884
|
+
# coordinate. +nil+ if the face doesn't have
|
885
|
+
# a texture on the given side.
|
886
|
+
#
|
887
|
+
# @see #position_material
|
888
|
+
#
|
889
|
+
# @version SketchUp 2021.1
|
890
|
+
def uv_tile_at(position, front)
|
725
891
|
end
|
726
892
|
|
727
893
|
# The vertices method is used to get an array of all of the vertices that
|