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,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
  # Http::Response objects allows you to get the response information from the
@@ -15,9 +15,9 @@ class Sketchup::Http::Response
15
15
  # no charset is specified, ASCII-8BIT will be used.
16
16
  #
17
17
  # @example
18
- # request = Sketchup::Http::Request.new("http://localhost:8080")
18
+ # @request = Sketchup::Http::Request.new("http://localhost:8080")
19
19
  #
20
- # request.start do |request, response|
20
+ # @request.start do |request, response|
21
21
  # puts "body: " + response.body
22
22
  # end
23
23
  #
@@ -30,9 +30,9 @@ class Sketchup::Http::Response
30
30
  # Returns the http headers that were sent by the server.
31
31
  #
32
32
  # @example
33
- # request = Sketchup::Http::Request.new("http://localhost:8080")
33
+ # @request = Sketchup::Http::Request.new("http://localhost:8080")
34
34
  #
35
- # request.start do |request, response|
35
+ # @request.start do |request, response|
36
36
  # response.headers.each do |key, value|
37
37
  # puts "#{key}: #{value}"
38
38
  # end
@@ -47,9 +47,9 @@ class Sketchup::Http::Response
47
47
  # Returns the HTTP response status code as defined in rfc2616.
48
48
  #
49
49
  # @example
50
- # request = Sketchup::Http::Request.new("http://localhost:8080")
50
+ # @request = Sketchup::Http::Request.new("http://localhost:8080")
51
51
  #
52
- # request.start do |request, response|
52
+ # @request.start do |request, response|
53
53
  # puts "http status code: #{response.status_code}"
54
54
  # end
55
55
  #
@@ -1,8 +1,16 @@
1
- # Copyright:: Copyright 2020 Trimble Inc.
1
+ # Copyright:: Copyright 2021 Trimble Inc.
2
2
  # License:: The MIT License (MIT)
3
3
 
4
4
  # An Image object represents a raster image placed in the Model.
5
5
  #
6
+ # @example Create material from image (SU 2018 and later)
7
+ # model = Sketchup.active_model
8
+ # entities = model.active_entities
9
+ # image = entities.grep(Sketchup::Image).first
10
+ # img_rep = image.image_rep
11
+ # material = model.materials.add("New Name")
12
+ # material.texture = img_rep
13
+ #
6
14
  # @version SketchUp 6.0
7
15
  class Sketchup::Image < Sketchup::Drawingelement
8
16
 
@@ -31,6 +39,53 @@ class Sketchup::Image < Sketchup::Drawingelement
31
39
  def explode
32
40
  end
33
41
 
42
+ # The {#glued_to} method is used to retrieve the entity that this image is
43
+ # glued to.
44
+ #
45
+ # @example
46
+ # point = Geom::Point3d.new(10, 20, 30)
47
+ # transform = Geom::Transformation.new(point)
48
+ # model = Sketchup.active_model
49
+ # entities = model.active_entities
50
+ # group = entities.add_group
51
+ # group.entities.add_face([[0, 0, 0], [10, 0, 0], [10, 10, 0], [0, 10, 0]])
52
+ # status = group.glued_to
53
+ #
54
+ # @return [Sketchup::Face, Sketchup::Group, Sketchup::ComponentInstance, Sketchup::Image, nil]
55
+ #
56
+ # @version SketchUp 2021.1
57
+ def glued_to
58
+ end
59
+
60
+ # The {glued_to=} method glues this image to a drawing element.
61
+ # When moving this other drawing elment with the Move tool, the image moves with it.
62
+ #
63
+ # @example
64
+ # model = Sketchup.active_model
65
+ # entities = model.active_entities
66
+ #
67
+ # # Create a face
68
+ # face = entities.add_face([[0, 0, 0], [100, 0, 0], [100, 100, 0], [0, 100, 0]])
69
+ #
70
+ # # Create a group
71
+ # path = "Plugins/su_dynamiccomponents/images"
72
+ # image_file = Sketchup.find_support_file("report_tool.png", path)
73
+ # image = model.active_entities.add_image(image_file, ORIGIN, 300)
74
+ #
75
+ # # Glue the group to the face.
76
+ # # If you now move the face, the group will follow.
77
+ # image.glued_to = face
78
+ #
79
+ # @param [Sketchup::Face, Sketchup::Group, Sketchup::ComponentInstance, Sketchup::Image, nil] drawing_element
80
+ #
81
+ # @raise ArgumentError if this would lead to cyclic gluing.
82
+ #
83
+ # @return [Sketchup::Face, Sketchup::Group, Sketchup::ComponentInstance, Sketchup::Image, nil] the entity the group was glued to.
84
+ #
85
+ # @version SketchUp 2021.1
86
+ def glued_to=(drawing_element)
87
+ end
88
+
34
89
  # The height method is used to retrieve the height of the image.
35
90
  #
36
91
  # The height is given in inches.
@@ -84,6 +139,8 @@ class Sketchup::Image < Sketchup::Drawingelement
84
139
  # The {#image_rep} method returns a copy of a {Sketchup::ImageRep} object
85
140
  # representing the pixel data.
86
141
  #
142
+ # @bug Prior to SketchUp 2021.1, SketchUp crashes when the Image is corrupt and lacks image data.
143
+ #
87
144
  # @example
88
145
  # model = Sketchup.active_model
89
146
  # path = "Plugins/su_dynamiccomponents/images"
@@ -91,6 +148,8 @@ class Sketchup::Image < Sketchup::Drawingelement
91
148
  # image = model.active_entities.add_image(image_file, ORIGIN, 300)
92
149
  # image_rep = image.image_rep
93
150
  #
151
+ # @raise ArgumentError if the Image is corrupt and lacks image data.
152
+ #
94
153
  # @return [Sketchup::ImageRep]
95
154
  #
96
155
  # @version SketchUp 2018
@@ -1,8 +1,14 @@
1
- # Copyright:: Copyright 2020 Trimble Inc.
1
+ # Copyright:: Copyright 2021 Trimble Inc.
2
2
  # License:: The MIT License (MIT)
3
3
 
4
4
  # References an image representation object.
5
5
  #
6
+ # @example
7
+ # # Get the color of the center of the first material texture found in model.
8
+ # texture = Sketchup.active_model.materials.map(&:texture).compact.first
9
+ # image_rep = texture.image_rep
10
+ # color = image_rep.color_at_uv(0.5, 0.5)
11
+ #
6
12
  # @version SketchUp 2018
7
13
  class Sketchup::ImageRep
8
14
 
@@ -23,7 +29,8 @@ class Sketchup::ImageRep
23
29
  end
24
30
 
25
31
  # The {#color_at_uv} method returns a color corresponding to the UV texture
26
- # coordinates
32
+ # coordinates. +0.0, 0.0+ maps to the bottom left and +1.0, 1.0+ to the top
33
+ # right of the image.
27
34
  #
28
35
  # @example
29
36
  # image_rep = Sketchup::ImageRep.new
@@ -69,6 +76,8 @@ class Sketchup::ImageRep
69
76
  # byte_string = image_rep.data
70
77
  # byte_string.each_byte { |byte| puts byte, ' ' }
71
78
  #
79
+ # @note The byte order of the pixels are RGB(A) on macOS and BGR(A) on Windows.
80
+ #
72
81
  # @return [String, nil]
73
82
  #
74
83
  # @version SketchUp 2018
@@ -93,6 +102,7 @@ class Sketchup::ImageRep
93
102
  #
94
103
  # @example Default constructor
95
104
  # image_rep = Sketchup::ImageRep.new
105
+ # # Use #set_data or #load_file to add image data.
96
106
  #
97
107
  # @example Construct from file
98
108
  # image_rep = Sketchup::ImageRep.new("/path/to/image.jpg")
@@ -155,15 +165,45 @@ class Sketchup::ImageRep
155
165
  def save_file(filepath)
156
166
  end
157
167
 
158
- # The {#set_data} method sets the pixel data of the {Sketchup::ImageRep}.
168
+ # The {#set_data} method discards any existing data and sets new pixel data for
169
+ # the {Sketchup::ImageRep}.
159
170
  #
160
171
  # @example Setting new data
161
172
  # image_rep = Sketchup::ImageRep.new
162
- # image_rep.load_file("/path/to/image.jpg")
163
- # new_image_rep = image_rep.set_data(800, 600, 24, 0, pixel_data)
173
+ # width = 800
174
+ # height = 600
175
+ # bpp = 24
176
+ # pixel = [127, 127, 127].pack("C*")
177
+ # pixels = pixel * width * height
178
+ # image_rep.set_data(width, height, bpp, 0, pixels)
179
+ # image_rep.save_file(UI.savepanel)
180
+ #
181
+ # @example Handling system color differences
182
+ # # Generates red image on Mac and blue on Windows.
183
+ # image_rep = Sketchup::ImageRep.new
184
+ # color = Sketchup::Color.new("Red")
185
+ # rgba = color.to_a # Red, green , blue, alpha
186
+ # color_data = rgba.pack("C*")
187
+ # image_rep.set_data(1, 1, 32, 0, color_data)
188
+ # image_rep.save_file(UI.savepanel)
189
+ #
190
+ # # Generates red image on both systems.
191
+ # image_rep = Sketchup::ImageRep.new
192
+ # color = Sketchup::Color.new("Red")
193
+ # color_code = color.to_a # Red, green, blue, alpha
194
+ # if Sketchup.platform == :platform_win
195
+ # # Change order to Blue, green, red, alpha on Windows.
196
+ # color_code = color_code.values_at(2, 1, 0, 3)
197
+ # end
198
+ # color_data = color_code.pack("C*")
199
+ # image_rep.set_data(1, 1, 32, 0, color_data)
200
+ # image_rep.save_file(UI.savepanel)
201
+ #
202
+ # @note The byte order of the pixels are RGB(A) on macOS and BGR(A) on Windows.
164
203
  #
165
204
  # @note The encoding of the pixel_data {String} parameter should be ASCII-8BIT.
166
- # Any other encoding could corrupt the binary data.
205
+ # Any other encoding could corrupt the binary data. Using
206
+ # `Array#pack("C*")` gives correct encoding.
167
207
  #
168
208
  # @param [Integer] width
169
209
  # The width of the pixel data. Must be greater than 0.
@@ -179,7 +219,7 @@ class Sketchup::ImageRep
179
219
  # @param [Integer] row_padding
180
220
  # The row padding for the pixel data which is
181
221
  # sized in bytes. Row padding is used to pad each row with zeros so that each
182
- # scanline on the pixel data will end on the data-type boundry.
222
+ # scanline on the pixel data will end on the data-type boundary.
183
223
  #
184
224
  # @param [String] pixel_data
185
225
  # The binary string containing the pixel data
@@ -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 Importer interface lets you build your own importers for SketchUp. To
@@ -53,7 +53,8 @@
53
53
  # # processing the file.
54
54
  # def load_file(file_path, status)
55
55
  # UI.messagebox(file_path)
56
- # return 0 # 0 is the code for a successful import
56
+ #
57
+ # return Sketchup::Importer::ImportSuccess
57
58
  # end
58
59
  # end
59
60
  #
@@ -68,7 +69,6 @@ class Sketchup::Importer
68
69
  ImportFail = nil # Stub value.
69
70
  ImportFileNotFound = nil # Stub value.
70
71
  ImportSuccess = nil # Stub value.
71
- ImporterNotFound = nil # Stub value.
72
72
 
73
73
  # Instance Methods
74
74
 
@@ -144,20 +144,19 @@ class Sketchup::Importer
144
144
  # File object and processing it in whatever way you need.
145
145
  #
146
146
  # You must return an integer success code to SketchUp when you are done.
147
- # These are the codes that SketchUp understands and what will happen when
148
- # SketchUp receives each key.
147
+ # These are the codes that SketchUp understands:
149
148
  #
150
- # - 0 = Import Success (no additional dialog shown)
151
- # - 1 = Import Failed (no additional dialog shown)
152
- # - 2 = Import Cancelled by User (SketchUp will show a "cancelled" dialog)
153
- # - 4 = Import File not Found (SketchUp will show a "not found" dialog)
154
- # - 5 = SketchUp version not supported (no additional dialog shown)
149
+ # - Sketchup::Importer::ImportSuccess
150
+ # - Sketchup::Importer::ImportFail
151
+ # - Sketchup::Importer::ImportCanceled - SketchUp will show a "cancelled" dialog
152
+ # - Sketchup::Importer::ImportFileNotFound - SketchUp will show a "not found" dialog
155
153
  #
156
154
  # @example
157
155
  # def load_file(file_path, status)
158
156
  # # Here is where you would open the file and process it.
159
- # UI.messagebox(file_path)
160
- # return 0 # Success
157
+ # puts file_path
158
+ #
159
+ # return Sketchup::Importer::ImportSuccess
161
160
  # end
162
161
  #
163
162
  # @param file_path
@@ -1,14 +1,23 @@
1
- # Copyright:: Copyright 2020 Trimble Inc.
1
+ # Copyright:: Copyright 2021 Trimble Inc.
2
2
  # License:: The MIT License (MIT)
3
3
 
4
- # The InputPoint used to pick entities that reside under the current cursor
5
- # location. InputPoint and PickHelper are similar, but InputPoint also uses
6
- # inferencing. Only tools react to cursor location. Therefore, most of the
7
- # methods in this class are only useful in the context of a tool you are
8
- # writing. For example, if you want to determine the entity that you just
9
- # clicked on with the mouse, you would use InputPoint.pick from within your
10
- # onLMouseButton method in a tool. See the example script linetool.rb for
11
- # examples of using the InputPoint class.
4
+ # The {Sketchup::InputPoint} class is used to pick 3d points and/or entities
5
+ # that reside under the current cursor location, similar to native Line tool
6
+ # and other drawing tools. Unlike {Sketchup::PickHelper},
7
+ # {Sketchup::InputPoint} uses inference, i.e. "snaps" to vertices and other
8
+ # entities when the cursor is close to them.
9
+ #
10
+ # Only {Sketchup::Tool}s react to cursor location and most of these methods are
11
+ # only useful in the context of a tool. For example, if you want to determine
12
+ # the 3d point you just moved the cursor over, you would use
13
+ # {#pick} from within your {Sketchup::Tool#onMouseMove} method.
14
+ # {Sketchup::InputPoints} are best picked from mouse move, as you want them to
15
+ # draw them to the view.
16
+ #
17
+ # For an example, see https://github.com/SketchUp/sketchup-ruby-api-tutorials/tree/master/examples/02_custom_tool.
18
+ #
19
+ # To lock inference similar to native SketchUp tools, see
20
+ # {View#lock_inference}.
12
21
  #
13
22
  # @version SketchUp 6.0
14
23
  class Sketchup::InputPoint
@@ -188,10 +197,8 @@ class Sketchup::InputPoint
188
197
  def edge
189
198
  end
190
199
 
191
- # The face method retrieves the face if the input point is getting its
192
- # position from a face.
193
- #
194
- # Otherwise it returns nil.
200
+ # The face method retrieves the face at or behind the input point. This can be
201
+ # used to determine a plane, similar to what native Rotate tool does.
195
202
  #
196
203
  # @example
197
204
  # view = Sketchup.active_model.active_view
@@ -200,8 +207,10 @@ class Sketchup::InputPoint
200
207
  # ip1 = view.inputpoint x,y
201
208
  # f = ip1.face
202
209
  #
203
- # @return face - a Face object if successful, or nil if
204
- # unsuccessful
210
+ # @note The InputPoint doesn't necessarily lie on the face, but can be e.g. on
211
+ # an edge in front of the face.
212
+ #
213
+ # @return [Sketchup::Face, nil]
205
214
  #
206
215
  # @version SketchUp 6.0
207
216
  def face
@@ -220,15 +229,18 @@ class Sketchup::InputPoint
220
229
  # sub-class {Sketchup::InputPoint} due to a bug in how SketchUp initialized
221
230
  # the class.
222
231
  #
223
- # @param pt_or_vertex
224
- # An optional Point3d or Vertex where the new InputPoint
225
- # should be created.
232
+ # @overload initialize()
226
233
  #
227
- # @return inputpoint - the newly created InputPoint object if
228
- # successful
234
+ # @return [Sketchup::InputPoint]
235
+ #
236
+ # @overload initialize(pt_or_vertex)
237
+ #
238
+ # @param pt_or_vertex [Geom::Point3d, Sketchup::Vertex] An optional Point3d
239
+ # or Vertex where the new InputPoint should be created.
240
+ # @return [Sketchup::InputPoint]
229
241
  #
230
242
  # @version SketchUp 6.0
231
- def initialize(pt_or_vertex)
243
+ def initialize(*args)
232
244
  end
233
245
 
234
246
  # The {#instance_path} method retrieves the instance path for the picked point.
@@ -1,14 +1,16 @@
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 component instance
5
- # events. To implement this observer, create a Ruby class of this type,
6
- # override the desired methods, and add an instance of the observer to the
7
- # objects of interests.
5
+ # events.
8
6
  #
9
7
  # Note that you may also attach {Sketchup::InstanceObserver}s to
10
8
  # {Sketchup::Group}s.
11
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
+ #
12
14
  # @example
13
15
  # # This is an example of an observer that watches a specific instance
14
16
  # # for open edit actions and shows a messagebox.
@@ -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 {Sketchup::InstancePath} class represent the instance path to a given
@@ -30,7 +30,7 @@ class Sketchup::InstancePath
30
30
  def ==(other)
31
31
  end
32
32
 
33
- # The elements of an instance path can be accessed like an array.
33
+ # The elements of an instance path can be accessed similarly to an array.
34
34
  #
35
35
  # @example
36
36
  # model = Sketchup.active_model
@@ -40,6 +40,9 @@ class Sketchup::InstancePath
40
40
  # path[0] == group # returns true
41
41
  # path[1] == edge # returns true
42
42
  #
43
+ # @note This method does not accept negative indices. For the exact behavior
44
+ # of an array, use +{#to_a}+.
45
+ #
43
46
  # @param [Integer] index
44
47
  #
45
48
  # @raise [IndexError] if the given index is out of bounds
@@ -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
4
  # The Layer class contains methods modifying and extracting information for a
5
5
  # layer.
6
6
  #
7
- # By default, a SketchUp model has one layer, Layer 0 (zero), which is the base
7
+ # By default, a SketchUp model has one layer, Layer 0 (Named "Untagged" in the
8
+ # UI since SketchUp 2020), which is the base
8
9
  # layer. You can't delete or rename Layer 0. Unlike certain other CAD software
9
10
  # packages, entities associated with different layers in SketchUp still
10
11
  # intersect with each other. (If you want collections of entities to not
@@ -15,12 +16,14 @@
15
16
  # wall and roof entities different groups, associate layers with those groups,
16
17
  # and then hide those layers so as to display just the floor plan in the model.
17
18
  #
18
- # You can programatically create a new layer by calling the Layers.add method.
19
- #
20
19
  # @example
21
20
  # model = Sketchup.active_model
22
21
  # layers = model.layers
23
- # new_layer = layers.add "test layer"
22
+ # new_layer = layers.add('Doors')
23
+ #
24
+ # @note As of SketchUp 2020 "Layers" were renamed to "Tags" in the UI.
25
+ # The API retains the use of "Layer" for compatibility and is synonymous with
26
+ # "Tag".
24
27
  #
25
28
  # @version SketchUp 6.0
26
29
  class Sketchup::Layer < Sketchup::Entity
@@ -31,8 +34,8 @@ class Sketchup::Layer < Sketchup::Entity
31
34
 
32
35
  # Instance Methods
33
36
 
34
- # The <=> method is used to compare two layers based on their names. You could
35
- # use this for sorting if you're building a list of layer names.
37
+ # The {#<=>} method is used to compare two layers based on their names. You
38
+ # could use this for sorting if you're building a list of layer names.
36
39
  #
37
40
  # @example
38
41
  # model = Sketchup.active_model
@@ -42,37 +45,31 @@ class Sketchup::Layer < Sketchup::Entity
42
45
  # layer2 = layers[1]
43
46
  # status = layer1 <=> layer2
44
47
  #
45
- # @param layer2
46
- # A Layer object.
48
+ # @param [Sketchup::Layer] layer2
47
49
  #
48
- # @return status - -1 if layer1 is less than layer2. 1 if layer2
49
- # is less than layer1. 0 if layer1 and layer2 are
50
- # equal.
50
+ # @return [Integer] -1 if layer1 is less than layer2. 1 if layer2
51
+ # is less than layer1. 0 if layer1 and layer2 are equal.
51
52
  #
52
53
  # @version SketchUp 6.0
53
54
  def <=>(layer2)
54
55
  end
55
56
 
56
- # The == method is used to determine if two layers are the same.
57
+ # The {#==} method is used to determine if two layers are the same.
57
58
  #
58
59
  # @example
59
60
  # model = Sketchup.active_model
60
61
  # layers = model.layers
61
- # layer1 = layers.add "test layer 1"
62
- # layer2 = layers.add "test layer 2"
63
- # status = layer1 == layer2
64
- #
65
- # @param layer2
66
- # A Layer object.
62
+ # layer1 = layers.add("Test layer 1")
63
+ # layer2 = layers.add("Test layer 2")
64
+ # equal = layer1 == layer2
67
65
  #
68
- # @return status - true if layer1 and layer2 are equal. false if
69
- # layer1 and layer2 are not equal.
66
+ # @param [Object] other
70
67
  #
71
68
  # @version SketchUp 6.0
72
- def ==(layer2)
69
+ def ==(other)
73
70
  end
74
71
 
75
- # The color method is used to retrieve the color of the layer.
72
+ # The {#color} method is used to retrieve the color of the layer.
76
73
  #
77
74
  # @example
78
75
  # model = Sketchup.active_model
@@ -80,13 +77,13 @@ class Sketchup::Layer < Sketchup::Entity
80
77
  # new_layer = layers.add('Test layer')
81
78
  # color = new_layer.color
82
79
  #
83
- # @return color - the color of the Layer object
80
+ # @return [Sketchup::Color]
84
81
  #
85
82
  # @version SketchUp 2014
86
83
  def color
87
84
  end
88
85
 
89
- # The color= method is used to set the name of a layer.
86
+ # The {#color=} method is used to set the name of a layer.
90
87
  #
91
88
  # @example
92
89
  # model = Sketchup.active_model
@@ -94,10 +91,7 @@ class Sketchup::Layer < Sketchup::Entity
94
91
  # new_layer = layers.add('Test layer')
95
92
  # new_layer.color = Sketchup::Color.new(192, 0, 0)
96
93
  #
97
- # @param color
98
- # The new color for the Layer object.
99
- #
100
- # @return color
94
+ # @param [Sketchup::Color] color
101
95
  #
102
96
  # @version SketchUp 2014
103
97
  def color=(color)
@@ -111,7 +105,7 @@ class Sketchup::Layer < Sketchup::Entity
111
105
  # new_layer = layers.add ("test layer")
112
106
  # name = new_layer.display_name
113
107
  #
114
- # @return [String] the display name of the Layer object
108
+ # @return [String]
115
109
  #
116
110
  # @see #name
117
111
  #
@@ -119,6 +113,48 @@ class Sketchup::Layer < Sketchup::Entity
119
113
  def display_name
120
114
  end
121
115
 
116
+ # The {#folder} method is used to return the parent layer folder of a layer.
117
+ #
118
+ # @api TagFolder
119
+ #
120
+ # @example
121
+ # model = Sketchup.active_model
122
+ # layers = model.layers
123
+ # folder1 = layers.add('Folder1')
124
+ # parent_folder = folder1.folder # Returns: nil
125
+ #
126
+ # folder2 = folder1.add('Folder2')
127
+ # parent_folder = folder2.folder # Returns: folder1
128
+ #
129
+ # @return [Sketchup::LayerFolder, nil] +nil+ if the folder is a direct child to
130
+ # the layer manager.
131
+ #
132
+ # @version SketchUp 2021.0
133
+ def folder
134
+ end
135
+
136
+ # The {#folder=} method is used to set the parent layer folder of a layer.
137
+ #
138
+ # This will trigger +onParentFolderChanged+ in normal cases and
139
+ # +onLayerChanged+ during undo/redo.
140
+ #
141
+ # @api TagFolder
142
+ #
143
+ # @example
144
+ # model = Sketchup.active_model
145
+ # layers = model.layers
146
+ # folder = layers.add_folder('Hello')
147
+ # layer = layers.add_layer('World')
148
+ # layer.folder = folder
149
+ #
150
+ # @param [Sketchup::LayerFolder, nil] parent
151
+ # +nil+ will make the layer a
152
+ # direct child to the layer manager.
153
+ #
154
+ # @version SketchUp 2021.0
155
+ def folder=(parent)
156
+ end
157
+
122
158
  # The {#line_style} method retrieves the line style on this layer.
123
159
  #
124
160
  # @example
@@ -161,7 +197,7 @@ class Sketchup::Layer < Sketchup::Entity
161
197
  def name
162
198
  end
163
199
 
164
- # The name= method is used to set the name of a layer.
200
+ # The {#name=} method is used to set the name of a layer.
165
201
  #
166
202
  # @example
167
203
  # model = Sketchup.active_model
@@ -169,16 +205,13 @@ class Sketchup::Layer < Sketchup::Entity
169
205
  # new_layer = layers.add "test layer"
170
206
  # name = new_layer.name = "new test layer"
171
207
  #
172
- # @param name
173
- # The new name for the Layer object.
174
- #
175
- # @return name - the newly set name
208
+ # @param [String] name
176
209
  #
177
210
  # @version SketchUp 6.0
178
211
  def name=(name)
179
212
  end
180
213
 
181
- # The page_behavior method is used to retrieve the visibility behavior of the
214
+ # The {#page_behavior} method is used to retrieve the visibility behavior of the
182
215
  # layer for new pages and existing pages. For example, you may want your layer
183
216
  # to be visible or hidden by default in any new pages (aka Scenes) created by
184
217
  # the user.
@@ -188,15 +221,25 @@ class Sketchup::Layer < Sketchup::Entity
188
221
  # determined by one of these values:
189
222
  #
190
223
  # The behaviour is composed of a combination of these flags:
191
- # - LAYER_VISIBLE_BY_DEFAULT: 0x0000
192
- # - LAYER_HIDDEN_BY_DEFAULT: 0x0001
193
- # - LAYER_USES_DEFAULT_VISIBILITY_ON_NEW_PAGES: 0x0000
194
- # - LAYER_IS_VISIBLE_ON_NEW_PAGES: 0x0010
195
- # - LAYER_IS_HIDDEN_ON_NEW_PAGES: 0x0020
224
+ #
225
+ # [Default visibility]
226
+ # These flags are used to set the value of {#page_behavior}. A page keeps
227
+ # a list of layers that do not have their default behavior. If a layer
228
+ # is not in that list, then it is set to its default visibility which
229
+ # is determined by one of these flags.
230
+ # - {LAYER_VISIBLE_BY_DEFAULT}: +0x0000+
231
+ # - {LAYER_HIDDEN_BY_DEFAULT}: +0x0001+
232
+ #
233
+ # [Visibility on new pages]
234
+ # You can also set this addition flag that controls the visibility of
235
+ # a layer on newly created pages.
236
+ # - {LAYER_USES_DEFAULT_VISIBILITY_ON_NEW_PAGES}: +0x0000+
237
+ # - {LAYER_IS_VISIBLE_ON_NEW_PAGES}: +0x0010+
238
+ # - {LAYER_IS_HIDDEN_ON_NEW_PAGES}: +0x0020+
196
239
  #
197
240
  # The default visibility for a layer is set by either
198
- # <code>LAYER_VISIBLE_BY_DEFAULT</code> or
199
- # <code>LAYER_HIDDEN_BY_DEFAULT</code>. This is what will be used when a page
241
+ # {LAYER_VISIBLE_BY_DEFAULT} or
242
+ # {LAYER_HIDDEN_BY_DEFAULT}. This is what will be used when a page
200
243
  # does not contain the visibility state of a layer.
201
244
  #
202
245
  # The remaining flags control the visibility of the layer for new pages.
@@ -208,8 +251,7 @@ class Sketchup::Layer < Sketchup::Entity
208
251
  # hidden_by_default = (layer.page_behavior & LAYER_HIDDEN_BY_DEFAULT) ==
209
252
  # LAYER_HIDDEN_BY_DEFAULT
210
253
  #
211
- # @return pagebehavior - an integer representing the current
212
- # behavior of the layer.
254
+ # @return [Integer] an integer representing the current behavior of the layer.
213
255
  #
214
256
  # @version SketchUp 6.0
215
257
  def page_behavior
@@ -222,11 +264,25 @@ class Sketchup::Layer < Sketchup::Entity
222
264
  # visibility of the layer is used.
223
265
  #
224
266
  # The behavior is composed of a combination of these flags:
225
- # [+LAYER_VISIBLE_BY_DEFAULT: 0x0000+]
226
- # [+LAYER_HIDDEN_BY_DEFAULT: 0x0001+]
227
- # [+LAYER_USES_DEFAULT_VISIBILITY_ON_NEW_PAGES: 0x0000+]
228
- # [+LAYER_IS_VISIBLE_ON_NEW_PAGES: 0x0010+]
229
- # [+LAYER_IS_HIDDEN_ON_NEW_PAGES: 0x0020+]
267
+ #
268
+ # [Default visibility]
269
+ # These flags are used to set the value of {#page_behavior}. A page keeps
270
+ # a list of layers that do not have their default behavior. If a layer
271
+ # is not in that list, then it is set to its default visibility which
272
+ # is determined by one of these flags.
273
+ # - {LAYER_VISIBLE_BY_DEFAULT}: +0x0000+
274
+ # - {LAYER_HIDDEN_BY_DEFAULT}: +0x0001+
275
+ #
276
+ # [Visibility on new pages]
277
+ # You can also set this addition flag that controls the visibility of
278
+ # a layer on newly created pages.
279
+ # - {LAYER_USES_DEFAULT_VISIBILITY_ON_NEW_PAGES}: +0x0000+
280
+ # - {LAYER_IS_VISIBLE_ON_NEW_PAGES}: +0x0010+
281
+ # - {LAYER_IS_HIDDEN_ON_NEW_PAGES}: +0x0020+
282
+ #
283
+ # @bug Prior to SketchUp 2014 the +LAYER_HIDDEN_BY_DEFAULT+ flag
284
+ # would trigger the validation check in SketchUp that would reset the
285
+ # {#page_behavior} of the layer.
230
286
  #
231
287
  # @example
232
288
  # layers = Sketchup.active_model.layers
@@ -234,44 +290,35 @@ class Sketchup::Layer < Sketchup::Entity
234
290
  # behavior = LAYER_HIDDEN_BY_DEFAULT | LAYER_IS_HIDDEN_ON_NEW_PAGES
235
291
  # layer.page_behavior = behavior
236
292
  #
237
- # @note Prior to SketchUp 2014 the +LAYER_HIDDEN_BY_DEFAULT+ flag
238
- # would trigger the validation check in SketchUp that would reset the
239
- # {#page_behavior} of the layer.
240
- #
241
293
  # @param [Integer] page_behavior
242
294
  #
243
- # @return [Integer]
244
- #
245
295
  # @version SketchUp 6.0
246
296
  def page_behavior=(page_behavior)
247
297
  end
248
298
 
249
- # The visible= method is used to set if the layer is visible.
299
+ # The {#visible=} method is used to set if the layer is visible.
250
300
  #
251
301
  # @example
252
302
  # model = Sketchup.active_model
253
303
  # layers = model.layers
254
- # new_layer = layers.add "test layer"
304
+ # layer = layers.add('Hello World')
305
+ # layer.visible = false
255
306
  #
256
- # # Hide the layer.
257
- # new_layer.visible = false
258
- #
259
- # @param is_visible
260
- # The new visibility setting.
307
+ # @param [Boolean] visible
261
308
  #
262
309
  # @version SketchUp 6.0
263
- def visible=(is_visible)
310
+ def visible=(visible)
264
311
  end
265
312
 
266
- # The visible? method is used to determine if the layer is visible.
313
+ # The {#visible?} method is used to determine if the layer is visible.
267
314
  #
268
315
  # @example
269
316
  # model = Sketchup.active_model
270
317
  # layers = model.layers
271
- # new_layer = layers.add "test layer"
272
- # UI.messagebox(new_layer.visible?)
318
+ # layer = layers.add('Hello World')
319
+ # layer.visible? # Returns: true
273
320
  #
274
- # @return [Boolean] true if the layer is visible
321
+ # @return [Boolean]
275
322
  #
276
323
  # @version SketchUp 6.0
277
324
  def visible?