sketchup-api-stubs 0.7.2 → 0.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. checksums.yaml +4 -4
  2. data/lib/sketchup-api-stubs/sketchup.rb +3 -1
  3. data/lib/sketchup-api-stubs/stubs/Geom/BoundingBox.rb +15 -11
  4. data/lib/sketchup-api-stubs/stubs/Geom/Bounds2d.rb +5 -5
  5. data/lib/sketchup-api-stubs/stubs/Geom/LatLong.rb +5 -5
  6. data/lib/sketchup-api-stubs/stubs/Geom/OrientedBounds2d.rb +1 -1
  7. data/lib/sketchup-api-stubs/stubs/Geom/Point2d.rb +5 -6
  8. data/lib/sketchup-api-stubs/stubs/Geom/Point3d.rb +18 -18
  9. data/lib/sketchup-api-stubs/stubs/Geom/PolygonMesh.rb +27 -10
  10. data/lib/sketchup-api-stubs/stubs/Geom/Transformation.rb +1 -1
  11. data/lib/sketchup-api-stubs/stubs/Geom/Transformation2d.rb +1 -1
  12. data/lib/sketchup-api-stubs/stubs/Geom/UTM.rb +1 -1
  13. data/lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb +2 -3
  14. data/lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb +4 -4
  15. data/lib/sketchup-api-stubs/stubs/Layout.rb +1 -1
  16. data/lib/sketchup-api-stubs/stubs/Layout/AngularDimension.rb +5 -1
  17. data/lib/sketchup-api-stubs/stubs/Layout/AutoTextDefinition.rb +1 -1
  18. data/lib/sketchup-api-stubs/stubs/Layout/AutoTextDefinitions.rb +7 -14
  19. data/lib/sketchup-api-stubs/stubs/Layout/ConnectionPoint.rb +1 -1
  20. data/lib/sketchup-api-stubs/stubs/Layout/Document.rb +61 -5
  21. data/lib/sketchup-api-stubs/stubs/Layout/Ellipse.rb +1 -1
  22. data/lib/sketchup-api-stubs/stubs/Layout/Entities.rb +7 -14
  23. data/lib/sketchup-api-stubs/stubs/Layout/Entity.rb +1 -1
  24. data/lib/sketchup-api-stubs/stubs/Layout/FormattedText.rb +1 -1
  25. data/lib/sketchup-api-stubs/stubs/Layout/Grid.rb +189 -1
  26. data/lib/sketchup-api-stubs/stubs/Layout/Group.rb +1 -1
  27. data/lib/sketchup-api-stubs/stubs/Layout/Image.rb +9 -4
  28. data/lib/sketchup-api-stubs/stubs/Layout/Label.rb +2 -3
  29. data/lib/sketchup-api-stubs/stubs/Layout/Layer.rb +1 -1
  30. data/lib/sketchup-api-stubs/stubs/Layout/LayerInstance.rb +1 -1
  31. data/lib/sketchup-api-stubs/stubs/Layout/Layers.rb +7 -14
  32. data/lib/sketchup-api-stubs/stubs/Layout/LinearDimension.rb +6 -2
  33. data/lib/sketchup-api-stubs/stubs/Layout/LockedEntityError.rb +1 -1
  34. data/lib/sketchup-api-stubs/stubs/Layout/LockedLayerError.rb +1 -1
  35. data/lib/sketchup-api-stubs/stubs/Layout/Page.rb +1 -1
  36. data/lib/sketchup-api-stubs/stubs/Layout/PageInfo.rb +1 -1
  37. data/lib/sketchup-api-stubs/stubs/Layout/Pages.rb +7 -14
  38. data/lib/sketchup-api-stubs/stubs/Layout/Path.rb +1 -1
  39. data/lib/sketchup-api-stubs/stubs/Layout/Rectangle.rb +1 -1
  40. data/lib/sketchup-api-stubs/stubs/Layout/SketchUpModel.rb +148 -5
  41. data/lib/sketchup-api-stubs/stubs/Layout/Style.rb +1 -1
  42. data/lib/sketchup-api-stubs/stubs/Layout/Table.rb +1 -1
  43. data/lib/sketchup-api-stubs/stubs/Layout/TableCell.rb +1 -1
  44. data/lib/sketchup-api-stubs/stubs/Layout/TableColumn.rb +1 -1
  45. data/lib/sketchup-api-stubs/stubs/Layout/TableRow.rb +1 -1
  46. data/lib/sketchup-api-stubs/stubs/Sketchup/Animation.rb +5 -1
  47. data/lib/sketchup-api-stubs/stubs/Sketchup/AppObserver.rb +4 -4
  48. data/lib/sketchup-api-stubs/stubs/Sketchup/ArcCurve.rb +1 -1
  49. data/lib/sketchup-api-stubs/stubs/Sketchup/AttributeDictionaries.rb +3 -3
  50. data/lib/sketchup-api-stubs/stubs/Sketchup/AttributeDictionary.rb +6 -1
  51. data/lib/sketchup-api-stubs/stubs/Sketchup/Axes.rb +1 -1
  52. data/lib/sketchup-api-stubs/stubs/Sketchup/Behavior.rb +32 -58
  53. data/lib/sketchup-api-stubs/stubs/Sketchup/Camera.rb +110 -209
  54. data/lib/sketchup-api-stubs/stubs/Sketchup/ClassificationSchema.rb +1 -1
  55. data/lib/sketchup-api-stubs/stubs/Sketchup/Classifications.rb +1 -1
  56. data/lib/sketchup-api-stubs/stubs/Sketchup/Color.rb +24 -11
  57. data/lib/sketchup-api-stubs/stubs/Sketchup/ComponentDefinition.rb +24 -9
  58. data/lib/sketchup-api-stubs/stubs/Sketchup/ComponentInstance.rb +58 -57
  59. data/lib/sketchup-api-stubs/stubs/Sketchup/Console.rb +1 -1
  60. data/lib/sketchup-api-stubs/stubs/Sketchup/ConstructionLine.rb +1 -1
  61. data/lib/sketchup-api-stubs/stubs/Sketchup/ConstructionPoint.rb +1 -1
  62. data/lib/sketchup-api-stubs/stubs/Sketchup/Curve.rb +16 -9
  63. data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionList.rb +135 -39
  64. data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionObserver.rb +6 -4
  65. data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionsObserver.rb +6 -4
  66. data/lib/sketchup-api-stubs/stubs/Sketchup/Dimension.rb +1 -1
  67. data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionLinear.rb +3 -9
  68. data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionObserver.rb +5 -1
  69. data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionRadial.rb +1 -1
  70. data/lib/sketchup-api-stubs/stubs/Sketchup/Drawingelement.rb +10 -4
  71. data/lib/sketchup-api-stubs/stubs/Sketchup/Edge.rb +8 -14
  72. data/lib/sketchup-api-stubs/stubs/Sketchup/EdgeUse.rb +1 -1
  73. data/lib/sketchup-api-stubs/stubs/Sketchup/Entities.rb +55 -26
  74. data/lib/sketchup-api-stubs/stubs/Sketchup/EntitiesObserver.rb +6 -4
  75. data/lib/sketchup-api-stubs/stubs/Sketchup/Entity.rb +20 -15
  76. data/lib/sketchup-api-stubs/stubs/Sketchup/EntityObserver.rb +6 -5
  77. data/lib/sketchup-api-stubs/stubs/Sketchup/ExtensionsManager.rb +9 -8
  78. data/lib/sketchup-api-stubs/stubs/Sketchup/Face.rb +232 -65
  79. data/lib/sketchup-api-stubs/stubs/Sketchup/FrameChangeObserver.rb +1 -1
  80. data/lib/sketchup-api-stubs/stubs/Sketchup/Group.rb +98 -45
  81. data/lib/sketchup-api-stubs/stubs/Sketchup/Http.rb +1 -1
  82. data/lib/sketchup-api-stubs/stubs/Sketchup/Http/Request.rb +48 -41
  83. data/lib/sketchup-api-stubs/stubs/Sketchup/Http/Response.rb +7 -7
  84. data/lib/sketchup-api-stubs/stubs/Sketchup/Image.rb +60 -1
  85. data/lib/sketchup-api-stubs/stubs/Sketchup/ImageRep.rb +47 -7
  86. data/lib/sketchup-api-stubs/stubs/Sketchup/Importer.rb +11 -12
  87. data/lib/sketchup-api-stubs/stubs/Sketchup/InputPoint.rb +33 -21
  88. data/lib/sketchup-api-stubs/stubs/Sketchup/InstanceObserver.rb +6 -4
  89. data/lib/sketchup-api-stubs/stubs/Sketchup/InstancePath.rb +5 -2
  90. data/lib/sketchup-api-stubs/stubs/Sketchup/Layer.rb +115 -68
  91. data/lib/sketchup-api-stubs/stubs/Sketchup/LayerFolder.rb +422 -0
  92. data/lib/sketchup-api-stubs/stubs/Sketchup/Layers.rb +225 -29
  93. data/lib/sketchup-api-stubs/stubs/Sketchup/LayersObserver.rb +118 -5
  94. data/lib/sketchup-api-stubs/stubs/Sketchup/Licensing.rb +2 -2
  95. data/lib/sketchup-api-stubs/stubs/Sketchup/Licensing/ExtensionLicense.rb +1 -1
  96. data/lib/sketchup-api-stubs/stubs/Sketchup/LineStyle.rb +1 -1
  97. data/lib/sketchup-api-stubs/stubs/Sketchup/LineStyles.rb +2 -13
  98. data/lib/sketchup-api-stubs/stubs/Sketchup/Loop.rb +1 -1
  99. data/lib/sketchup-api-stubs/stubs/Sketchup/Material.rb +8 -10
  100. data/lib/sketchup-api-stubs/stubs/Sketchup/Materials.rb +16 -9
  101. data/lib/sketchup-api-stubs/stubs/Sketchup/MaterialsObserver.rb +6 -5
  102. data/lib/sketchup-api-stubs/stubs/Sketchup/Menu.rb +9 -11
  103. data/lib/sketchup-api-stubs/stubs/Sketchup/Model.rb +126 -73
  104. data/lib/sketchup-api-stubs/stubs/Sketchup/ModelObserver.rb +5 -4
  105. data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsManager.rb +2 -3
  106. data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsProvider.rb +7 -7
  107. data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsProviderObserver.rb +4 -4
  108. data/lib/sketchup-api-stubs/stubs/Sketchup/Page.rb +143 -40
  109. data/lib/sketchup-api-stubs/stubs/Sketchup/Pages.rb +22 -12
  110. data/lib/sketchup-api-stubs/stubs/Sketchup/PagesObserver.rb +6 -5
  111. data/lib/sketchup-api-stubs/stubs/Sketchup/PickHelper.rb +37 -15
  112. data/lib/sketchup-api-stubs/stubs/Sketchup/RegionalSettings.rb +1 -1
  113. data/lib/sketchup-api-stubs/stubs/Sketchup/RenderingOptions.rb +1 -1
  114. data/lib/sketchup-api-stubs/stubs/Sketchup/RenderingOptionsObserver.rb +5 -4
  115. data/lib/sketchup-api-stubs/stubs/Sketchup/SectionPlane.rb +1 -1
  116. data/lib/sketchup-api-stubs/stubs/Sketchup/Selection.rb +10 -5
  117. data/lib/sketchup-api-stubs/stubs/Sketchup/SelectionObserver.rb +20 -20
  118. data/lib/sketchup-api-stubs/stubs/Sketchup/Set.rb +1 -1
  119. data/lib/sketchup-api-stubs/stubs/Sketchup/ShadowInfo.rb +5 -5
  120. data/lib/sketchup-api-stubs/stubs/Sketchup/ShadowInfoObserver.rb +6 -4
  121. data/lib/sketchup-api-stubs/stubs/Sketchup/Skp.rb +40 -0
  122. data/lib/sketchup-api-stubs/stubs/Sketchup/Style.rb +1 -1
  123. data/lib/sketchup-api-stubs/stubs/Sketchup/Styles.rb +9 -3
  124. data/lib/sketchup-api-stubs/stubs/Sketchup/Text.rb +1 -1
  125. data/lib/sketchup-api-stubs/stubs/Sketchup/Texture.rb +14 -22
  126. data/lib/sketchup-api-stubs/stubs/Sketchup/TextureWriter.rb +1 -1
  127. data/lib/sketchup-api-stubs/stubs/Sketchup/Tool.rb +31 -25
  128. data/lib/sketchup-api-stubs/stubs/Sketchup/Tools.rb +2 -2
  129. data/lib/sketchup-api-stubs/stubs/Sketchup/ToolsObserver.rb +6 -4
  130. data/lib/sketchup-api-stubs/stubs/Sketchup/UVHelper.rb +32 -22
  131. data/lib/sketchup-api-stubs/stubs/Sketchup/Vertex.rb +1 -1
  132. data/lib/sketchup-api-stubs/stubs/Sketchup/View.rb +73 -67
  133. data/lib/sketchup-api-stubs/stubs/Sketchup/ViewObserver.rb +6 -4
  134. data/lib/sketchup-api-stubs/stubs/UI/Command.rb +13 -6
  135. data/lib/sketchup-api-stubs/stubs/UI/HtmlDialog.rb +132 -10
  136. data/lib/sketchup-api-stubs/stubs/UI/Notification.rb +94 -54
  137. data/lib/sketchup-api-stubs/stubs/UI/Toolbar.rb +1 -1
  138. data/lib/sketchup-api-stubs/stubs/UI/WebDialog.rb +3 -3
  139. data/lib/sketchup-api-stubs/stubs/_top_level.rb +3 -1
  140. data/lib/sketchup-api-stubs/stubs/array.rb +1 -1
  141. data/lib/sketchup-api-stubs/stubs/geom.rb +4 -1
  142. data/lib/sketchup-api-stubs/stubs/languagehandler.rb +1 -1
  143. data/lib/sketchup-api-stubs/stubs/length.rb +1 -1
  144. data/lib/sketchup-api-stubs/stubs/numeric.rb +1 -1
  145. data/lib/sketchup-api-stubs/stubs/sketchup.rb +66 -23
  146. data/lib/sketchup-api-stubs/stubs/sketchupextension.rb +1 -1
  147. data/lib/sketchup-api-stubs/stubs/string.rb +1 -1
  148. data/lib/sketchup-api-stubs/stubs/ui.rb +17 -12
  149. metadata +5 -3
@@ -1,10 +1,12 @@
1
- # Copyright:: Copyright 2020 Trimble Inc.
1
+ # Copyright:: Copyright 2021 Trimble Inc.
2
2
  # License:: The MIT License (MIT)
3
3
 
4
4
  # This observer interface is implemented to react to {Sketchup::Entities}
5
- # collection events. To implement this observer, create a Ruby class of this
6
- # type, override the desired methods, and add an instance of the observer to
7
- # the objects of interests.
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.
8
10
  #
9
11
  # @example
10
12
  # # This is an example of an observer that watches the entities collection
@@ -1,4 +1,4 @@
1
- # Copyright:: Copyright 2020 Trimble Inc.
1
+ # Copyright:: Copyright 2021 Trimble Inc.
2
2
  # License:: The MIT License (MIT)
3
3
 
4
4
  # This is the base class for all SketchUp entities. Entities are basically
@@ -73,12 +73,11 @@ class Sketchup::Entity
73
73
  # status = entity1.set_attribute "testdictionary", "test", 115
74
74
  # attrdicts = entity1.attribute_dictionaries
75
75
  #
76
- # @return [Sketchup::AttributeDictionaries, nil] the AttributeDictionaries
77
- # object associated with the entity, or nil if there are
78
- # no attribute_dictionary objects associated with the
79
- # model. Care must be taken if nil is returned, for
80
- # example: invoking attribute_dictionaries.length will
81
- # throw a NoMethodError exception, not return 0.
76
+ # @note The return value may be either +nil+ or an empty
77
+ # {Sketchup::AttributeDictionaries} collection if this entity has no
78
+ # {Sketchup::AttributeDictionary}s.
79
+ #
80
+ # @return [Sketchup::AttributeDictionaries, nil]
82
81
  #
83
82
  # @version SketchUp 6.0
84
83
  def attribute_dictionaries
@@ -155,14 +154,14 @@ class Sketchup::Entity
155
154
  #
156
155
  # @overload delete_attribute(dictionary_name)
157
156
  #
158
- # @param dictionary_name [String] The name of an attribute dictionary.
159
- # @return [Boolean]
157
+ # @param [String] dictionary_name The name of an attribute dictionary.
158
+ # @return [Boolean]
160
159
  #
161
160
  # @overload delete_attribute(dictionary_name, key)
162
161
  #
163
- # @param dictionary_name [String] The name of an attribute dictionary.
164
- # @param key [String] An attribute key.
165
- # @return [Boolean]
162
+ # @param [String] dictionary_name The name of an attribute dictionary.
163
+ # @param [String] key An attribute key.
164
+ # @return [Boolean]
166
165
  #
167
166
  # @version SketchUp 6.0
168
167
  def delete_attribute(*args)
@@ -344,6 +343,10 @@ class Sketchup::Entity
344
343
  #
345
344
  # The persistent id persistent between sessions.
346
345
  #
346
+ # [SketchUp 2020.1]
347
+ # - {Sketchup::ComponentDefinition}
348
+ # - {Sketchup::Material}
349
+ # - {Sketchup::Style}
347
350
  # [SketchUp 2020.0]
348
351
  # - {Sketchup::Layer}
349
352
  # - {Sketchup::LineStyle}
@@ -504,16 +507,18 @@ class Sketchup::Entity
504
507
  # entity1 = entities[1]
505
508
  # type = entity1.typename
506
509
  #
510
+ # @note Prefer +is_a?+ over +typename+ when possible as it is faster.
511
+ #
507
512
  # @return [String] the type of the entity
508
513
  #
509
514
  # @version SketchUp 6.0
510
515
  def typename
511
516
  end
512
517
 
513
- # The valid? method is used to determine if your entity is still valid (not
514
- # deleted by another script, for example.)
518
+ # The {#valid?} method is used to determine if your entity is still valid (not
519
+ # deleted by another script, for example).
515
520
  #
516
- # This method is functionally identical to the deleted? method.
521
+ # This method is functionally the inverse to the {#deleted?} method.
517
522
  #
518
523
  # @example
519
524
  # depth = 100
@@ -1,10 +1,11 @@
1
- # Copyright:: Copyright 2020 Trimble Inc.
1
+ # Copyright:: Copyright 2021 Trimble Inc.
2
2
  # License:: The MIT License (MIT)
3
3
 
4
- # This observer interface is implemented to react to entity events. To
5
- # implement this observer, create a Ruby class of this type, override the
6
- # desired methods, and add an instance of the observer to the entity of
7
- # interests.
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.
8
9
  #
9
10
  # @example
10
11
  # class MyEntityObserver < Sketchup::EntityObserver
@@ -1,4 +1,4 @@
1
- # Copyright:: Copyright 2020 Trimble Inc.
1
+ # Copyright:: Copyright 2021 Trimble Inc.
2
2
  # License:: The MIT License (MIT)
3
3
 
4
4
  # The ExtensionsManager class provides a way of accessing the
@@ -21,11 +21,11 @@ class Sketchup::ExtensionsManager
21
21
  #
22
22
  # @example
23
23
  # manager = Sketchup.extensions
24
- # extension = manager[0]
24
+ # extension = manager[1]
25
25
  # if (extension)
26
- # UI.messagebox extension.name
26
+ # puts extension.name
27
27
  # else
28
- # UI.messagebox "Failure"
28
+ # puts "No Extensions installed"
29
29
  # end
30
30
  #
31
31
  # # You can also get extensions by name.
@@ -34,11 +34,12 @@ class Sketchup::ExtensionsManager
34
34
  # # You can also get extensions by ID.
35
35
  # my_extension = manager['2475A758-6503-46D5-AC5E-16AEA0A3162A']
36
36
  #
37
- # @param index_or_name
37
+ # @note Index starts at 1.
38
+ #
39
+ # @param [Integer, String] index_or_name
38
40
  # The index, name or ID of the SketchupExtension object.
39
41
  #
40
- # @return extension - an SketchupExtension object if
41
- # successful, otherwise nil.
42
+ # @return [SketchupExtension, nil]
42
43
  #
43
44
  # @version SketchUp 8.0 M2
44
45
  def [](index_or_name)
@@ -66,7 +67,7 @@ class Sketchup::ExtensionsManager
66
67
  # @example
67
68
  # manager = Sketchup.extensions
68
69
  # # Retrieves each extension
69
- # manager.each { |extension| UI.messagebox extension.name }
70
+ # manager.each { |extension| puts extension.name }
70
71
  #
71
72
  # @return nil
72
73
  #
@@ -1,4 +1,4 @@
1
- # Copyright:: Copyright 2020 Trimble Inc.
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.
@@ -41,7 +41,7 @@ class Sketchup::Face < Sketchup::Drawingelement
41
41
  def all_connected
42
42
  end
43
43
 
44
- # The area method is used to retrieve the area of a face in current units.
44
+ # The area method is used to retrieve the area of a face.
45
45
  #
46
46
  # You can pass in an optional Transformation (or an array that can represent a
47
47
  # transformation), to correct for a parent group's transformation. For example,
@@ -66,13 +66,14 @@ class Sketchup::Face < Sketchup::Drawingelement
66
66
  #
67
67
  # @overload area
68
68
  #
69
- # @return [Float] the area of the face in current units (if successful)
69
+ # @return [Float] the area of the face in square inches.
70
70
  #
71
71
  # @overload area(transform)
72
72
  #
73
- # @param transform [Geom::Transformation] A Transformation object or array
74
- # that can be interpreted as a Transformation object.
75
- # @return [Float] the area of the face in current units (if successful)
73
+ # @param [Geom::Transformation] transform
74
+ # A Transformation object or array that can be interpreted as a
75
+ # Transformation object.
76
+ # @return [Float] the area of the face in square inches.
76
77
  #
77
78
  # @version SketchUp 6.0
78
79
  def area(*args)
@@ -199,6 +200,21 @@ class Sketchup::Face < Sketchup::Drawingelement
199
200
  def classify_point(point)
200
201
  end
201
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
+
202
218
  # The edges method is used to get an array of edges that bound the face.
203
219
  #
204
220
  # @example
@@ -330,7 +346,7 @@ class Sketchup::Face < Sketchup::Drawingelement
330
346
  def get_glued_instances
331
347
  end
332
348
 
333
- # The get_texture_projection method will return a vector representing the
349
+ # The {#get_texture_projection} method will return a vector representing the
334
350
  # projection for either the front or back side of the face.
335
351
  #
336
352
  # @example
@@ -364,9 +380,14 @@ class Sketchup::Face < Sketchup::Drawingelement
364
380
  # vector = face.get_texture_projection(true)
365
381
  #
366
382
  # @param [Boolean] frontside
367
- # 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
368
389
  #
369
- # @return [Geom::Vector3d] a vector on success, nil on failure.
390
+ # @see #texture_projected?
370
391
  #
371
392
  # @version SketchUp 2014
372
393
  def get_texture_projection(frontside)
@@ -567,25 +588,26 @@ class Sketchup::Face < Sketchup::Drawingelement
567
588
  def plane
568
589
  end
569
590
 
570
- # 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.
571
592
  #
572
- # The pt_array must contain 2, 4, 6 or 8 points. The points are used in pairs
573
- # to tell where a point in the texture image is positioned on the Face. The
574
- # first point in each pair is a 3D point in the model. It should be a point on
575
- # the Face. The second point in each pair of points is a 2D point that gives
576
- # the (u,v) coordinates of a point in the image to match up with the 3D point.
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.
577
598
  #
578
599
  # @example
579
600
  # model = Sketchup.active_model
580
601
  # entities = model.active_entities
581
602
  #
582
603
  # # Create a face and add it to the model entities
583
- # pts = []
584
- # pts[0] = [0, 0, 1]
585
- # pts[1] = [9, 0, 1]
586
- # pts[2] = [9, 9, 1]
587
- # pts[3] = [0, 9, 1]
588
- # face = entities.add_face(pts)
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)
589
611
  #
590
612
  # # Export an image to use as a texture
591
613
  # path = Sketchup.temp_dir
@@ -599,26 +621,64 @@ class Sketchup::Face < Sketchup::Drawingelement
599
621
  # # Assign the new material to our face we created
600
622
  # face.material = material
601
623
  #
602
- # pt_array = []
603
- # pt_array[0] = Geom::Point3d.new(3,0,0)
604
- # pt_array[1] = Geom::Point3d.new(0,0,0)
624
+ # mapping = [
625
+ # Geom::Point3d.new(3,0,0), # Model coordinate
626
+ # Geom::Point3d.new(0,0,0), # UV coordinate
627
+ # ]
605
628
  # on_front = true
606
- # face.position_material(material, pt_array, on_front)
629
+ # face.position_material(material, mapping, on_front)
607
630
  #
608
- # @param [Sketchup::Material] material
609
- # a Material object.
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.
610
645
  #
611
- # @param [Array<Geom::Point3d>] pt_array
612
- # An array of Point3d objects used to position the material.
646
+ # @overload position_material(material, points, on_front, projection)
613
647
  #
614
- # @param [Boolean] o_front
615
- # true to position the texture on the front of the Face or
616
- # false to position it on the back of the Face.
648
+ # This variant positions a material on the face's plane with projection.
617
649
  #
618
- # @return [Sketchup::Face, false] the face upon success, false upon failure.
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
619
679
  #
620
680
  # @version SketchUp 6.0
621
- def position_material(material, pt_array, o_front)
681
+ def position_material(*args)
622
682
  end
623
683
 
624
684
  # The pushpull method is used to perform a push/pull on a face.
@@ -639,8 +699,8 @@ class Sketchup::Face < Sketchup::Drawingelement
639
699
  # face = entities.add_face(pts)
640
700
  # status = face.pushpull(100, true)
641
701
  #
642
- # @param [Numeric] distance
643
- # The distance, in current units, to push/pull the face.
702
+ # @param [Length] distance
703
+ # The distance to push/pull the face.
644
704
  #
645
705
  # @param [Boolean] copy
646
706
  # Create a new push/pull starting face if true (equivalent
@@ -677,50 +737,157 @@ class Sketchup::Face < Sketchup::Drawingelement
677
737
  def reverse!
678
738
  end
679
739
 
680
- # 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
681
741
  # direction.
682
742
  #
683
- # @deprecated This function never worked right. It's not possible to control
684
- # 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}.
685
778
  #
686
779
  # @example
687
780
  # model = Sketchup.active_model
688
781
  # entities = model.active_entities
689
- # materials = model.materials
782
+ # faces = entities.grep(Sketchup::Face).select { |face|
783
+ # face.texture_positioned?(true) || face.texture_positioned?(false)
784
+ # }
690
785
  #
691
- # # Create a face and add it to the model entities
692
- # pts = []
693
- # pts[0] = [0, 0, 1]
694
- # pts[1] = [10, 0, 1]
695
- # pts[2] = [10, 10, 1]
696
- # face = entities.add_face(pts)
786
+ # @param [Boolean] front
787
+ # +true+ Checks the front side of the face, +face+
788
+ # the back side.
697
789
  #
698
- # # Export an image to use as a texture
699
- # path = Sketchup.temp_dir
700
- # full_name = File.join(path, "temp_image.jpg")
701
- # model.active_view.write_image(full_name, 500, 500, false, 0.0)
790
+ # @return [Boolean]
702
791
  #
703
- # # Create a material and assign the testure to it.
704
- # material = materials.add("Test Material")
705
- # material.texture = full_name
792
+ # @see #position_material
706
793
  #
707
- # # Assign the new material to our face we created
708
- # face.material = material
794
+ # @see #material=
709
795
  #
710
- # # Returns nil if not successful, path if successful
711
- # result = face.set_texture_projection(face.normal, true)
796
+ # @see #back_material=
712
797
  #
713
- # @param [Geom::Vector3d] vector
714
- # representing the direction of the projection. Use nil
715
- # to remove the projection.
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.
716
804
  #
717
- # @param [Boolean] frontside
718
- # true for front side, false for back side.
805
+ # A texture is projected when the user enables this property via the
806
+ # Position Texture Tool.
719
807
  #
720
- # @return [Boolean] true on success
808
+ # It is also projected when the API user passes a projection vector to
809
+ # {#position_material}.
721
810
  #
722
- # @version SketchUp 2014
723
- def set_texture_projection(vector, frontside)
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)
724
891
  end
725
892
 
726
893
  # The vertices method is used to get an array of all of the vertices that