sketchup-api-stubs 0.7.9 → 0.7.11

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 (160) hide show
  1. checksums.yaml +4 -4
  2. data/lib/sketchup-api-stubs/sketchup.rb +157 -151
  3. data/lib/sketchup-api-stubs/stubs/Array.rb +741 -741
  4. data/lib/sketchup-api-stubs/stubs/Geom/BoundingBox.rb +322 -322
  5. data/lib/sketchup-api-stubs/stubs/Geom/Bounds2d.rb +182 -172
  6. data/lib/sketchup-api-stubs/stubs/Geom/LatLong.rb +111 -126
  7. data/lib/sketchup-api-stubs/stubs/Geom/OrientedBounds2d.rb +102 -102
  8. data/lib/sketchup-api-stubs/stubs/Geom/Point2d.rb +423 -400
  9. data/lib/sketchup-api-stubs/stubs/Geom/Point3d.rb +693 -661
  10. data/lib/sketchup-api-stubs/stubs/Geom/PolygonMesh.rb +535 -509
  11. data/lib/sketchup-api-stubs/stubs/Geom/Transformation.rb +500 -476
  12. data/lib/sketchup-api-stubs/stubs/Geom/Transformation2d.rb +267 -263
  13. data/lib/sketchup-api-stubs/stubs/Geom/UTM.rb +133 -141
  14. data/lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb +547 -522
  15. data/lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb +678 -693
  16. data/lib/sketchup-api-stubs/stubs/Geom.rb +351 -351
  17. data/lib/sketchup-api-stubs/stubs/LanguageHandler.rb +93 -93
  18. data/lib/sketchup-api-stubs/stubs/Layout/AngularDimension.rb +595 -595
  19. data/lib/sketchup-api-stubs/stubs/Layout/AutoTextDefinition.rb +751 -747
  20. data/lib/sketchup-api-stubs/stubs/Layout/AutoTextDefinitions.rb +183 -183
  21. data/lib/sketchup-api-stubs/stubs/Layout/ConnectionPoint.rb +70 -70
  22. data/lib/sketchup-api-stubs/stubs/Layout/Dictionary.rb +234 -0
  23. data/lib/sketchup-api-stubs/stubs/Layout/Document.rb +683 -517
  24. data/lib/sketchup-api-stubs/stubs/Layout/Ellipse.rb +29 -29
  25. data/lib/sketchup-api-stubs/stubs/Layout/Entities.rb +148 -148
  26. data/lib/sketchup-api-stubs/stubs/Layout/Entity.rb +464 -353
  27. data/lib/sketchup-api-stubs/stubs/Layout/FormattedText.rb +354 -354
  28. data/lib/sketchup-api-stubs/stubs/Layout/Grid.rb +311 -311
  29. data/lib/sketchup-api-stubs/stubs/Layout/Group.rb +261 -261
  30. data/lib/sketchup-api-stubs/stubs/Layout/Image.rb +91 -91
  31. data/lib/sketchup-api-stubs/stubs/Layout/Label.rb +370 -370
  32. data/lib/sketchup-api-stubs/stubs/Layout/Layer.rb +218 -218
  33. data/lib/sketchup-api-stubs/stubs/Layout/LayerInstance.rb +128 -128
  34. data/lib/sketchup-api-stubs/stubs/Layout/Layers.rb +225 -225
  35. data/lib/sketchup-api-stubs/stubs/Layout/LinearDimension.rb +614 -567
  36. data/lib/sketchup-api-stubs/stubs/Layout/LockedEntityError.rb +10 -10
  37. data/lib/sketchup-api-stubs/stubs/Layout/LockedLayerError.rb +11 -11
  38. data/lib/sketchup-api-stubs/stubs/Layout/Page.rb +282 -183
  39. data/lib/sketchup-api-stubs/stubs/Layout/PageInfo.rb +458 -387
  40. data/lib/sketchup-api-stubs/stubs/Layout/Pages.rb +209 -209
  41. data/lib/sketchup-api-stubs/stubs/Layout/Path.rb +346 -344
  42. data/lib/sketchup-api-stubs/stubs/Layout/Rectangle.rb +174 -174
  43. data/lib/sketchup-api-stubs/stubs/Layout/ReferenceEntity.rb +82 -82
  44. data/lib/sketchup-api-stubs/stubs/Layout/SketchUpModel.rb +714 -692
  45. data/lib/sketchup-api-stubs/stubs/Layout/Style.rb +1565 -1519
  46. data/lib/sketchup-api-stubs/stubs/Layout/Table.rb +290 -290
  47. data/lib/sketchup-api-stubs/stubs/Layout/TableCell.rb +149 -149
  48. data/lib/sketchup-api-stubs/stubs/Layout/TableColumn.rb +139 -139
  49. data/lib/sketchup-api-stubs/stubs/Layout/TableRow.rb +135 -135
  50. data/lib/sketchup-api-stubs/stubs/Layout.rb +25 -25
  51. data/lib/sketchup-api-stubs/stubs/Length.rb +286 -278
  52. data/lib/sketchup-api-stubs/stubs/Numeric.rb +249 -249
  53. data/lib/sketchup-api-stubs/stubs/Sketchup/Animation.rb +196 -144
  54. data/lib/sketchup-api-stubs/stubs/Sketchup/AppObserver.rb +169 -169
  55. data/lib/sketchup-api-stubs/stubs/Sketchup/ArcCurve.rb +226 -209
  56. data/lib/sketchup-api-stubs/stubs/Sketchup/AttributeDictionaries.rb +145 -150
  57. data/lib/sketchup-api-stubs/stubs/Sketchup/AttributeDictionary.rb +294 -281
  58. data/lib/sketchup-api-stubs/stubs/Sketchup/Axes.rb +149 -149
  59. data/lib/sketchup-api-stubs/stubs/Sketchup/Behavior.rb +296 -302
  60. data/lib/sketchup-api-stubs/stubs/Sketchup/Camera.rb +473 -478
  61. data/lib/sketchup-api-stubs/stubs/Sketchup/ClassificationSchema.rb +63 -63
  62. data/lib/sketchup-api-stubs/stubs/Sketchup/Classifications.rb +121 -121
  63. data/lib/sketchup-api-stubs/stubs/Sketchup/Color.rb +294 -294
  64. data/lib/sketchup-api-stubs/stubs/Sketchup/ComponentDefinition.rb +673 -659
  65. data/lib/sketchup-api-stubs/stubs/Sketchup/ComponentInstance.rb +600 -593
  66. data/lib/sketchup-api-stubs/stubs/Sketchup/Console.rb +76 -76
  67. data/lib/sketchup-api-stubs/stubs/Sketchup/ConstructionLine.rb +252 -257
  68. data/lib/sketchup-api-stubs/stubs/Sketchup/ConstructionPoint.rb +32 -32
  69. data/lib/sketchup-api-stubs/stubs/Sketchup/Curve.rb +201 -201
  70. data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionList.rb +443 -449
  71. data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionObserver.rb +74 -74
  72. data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionsObserver.rb +104 -104
  73. data/lib/sketchup-api-stubs/stubs/Sketchup/Dimension.rb +167 -165
  74. data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionLinear.rb +306 -306
  75. data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionObserver.rb +42 -42
  76. data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionRadial.rb +87 -87
  77. data/lib/sketchup-api-stubs/stubs/Sketchup/Drawingelement.rb +403 -406
  78. data/lib/sketchup-api-stubs/stubs/Sketchup/Edge.rb +397 -397
  79. data/lib/sketchup-api-stubs/stubs/Sketchup/EdgeUse.rb +211 -211
  80. data/lib/sketchup-api-stubs/stubs/Sketchup/Entities.rb +1282 -1239
  81. data/lib/sketchup-api-stubs/stubs/Sketchup/EntitiesBuilder.rb +261 -261
  82. data/lib/sketchup-api-stubs/stubs/Sketchup/EntitiesObserver.rb +127 -127
  83. data/lib/sketchup-api-stubs/stubs/Sketchup/Entity.rb +519 -545
  84. data/lib/sketchup-api-stubs/stubs/Sketchup/EntityObserver.rb +60 -60
  85. data/lib/sketchup-api-stubs/stubs/Sketchup/Environment.rb +406 -0
  86. data/lib/sketchup-api-stubs/stubs/Sketchup/Environments.rb +185 -0
  87. data/lib/sketchup-api-stubs/stubs/Sketchup/EnvironmentsObserver.rb +113 -0
  88. data/lib/sketchup-api-stubs/stubs/Sketchup/ExtensionsManager.rb +122 -125
  89. data/lib/sketchup-api-stubs/stubs/Sketchup/Face.rb +1006 -937
  90. data/lib/sketchup-api-stubs/stubs/Sketchup/FrameChangeObserver.rb +102 -102
  91. data/lib/sketchup-api-stubs/stubs/Sketchup/Group.rb +740 -750
  92. data/lib/sketchup-api-stubs/stubs/Sketchup/Http/Request.rb +289 -282
  93. data/lib/sketchup-api-stubs/stubs/Sketchup/Http/Response.rb +64 -62
  94. data/lib/sketchup-api-stubs/stubs/Sketchup/Http.rb +27 -27
  95. data/lib/sketchup-api-stubs/stubs/Sketchup/Image.rb +405 -468
  96. data/lib/sketchup-api-stubs/stubs/Sketchup/ImageRep.rb +266 -266
  97. data/lib/sketchup-api-stubs/stubs/Sketchup/Importer.rb +189 -189
  98. data/lib/sketchup-api-stubs/stubs/Sketchup/InputPoint.rb +432 -406
  99. data/lib/sketchup-api-stubs/stubs/Sketchup/InstanceObserver.rb +84 -84
  100. data/lib/sketchup-api-stubs/stubs/Sketchup/InstancePath.rb +307 -306
  101. data/lib/sketchup-api-stubs/stubs/Sketchup/Layer.rb +332 -326
  102. data/lib/sketchup-api-stubs/stubs/Sketchup/LayerFolder.rb +380 -422
  103. data/lib/sketchup-api-stubs/stubs/Sketchup/Layers.rb +409 -427
  104. data/lib/sketchup-api-stubs/stubs/Sketchup/LayersObserver.rb +241 -249
  105. data/lib/sketchup-api-stubs/stubs/Sketchup/Licensing/ExtensionLicense.rb +86 -86
  106. data/lib/sketchup-api-stubs/stubs/Sketchup/Licensing.rb +55 -48
  107. data/lib/sketchup-api-stubs/stubs/Sketchup/LineStyle.rb +24 -24
  108. data/lib/sketchup-api-stubs/stubs/Sketchup/LineStyles.rb +114 -114
  109. data/lib/sketchup-api-stubs/stubs/Sketchup/LoadHandler.rb +70 -0
  110. data/lib/sketchup-api-stubs/stubs/Sketchup/Loop.rb +137 -137
  111. data/lib/sketchup-api-stubs/stubs/Sketchup/Material.rb +1115 -414
  112. data/lib/sketchup-api-stubs/stubs/Sketchup/Materials.rb +330 -317
  113. data/lib/sketchup-api-stubs/stubs/Sketchup/MaterialsObserver.rb +142 -142
  114. data/lib/sketchup-api-stubs/stubs/Sketchup/Menu.rb +93 -93
  115. data/lib/sketchup-api-stubs/stubs/Sketchup/Model.rb +1714 -1652
  116. data/lib/sketchup-api-stubs/stubs/Sketchup/ModelObserver.rb +372 -357
  117. data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsManager.rb +133 -130
  118. data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsProvider.rb +271 -271
  119. data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsProviderObserver.rb +58 -58
  120. data/lib/sketchup-api-stubs/stubs/Sketchup/Overlay.rb +463 -490
  121. data/lib/sketchup-api-stubs/stubs/Sketchup/OverlaysManager.rb +104 -116
  122. data/lib/sketchup-api-stubs/stubs/Sketchup/Page.rb +939 -797
  123. data/lib/sketchup-api-stubs/stubs/Sketchup/Pages.rb +388 -361
  124. data/lib/sketchup-api-stubs/stubs/Sketchup/PagesObserver.rb +77 -77
  125. data/lib/sketchup-api-stubs/stubs/Sketchup/PickHelper.rb +501 -478
  126. data/lib/sketchup-api-stubs/stubs/Sketchup/RegionalSettings.rb +43 -43
  127. data/lib/sketchup-api-stubs/stubs/Sketchup/RenderingOptions.rb +385 -361
  128. data/lib/sketchup-api-stubs/stubs/Sketchup/RenderingOptionsObserver.rb +45 -45
  129. data/lib/sketchup-api-stubs/stubs/Sketchup/SectionPlane.rb +150 -150
  130. data/lib/sketchup-api-stubs/stubs/Sketchup/Selection.rb +451 -458
  131. data/lib/sketchup-api-stubs/stubs/Sketchup/SelectionObserver.rb +115 -115
  132. data/lib/sketchup-api-stubs/stubs/Sketchup/Set.rb +211 -212
  133. data/lib/sketchup-api-stubs/stubs/Sketchup/ShadowInfo.rb +259 -255
  134. data/lib/sketchup-api-stubs/stubs/Sketchup/ShadowInfoObserver.rb +59 -59
  135. data/lib/sketchup-api-stubs/stubs/Sketchup/Skp.rb +40 -40
  136. data/lib/sketchup-api-stubs/stubs/Sketchup/Snap.rb +125 -0
  137. data/lib/sketchup-api-stubs/stubs/Sketchup/Style.rb +88 -69
  138. data/lib/sketchup-api-stubs/stubs/Sketchup/Styles.rb +263 -217
  139. data/lib/sketchup-api-stubs/stubs/Sketchup/Text.rb +283 -262
  140. data/lib/sketchup-api-stubs/stubs/Sketchup/Texture.rb +199 -217
  141. data/lib/sketchup-api-stubs/stubs/Sketchup/TextureWriter.rb +237 -237
  142. data/lib/sketchup-api-stubs/stubs/Sketchup/Tool.rb +924 -834
  143. data/lib/sketchup-api-stubs/stubs/Sketchup/Tools.rb +132 -132
  144. data/lib/sketchup-api-stubs/stubs/Sketchup/ToolsObserver.rb +156 -156
  145. data/lib/sketchup-api-stubs/stubs/Sketchup/UVHelper.rb +75 -75
  146. data/lib/sketchup-api-stubs/stubs/Sketchup/Vertex.rb +143 -142
  147. data/lib/sketchup-api-stubs/stubs/Sketchup/View.rb +1566 -1311
  148. data/lib/sketchup-api-stubs/stubs/Sketchup/ViewObserver.rb +71 -45
  149. data/lib/sketchup-api-stubs/stubs/Sketchup.rb +1429 -1377
  150. data/lib/sketchup-api-stubs/stubs/SketchupExtension.rb +353 -353
  151. data/lib/sketchup-api-stubs/stubs/String.rb +24 -24
  152. data/lib/sketchup-api-stubs/stubs/UI/Command.rb +399 -389
  153. data/lib/sketchup-api-stubs/stubs/UI/HtmlDialog.rb +580 -494
  154. data/lib/sketchup-api-stubs/stubs/UI/Notification.rb +280 -269
  155. data/lib/sketchup-api-stubs/stubs/UI/Toolbar.rb +258 -241
  156. data/lib/sketchup-api-stubs/stubs/UI/WebDialog.rb +636 -635
  157. data/lib/sketchup-api-stubs/stubs/UI.rb +791 -683
  158. data/lib/sketchup-api-stubs/stubs/_top_level.rb +303 -303
  159. data/lib/sketchup-api-stubs.rb +1 -1
  160. metadata +10 -24
@@ -1,357 +1,372 @@
1
- # Copyright:: Copyright 2023 Trimble Inc.
2
- # License:: The MIT License (MIT)
3
-
4
- # This observer interface is implemented to react to model events.
5
- #
6
- # Note that the observers related to transactions (aka undoable operations)
7
- # are primarily for reporting and debugging. Performing any edit operations
8
- # of your own (such as modifying the model) inside the observer callback
9
- # should be avoided, as it could cause crashes or model corruption. The most
10
- # common use for these callbacks is to help debug problems where your
11
- # Ruby script's {Sketchup::Model#start_operation} and
12
- # {Sketchup::Model#commit_operation} calls are somehow conflicting with
13
- # SketchUp's native undo operations. You can set up an observer set to watch
14
- # precisely what is going on.
15
- #
16
- # @abstract To implement this observer, create a Ruby class of this type, override the
17
- # desired methods, and add an instance of the observer to the model.
18
- #
19
- # @example
20
- # # This is an example of an observer that watches the
21
- # # component placement event.
22
- # class MyModelObserver < Sketchup::ModelObserver
23
- # def onPlaceComponent(instance)
24
- # puts "onPlaceComponent: #{instance}"
25
- # end
26
- # end
27
- #
28
- # # Attach the observer.
29
- # Sketchup.active_model.add_observer(MyModelObserver.new)
30
- #
31
- # @version SketchUp 6.0
32
- class Sketchup::ModelObserver
33
-
34
- # Instance Methods
35
-
36
- # The {#onActivePathChanged} method is invoked when the user opens or closes a
37
- # {Sketchup::ComponentInstance} or {Sketchup::Group} for editing.
38
- #
39
- # When the user opens an instance for editing the positions and transformations
40
- # of the entities in the opened instance will be relative to global world
41
- # coordinates instead of the local coordinates relative to their parent.
42
- #
43
- # See {Sketchup::Model#active_path} and {Sketchup::Model#edit_transform} for
44
- # methods that report the current edit origin vs. the global origin, etc.
45
- #
46
- # By using this observer callback, you can keep track of the various nested
47
- # transformations as your users double click to drill into and out of
48
- # component edits.
49
- #
50
- # @example
51
- # # As the user double clicks into component edits, show the "path" along
52
- # # the model hierarchy they have followed to get here.
53
- # def onActivePathChanged(model)
54
- # puts "onActivePathChanged: #{model}"
55
- # end
56
- #
57
- # @param [Sketchup::Model] model
58
- #
59
- # @return [nil]
60
- #
61
- # @see Sketchup::Model#active_path
62
- #
63
- # @see Sketchup::Model#edit_transform
64
- def onActivePathChanged(model)
65
- end
66
-
67
- # The {#onAfterComponentSaveAs} method is invoked when the user context-clicks >
68
- # Save As on a component instance. It is called just after the component is
69
- # written to disk, so you can restore the component to some state before
70
- # returning control to the user.
71
- #
72
- # @example
73
- # def onAfterComponentSaveAs(model)
74
- # puts "onAfterComponentSaveAs: #{model}"
75
- # end
76
- #
77
- # @param [Sketchup::Model] model
78
- #
79
- # @return [nil]
80
- #
81
- # @see #onBeforeComponentSaveAs
82
- #
83
- # @version SketchUp 7.0
84
- def onAfterComponentSaveAs(model)
85
- end
86
-
87
- # The {#onBeforeComponentSaveAs} method is invoked when the user
88
- # context-clicks > Save As on a component instance. It is called just before
89
- # the component is written to disk, so you can make changes within the handler
90
- # and it will make it into the save.
91
- #
92
- # For example, you may decide that you want to add some attribute to every
93
- # component that is saved out, but you do not want that attribute sticking
94
- # around inside the current model. Within {#onBeforeComponentSaveAs} you could
95
- # add the attribute, and within {#onAfterComponentSaveAs} you could delete that
96
- # attribute.
97
- #
98
- # The callback is not sent the component that is to be saved, but the
99
- # model's selection will contain it.
100
- #
101
- # @example
102
- # def onBeforeComponentSaveAs(model)
103
- # puts "onBeforeComponentSaveAs: #{model}"
104
- # end
105
- #
106
- # @param [Sketchup::Model] model
107
- #
108
- # @return [nil]
109
- #
110
- # @version SketchUp 7.0
111
- def onBeforeComponentSaveAs(model)
112
- end
113
-
114
- # The {#onDeleteModel} method is invoked when a model is deleted.
115
- #
116
- # @example
117
- # def onDeleteModel(model)
118
- # puts "onDeleteModel: #{model}"
119
- # end
120
- #
121
- # @param [Sketchup::Model] model
122
- #
123
- # @return [nil]
124
- #
125
- # @version SketchUp 6.0
126
- def onDeleteModel(model)
127
- end
128
-
129
- # The {#onEraseAll} method is invoked when everything in a model is erased.
130
- #
131
- # @example
132
- # def onEraseAll(model)
133
- # puts "onEraseAll: #{model}"
134
- # end
135
- #
136
- # @param [Sketchup::Model] model
137
- #
138
- # @return [nil]
139
- #
140
- # @version SketchUp 6.0
141
- def onEraseAll(model)
142
- end
143
-
144
- # The {#onExplode method} is invoked whenever a component anywhere in this
145
- # model is exploded. This is an easier way to watch explode events vs.
146
- # attaching an InstanceObserver to every instance in the model.
147
- #
148
- # Since the callback does not return what was exploded, one solution is to
149
- # place a selection observer that keeps track of which entities whose
150
- # explosion you are interested in are in the selection. Since SketchUp's
151
- # user interface only provides a means of exploding the selection, this
152
- # method is a reliable way to know what was just exploded.
153
- #
154
- # Another method would be to watch
155
- # {Sketchup::ComponentDefinition.count_instances} to determine what just
156
- # changed, as any components that were exploded will now be less an instance.
157
- #
158
- # @example
159
- # def onExplode(model)
160
- # puts "onExplode: #{model}"
161
- # end
162
- #
163
- # @param [Sketchup::Model] model
164
- #
165
- # @return [nil]
166
- #
167
- # @version SketchUp 7.0
168
- def onExplode(model)
169
- end
170
-
171
- # The {#onPidChanged} method is invoked when a persistent id in the model
172
- # changes. For example when entities are grouped.
173
- #
174
- # @example
175
- # def onPidChanged(model, old_pid, new_pid)
176
- # puts "onPidChanged: #{model}, #{old_pid} => #{new_pid}"
177
- # end
178
- #
179
- # @param [Sketchup::Model] model
180
- #
181
- # @param [Integer] old_pid
182
- #
183
- # @param [Integer] new_pid
184
- #
185
- # @return [nil]
186
- #
187
- # @version SketchUp 2017
188
- def onPidChanged(model, old_pid, new_pid)
189
- end
190
-
191
- # The {#onPlaceComponent} method is invoked when a component is "placed" into
192
- # the model, meaning it is dragged from the Component Browser.
193
- #
194
- # @example
195
- # def onPlaceComponent(model)
196
- # puts "onPlaceComponent: #{model}"
197
- # end
198
- #
199
- # @param [Sketchup::Model] model
200
- #
201
- # @return [nil]
202
- #
203
- # @version SketchUp 7.0
204
- def onPlaceComponent(model)
205
- end
206
-
207
- # The {#onPostSaveModel} method is invoked after a model has been saved to disk.
208
- #
209
- # @example
210
- # def onPostSaveModel(model)
211
- # puts "onPostSaveModel: #{model}"
212
- # end
213
- #
214
- # @param [Sketchup::Model] model
215
- #
216
- # @return [nil]
217
- #
218
- # @version SketchUp 8.0
219
- def onPostSaveModel(model)
220
- end
221
-
222
- # The {#onPreSaveModel} method is invoked before a model is saved to disk.
223
- #
224
- # @example
225
- # def onPreSaveModel(model)
226
- # puts "onPreSaveModel: #{model}"
227
- # end
228
- #
229
- # @param [Sketchup::Model] model
230
- #
231
- # @return [nil]
232
- #
233
- # @version SketchUp 8.0
234
- def onPreSaveModel(model)
235
- end
236
-
237
- # The {#onSaveModel} method is invoked after a model has been saved to disk.
238
- #
239
- # @example
240
- # def onSaveModel(model)
241
- # puts "onSaveModel: #{model}"
242
- # end
243
- #
244
- # @param [Sketchup::Model] model
245
- #
246
- # @return [nil]
247
- #
248
- # @version SketchUp 6.0
249
- def onSaveModel(model)
250
- end
251
-
252
- # The {#onTransactionAbort} method is invoked when a transaction is aborted.
253
- #
254
- # @example
255
- # def onTransactionAbort(model)
256
- # puts "onTransactionAbort: #{model}"
257
- # end
258
- #
259
- # @param [Sketchup::Model] model
260
- #
261
- # @return [nil]
262
- #
263
- # @see Sketchup::Model#abort_operation
264
- #
265
- # @version SketchUp 6.0
266
- def onTransactionAbort(model)
267
- end
268
-
269
- # The {#onTransactionCommit} method is invoked when a transaction is completed.
270
- #
271
- # @example
272
- # def onTransactionCommit(model)
273
- # puts "onTransactionCommit: #{model}"
274
- # end
275
- #
276
- # @param [Sketchup::Model] model
277
- #
278
- # @return [nil]
279
- #
280
- # @see Sketchup::Model#commit_operation
281
- #
282
- # @version SketchUp 6.0
283
- def onTransactionCommit(model)
284
- end
285
-
286
- # The {#onTransactionEmpty} method is invoked when a transaction
287
- # (aka an undoable operation) starts and then is committed without anything
288
- # being altered in between.
289
- #
290
- # @example
291
- # def onTransactionEmpty(model)
292
- # puts "onTransactionEmpty: #{model}"
293
- # end
294
- #
295
- # @param [Sketchup::Model] model
296
- #
297
- # @return [nil]
298
- #
299
- # @see Sketchup::Model#start_operation
300
- #
301
- # @version SketchUp 6.0
302
- def onTransactionEmpty(model)
303
- end
304
-
305
- # The {#onTransactionRedo} method is invoked when the user "redoes" a
306
- # transaction (aka undo operation.) You can programmatically fire a redo by
307
- # calling +Sketchup.sendAction("editRedo")+.
308
- #
309
- # @example
310
- # def onTransactionRedo(model)
311
- # puts "onTransactionRedo: #{model}"
312
- # end
313
- #
314
- # @param [Sketchup::Model] model
315
- #
316
- # @return [nil]
317
- #
318
- # @version SketchUp 6.0
319
- def onTransactionRedo(model)
320
- end
321
-
322
- # The {#onTransactionStart} method is invoked when a transaction
323
- # (aka an undoable operation) starts.
324
- #
325
- # @example
326
- # def onTransactionStart(model)
327
- # puts "onTransactionStart: #{model}"
328
- # end
329
- #
330
- # @param [Sketchup::Model] model
331
- #
332
- # @return [nil]
333
- #
334
- # @see Sketchup::Model#start_operation
335
- #
336
- # @version SketchUp 6.0
337
- def onTransactionStart(model)
338
- end
339
-
340
- # The {#onTransactionUndo method} is invoked when the user "undoes" a
341
- # transaction (aka undo operation.) You can programmatically fire an undo by
342
- # calling +Sketchup.sendAction("editUndo")+.
343
- #
344
- # @example
345
- # def onTransactionUndo(model)
346
- # puts "onTransactionUndo: #{model}"
347
- # end
348
- #
349
- # @param [Sketchup::Model] model
350
- #
351
- # @return [nil]
352
- #
353
- # @version SketchUp 6.0
354
- def onTransactionUndo(model)
355
- end
356
-
357
- end
1
+ # Copyright:: Copyright 2026 Trimble Inc.
2
+ # License:: The MIT License (MIT)
3
+
4
+ # This observer interface is implemented to react to model events.
5
+ #
6
+ # Note that the observers related to transactions (aka undoable operations)
7
+ # are primarily for reporting and debugging. Performing any edit operations
8
+ # of your own (such as modifying the model) inside the observer callback
9
+ # should be avoided, as it could cause crashes or model corruption. The most
10
+ # common use for these callbacks is to help debug problems where your
11
+ # Ruby script's {Sketchup::Model#start_operation} and
12
+ # {Sketchup::Model#commit_operation} calls are somehow conflicting with
13
+ # SketchUp's native undo operations. You can set up an observer set to watch
14
+ # precisely what is going on.
15
+ #
16
+ # @abstract To implement this observer, create a Ruby class of this type, override the
17
+ # desired methods, and add an instance of the observer to the model.
18
+ #
19
+ # @example
20
+ # # This is an example of an observer that watches the
21
+ # # component placement event.
22
+ # class MyModelObserver < Sketchup::ModelObserver
23
+ # def onPlaceComponent(instance)
24
+ # puts "onPlaceComponent: #{instance}"
25
+ # end
26
+ # end
27
+ #
28
+ # # Attach the observer.
29
+ # Sketchup.active_model.add_observer(MyModelObserver.new)
30
+ #
31
+ # @version SketchUp 6.0
32
+ class Sketchup::ModelObserver
33
+
34
+ # Instance Methods
35
+
36
+ # The {#onActivePathChanged} method is invoked when the user opens or closes a
37
+ # {Sketchup::ComponentInstance} or {Sketchup::Group} for editing.
38
+ #
39
+ # When the user opens an instance for editing the positions and transformations
40
+ # of the entities in the opened instance will be relative to global world
41
+ # coordinates instead of the local coordinates relative to their parent.
42
+ #
43
+ # See {Sketchup::Model#active_path} and {Sketchup::Model#edit_transform} for
44
+ # methods that report the current edit origin vs. the global origin, etc.
45
+ #
46
+ # By using this observer callback, you can keep track of the various nested
47
+ # transformations as your users double click to drill into and out of
48
+ # component edits.
49
+ #
50
+ # @example
51
+ # # As the user double clicks into component edits, show the "path" along
52
+ # # the model hierarchy they have followed to get here.
53
+ # def onActivePathChanged(model)
54
+ # puts "onActivePathChanged: #{model}"
55
+ # end
56
+ #
57
+ # @param [Sketchup::Model] model
58
+ #
59
+ # @return [nil]
60
+ #
61
+ # @see Sketchup::Model#active_path
62
+ #
63
+ # @see Sketchup::Model#edit_transform
64
+ def onActivePathChanged(model)
65
+ end
66
+
67
+ # The {#onAfterComponentSaveAs} method is invoked when the user context-clicks >
68
+ # Save As on a component instance. It is called just after the component is
69
+ # written to disk, so you can restore the component to some state before
70
+ # returning control to the user.
71
+ #
72
+ # @example
73
+ # def onAfterComponentSaveAs(model)
74
+ # puts "onAfterComponentSaveAs: #{model}"
75
+ # end
76
+ #
77
+ # @param [Sketchup::Model] model
78
+ #
79
+ # @return [nil]
80
+ #
81
+ # @see #onBeforeComponentSaveAs
82
+ #
83
+ # @version SketchUp 7.0
84
+ def onAfterComponentSaveAs(model)
85
+ end
86
+
87
+ # The {#onBeforeComponentSaveAs} method is invoked when the user
88
+ # context-clicks > Save As on a component instance. It is called just before
89
+ # the component is written to disk, so you can make changes within the handler
90
+ # and it will make it into the save.
91
+ #
92
+ # For example, you may decide that you want to add some attribute to every
93
+ # component that is saved out, but you do not want that attribute sticking
94
+ # around inside the current model. Within {#onBeforeComponentSaveAs} you could
95
+ # add the attribute, and within {#onAfterComponentSaveAs} you could delete that
96
+ # attribute.
97
+ #
98
+ # The callback is not sent the component that is to be saved, but the
99
+ # model's selection will contain it.
100
+ #
101
+ # @example
102
+ # def onBeforeComponentSaveAs(model)
103
+ # puts "onBeforeComponentSaveAs: #{model}"
104
+ # end
105
+ #
106
+ # @param [Sketchup::Model] model
107
+ #
108
+ # @return [nil]
109
+ #
110
+ # @version SketchUp 7.0
111
+ def onBeforeComponentSaveAs(model)
112
+ end
113
+
114
+ # The {#onDeleteModel} method is invoked when a model is deleted.
115
+ #
116
+ # @example
117
+ # def onDeleteModel(model)
118
+ # puts "onDeleteModel: #{model}"
119
+ # end
120
+ #
121
+ # @param [Sketchup::Model] model
122
+ #
123
+ # @return [nil]
124
+ #
125
+ # @version SketchUp 6.0
126
+ def onDeleteModel(model)
127
+ end
128
+
129
+ # The {#onEraseAll} method is invoked when everything in a model is erased.
130
+ #
131
+ # @example
132
+ # def onEraseAll(model)
133
+ # puts "onEraseAll: #{model}"
134
+ # end
135
+ #
136
+ # @param [Sketchup::Model] model
137
+ #
138
+ # @return [nil]
139
+ #
140
+ # @version SketchUp 6.0
141
+ def onEraseAll(model)
142
+ end
143
+
144
+ # The {#onExplode method} is invoked whenever a component anywhere in this
145
+ # model is exploded. This is an easier way to watch explode events vs.
146
+ # attaching an InstanceObserver to every instance in the model.
147
+ #
148
+ # Since the callback does not return what was exploded, one solution is to
149
+ # place a selection observer that keeps track of which entities whose
150
+ # explosion you are interested in are in the selection. Since SketchUp's
151
+ # user interface only provides a means of exploding the selection, this
152
+ # method is a reliable way to know what was just exploded.
153
+ #
154
+ # Another method would be to watch
155
+ # {Sketchup::ComponentDefinition.count_instances} to determine what just
156
+ # changed, as any components that were exploded will now be less an instance.
157
+ #
158
+ # @example
159
+ # def onExplode(model)
160
+ # puts "onExplode: #{model}"
161
+ # end
162
+ #
163
+ # @param [Sketchup::Model] model
164
+ #
165
+ # @return [nil]
166
+ #
167
+ # @version SketchUp 7.0
168
+ def onExplode(model)
169
+ end
170
+
171
+ # The {#onPidChanged} method is invoked when a {Sketchup::Entity#persistent_id persistent id} of
172
+ # an entity changes within the model.
173
+ #
174
+ # @example
175
+ # class PidObserver < Sketchup::ModelObserver
176
+ # def onPidChanged(model, old_pid, new_pid)
177
+ # entity = model.find_entity_by_persistent_id(new_pid)
178
+ # puts "Entity with new PID #{new_pid}: #{entity}"
179
+ # end
180
+ # end
181
+ #
182
+ # model = Sketchup.active_model
183
+ # model.add_observer(PidObserver.new)
184
+ #
185
+ # @note This callback is useful for tracking changes to entities that result in new PIDs, such as
186
+ # grouping or other modifications that result in new entities.
187
+ #
188
+ # @param [Sketchup::Model] model
189
+ #
190
+ # @param [Integer] old_pid
191
+ # The old persistent ID of the entity.
192
+ #
193
+ # @param [Integer] new_pid
194
+ # The new persistent ID of the entity.
195
+ #
196
+ # @return [nil]
197
+ #
198
+ # @see Sketchup::Model#find_entity_by_persistent_id
199
+ #
200
+ # @see Sketchup::Entity#persistent_id
201
+ #
202
+ # @version SketchUp 2017
203
+ def onPidChanged(model, old_pid, new_pid)
204
+ end
205
+
206
+ # The {#onPlaceComponent} method is invoked when a component is "placed" into
207
+ # the model, meaning it is dragged from the Component Browser.
208
+ #
209
+ # @example
210
+ # def onPlaceComponent(model)
211
+ # puts "onPlaceComponent: #{model}"
212
+ # end
213
+ #
214
+ # @param [Sketchup::Model] model
215
+ #
216
+ # @return [nil]
217
+ #
218
+ # @version SketchUp 7.0
219
+ def onPlaceComponent(model)
220
+ end
221
+
222
+ # The {#onPostSaveModel} method is invoked after a model has been saved to disk.
223
+ #
224
+ # @example
225
+ # def onPostSaveModel(model)
226
+ # puts "onPostSaveModel: #{model}"
227
+ # end
228
+ #
229
+ # @param [Sketchup::Model] model
230
+ #
231
+ # @return [nil]
232
+ #
233
+ # @version SketchUp 8.0
234
+ def onPostSaveModel(model)
235
+ end
236
+
237
+ # The {#onPreSaveModel} method is invoked before a model is saved to disk.
238
+ #
239
+ # @example
240
+ # def onPreSaveModel(model)
241
+ # puts "onPreSaveModel: #{model}"
242
+ # end
243
+ #
244
+ # @param [Sketchup::Model] model
245
+ #
246
+ # @return [nil]
247
+ #
248
+ # @version SketchUp 8.0
249
+ def onPreSaveModel(model)
250
+ end
251
+
252
+ # The {#onSaveModel} method is invoked after a model has been saved to disk.
253
+ #
254
+ # @example
255
+ # def onSaveModel(model)
256
+ # puts "onSaveModel: #{model}"
257
+ # end
258
+ #
259
+ # @param [Sketchup::Model] model
260
+ #
261
+ # @return [nil]
262
+ #
263
+ # @version SketchUp 6.0
264
+ def onSaveModel(model)
265
+ end
266
+
267
+ # The {#onTransactionAbort} method is invoked when a transaction is aborted.
268
+ #
269
+ # @example
270
+ # def onTransactionAbort(model)
271
+ # puts "onTransactionAbort: #{model}"
272
+ # end
273
+ #
274
+ # @param [Sketchup::Model] model
275
+ #
276
+ # @return [nil]
277
+ #
278
+ # @see Sketchup::Model#abort_operation
279
+ #
280
+ # @version SketchUp 6.0
281
+ def onTransactionAbort(model)
282
+ end
283
+
284
+ # The {#onTransactionCommit} method is invoked when a transaction is completed.
285
+ #
286
+ # @example
287
+ # def onTransactionCommit(model)
288
+ # puts "onTransactionCommit: #{model}"
289
+ # end
290
+ #
291
+ # @param [Sketchup::Model] model
292
+ #
293
+ # @return [nil]
294
+ #
295
+ # @see Sketchup::Model#commit_operation
296
+ #
297
+ # @version SketchUp 6.0
298
+ def onTransactionCommit(model)
299
+ end
300
+
301
+ # The {#onTransactionEmpty} method is invoked when a transaction
302
+ # (aka an undoable operation) starts and then is committed without anything
303
+ # being altered in between.
304
+ #
305
+ # @example
306
+ # def onTransactionEmpty(model)
307
+ # puts "onTransactionEmpty: #{model}"
308
+ # end
309
+ #
310
+ # @param [Sketchup::Model] model
311
+ #
312
+ # @return [nil]
313
+ #
314
+ # @see Sketchup::Model#start_operation
315
+ #
316
+ # @version SketchUp 6.0
317
+ def onTransactionEmpty(model)
318
+ end
319
+
320
+ # The {#onTransactionRedo} method is invoked when the user "redoes" a
321
+ # transaction (aka undo operation.) You can programmatically fire a redo by
322
+ # calling +Sketchup.sendAction("editRedo")+.
323
+ #
324
+ # @example
325
+ # def onTransactionRedo(model)
326
+ # puts "onTransactionRedo: #{model}"
327
+ # end
328
+ #
329
+ # @param [Sketchup::Model] model
330
+ #
331
+ # @return [nil]
332
+ #
333
+ # @version SketchUp 6.0
334
+ def onTransactionRedo(model)
335
+ end
336
+
337
+ # The {#onTransactionStart} method is invoked when a transaction
338
+ # (aka an undoable operation) starts.
339
+ #
340
+ # @example
341
+ # def onTransactionStart(model)
342
+ # puts "onTransactionStart: #{model}"
343
+ # end
344
+ #
345
+ # @param [Sketchup::Model] model
346
+ #
347
+ # @return [nil]
348
+ #
349
+ # @see Sketchup::Model#start_operation
350
+ #
351
+ # @version SketchUp 6.0
352
+ def onTransactionStart(model)
353
+ end
354
+
355
+ # The {#onTransactionUndo method} is invoked when the user "undoes" a
356
+ # transaction (aka undo operation.) You can programmatically fire an undo by
357
+ # calling +Sketchup.sendAction("editUndo")+.
358
+ #
359
+ # @example
360
+ # def onTransactionUndo(model)
361
+ # puts "onTransactionUndo: #{model}"
362
+ # end
363
+ #
364
+ # @param [Sketchup::Model] model
365
+ #
366
+ # @return [nil]
367
+ #
368
+ # @version SketchUp 6.0
369
+ def onTransactionUndo(model)
370
+ end
371
+
372
+ end