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