Module: MSPhysics::Settings

Defined in:
RubyExtension/MSPhysics/settings.rb

Overview

Since:

  • 1.0.0

Class Method Summary collapse

Class Method Details

.aabb_visible=(state) ⇒ Object

Show/hide bodies’ axes aligned bounding box (AABB).

Parameters:

  • state (Boolean)

Since:

  • 1.0.0



419
420
421
422
423
# File 'RubyExtension/MSPhysics/settings.rb', line 419

def aabb_visible=(state)
  @debug_aabb = state ? true : false
  sim = MSPhysics::Simulation.instance
  sim.aabb_visible = @debug_aabb if sim
end

.aabb_visible?Boolean

Determine whether bodies’ axes aligned bonding box (AABB) is visible.

Returns:

  • (Boolean)

Since:

  • 1.0.0



427
428
429
# File 'RubyExtension/MSPhysics/settings.rb', line 427

def aabb_visible?
  @debug_aabb
end

.animate_scenes_delayNumeric

Get the time to wait before starting to animate scenes.

Returns:

  • (Numeric)

    Time in seconds.

Since:

  • 1.0.0



135
136
137
138
139
# File 'RubyExtension/MSPhysics/settings.rb', line 135

def animate_scenes_delay
  default = MSPhysics::DEFAULT_SIMULATION_SETTINGS[:animate_scenes_delay]
  attr = Sketchup.active_model.get_attribute('MSPhysics', 'Animate Scenes Delay', default)
  return AMS.clamp(attr.to_f, 0, nil)
end

.animate_scenes_delay=(value) ⇒ Object

Set the time to wait before starting to animate scenes.

Parameters:

  • value (Numeric)

    Time in seconds.

Since:

  • 1.0.0



143
144
145
146
# File 'RubyExtension/MSPhysics/settings.rb', line 143

def animate_scenes_delay=(value)
  value = AMS.clamp(value.to_f, 0, nil)
  Sketchup.active_model.set_attribute('MSPhysics', 'Animate Scenes Delay', value)
end

.animate_scenes_reversed=(state) ⇒ Object

Reverse/normalize the animation of scenes.

Parameters:

  • state (Boolean)

Since:

  • 1.0.0



158
159
160
161
# File 'RubyExtension/MSPhysics/settings.rb', line 158

def animate_scenes_reversed=(state)
  state = state ? true : false
  Sketchup.active_model.set_attribute('MSPhysics', 'Animate Scenes Reversed', state)
end

.animate_scenes_reversed?Boolean

Determine whether the animation of scenes is reversed.

Returns:

  • (Boolean)

Since:

  • 1.0.0



150
151
152
153
154
# File 'RubyExtension/MSPhysics/settings.rb', line 150

def animate_scenes_reversed?
  default = MSPhysics::DEFAULT_SIMULATION_SETTINGS[:animate_scenes_reversed]
  attr = Sketchup.active_model.get_attribute('MSPhysics', 'Animate Scenes Reversed', default)
  return attr ? true : false
end

.animate_scenes_stateInteger

Get the state of scenes animation.

Returns:

  • (Integer)

    State:

    • 0 - off/stop

    • 1 - one way

    • 2 - repeat forth and back

    • 3 - loop around

Since:

  • 1.0.0



114
115
116
117
118
# File 'RubyExtension/MSPhysics/settings.rb', line 114

def animate_scenes_state
  default = MSPhysics::DEFAULT_SIMULATION_SETTINGS[:animate_scenes_state]
  attr = Sketchup.active_model.get_attribute('MSPhysics', 'Animate Scenes State', default)
  return AMS.clamp(attr.to_i, 0, 3)
end

.animate_scenes_state=(state) ⇒ Object

Set the state of scenes animation.

Parameters:

  • state (Integer)

    State:

    • 0 - off/stop

    • 1 - one way

    • 2 - repeat forth and back

    • 3 - loop around

Since:

  • 1.0.0



126
127
128
129
130
131
# File 'RubyExtension/MSPhysics/settings.rb', line 126

def animate_scenes_state=(state)
  state = AMS.clamp(state.to_i, 0, 3)
  Sketchup.active_model.set_attribute('MSPhysics', 'Animate Scenes State', state)
  sim = MSPhysics::Simulation.instance
  sim.animate_scenes(state) if sim
end

.axes_visible=(state) ⇒ Object

Show/hide bodies’ centre of mass axes.

Parameters:

  • state (Boolean)

Since:

  • 1.0.0



405
406
407
408
409
# File 'RubyExtension/MSPhysics/settings.rb', line 405

def axes_visible=(state)
  @debug_axes = state ? true : false
  sim = MSPhysics::Simulation.instance
  sim.axes_visible = @debug_axes if sim
end

.axes_visible?Boolean

Determine whether bodies’ centre of mass axes are visible.

Returns:

  • (Boolean)

Since:

  • 1.0.0



413
414
415
# File 'RubyExtension/MSPhysics/settings.rb', line 413

def axes_visible?
  @debug_axes
end

.bodies_visible=(state) ⇒ Object

Show/hide all bodies.

Parameters:

  • state (Boolean)

Since:

  • 1.0.0



461
462
463
464
465
466
# File 'RubyExtension/MSPhysics/settings.rb', line 461

def bodies_visible=(state)
  @debug_bodies = state ? true : false
  sim = MSPhysics::Simulation.instance
  sim.bodies_visible = @debug_bodies if sim
  @debug_bodies
end

.bodies_visible?Boolean

Determine whether bodies are visible.

Returns:

  • (Boolean)

Since:

  • 1.0.0



470
471
472
# File 'RubyExtension/MSPhysics/settings.rb', line 470

def bodies_visible?
  @debug_bodies
end

.collision_wireframe_visible=(state) ⇒ Object

Show/hide bodies’ collision wireframe.

Parameters:

  • state (Boolean)

Since:

  • 1.0.0



391
392
393
394
395
# File 'RubyExtension/MSPhysics/settings.rb', line 391

def collision_wireframe_visible=(state)
  @debug_collision = state ? true : false
  sim = MSPhysics::Simulation.instance
  sim.collision_wireframe_visible = @debug_collision if sim
end

.collision_wireframe_visible?Boolean

Determine whether bodies’ collision wireframe is visible.

Returns:

  • (Boolean)

Since:

  • 1.0.0



399
400
401
# File 'RubyExtension/MSPhysics/settings.rb', line 399

def collision_wireframe_visible?
  @debug_collision
end

.contact_forces_visible=(state) ⇒ Object

Show/hide bodies’ contact forces.

Parameters:

  • state (Boolean)

Since:

  • 1.0.0



447
448
449
450
451
# File 'RubyExtension/MSPhysics/settings.rb', line 447

def contact_forces_visible=(state)
  @debug_contact_forces = state ? true : false
  sim = MSPhysics::Simulation.instance
  sim.contact_forces_visible = @debug_contact_forces if sim
end

.contact_forces_visible?Boolean

Determine whether bodies contact forces are visible.

Returns:

  • (Boolean)

Since:

  • 1.0.0



455
456
457
# File 'RubyExtension/MSPhysics/settings.rb', line 455

def contact_forces_visible?
  @debug_contact_forces
end

.contact_points_visible=(state) ⇒ Object

Show/hide bodies’ contact points.

Parameters:

  • state (Boolean)

Since:

  • 1.0.0



433
434
435
436
437
# File 'RubyExtension/MSPhysics/settings.rb', line 433

def contact_points_visible=(state)
  @debug_contact_points = state ? true : false
  sim = MSPhysics::Simulation.instance
  sim.contact_points_visible = @debug_contact_points if sim
end

.contact_points_visible?Boolean

Determine whether bodies’ contact points are visible.

Returns:

  • (Boolean)

Since:

  • 1.0.0



441
442
443
# File 'RubyExtension/MSPhysics/settings.rb', line 441

def contact_points_visible?
  @debug_contact_points
end

.continuous_collision_check_enabled=(state) ⇒ Object

Enable/disable continuous collision check.

Parameters:

  • state (Boolean)

Since:

  • 1.0.0



173
174
175
176
177
178
# File 'RubyExtension/MSPhysics/settings.rb', line 173

def continuous_collision_check_enabled=(state)
  state = state ? true : false
  Sketchup.active_model.set_attribute('MSPhysics', 'Continuous Collision Mode', state)
  sim = MSPhysics::Simulation.instance
  sim.continuous_collision_check_enabled = state if sim
end

.continuous_collision_check_enabled?Boolean

Determine whether continuous collision check is enabled.

Returns:

  • (Boolean)

Since:

  • 1.0.0



165
166
167
168
169
# File 'RubyExtension/MSPhysics/settings.rb', line 165

def continuous_collision_check_enabled?
  default = MSPhysics::DEFAULT_SIMULATION_SETTINGS[:continuous_collision_check]
  attr = Sketchup.active_model.get_attribute('MSPhysics', 'Continuous Collision Mode', default)
  return attr ? true : false
end

.full_screen_mode_enabled=(state) ⇒ Object

Enable/disable fullscreen mode.

Parameters:

  • state (Boolean)

Since:

  • 1.0.0



190
191
192
193
194
195
# File 'RubyExtension/MSPhysics/settings.rb', line 190

def full_screen_mode_enabled=(state)
  state = state ? true : false
  Sketchup.active_model.set_attribute('MSPhysics', 'Fullscreen Mode', state)
  sim = MSPhysics::Simulation.instance
  sim.view_full_screen(state) if sim
end

.full_screen_mode_enabled?Boolean

Determine whether fullscreen mode is enabled.

Returns:

  • (Boolean)

Since:

  • 1.0.0



182
183
184
185
186
# File 'RubyExtension/MSPhysics/settings.rb', line 182

def full_screen_mode_enabled?
  default = MSPhysics::DEFAULT_SIMULATION_SETTINGS[:full_screen_mode]
  attr = Sketchup.active_model.get_attribute('MSPhysics', 'Fullscreen Mode', default)
  return attr ? true : false
end

.game_mode_enabled=(state) ⇒ Object

Enable/disable game mode.

Parameters:

  • state (Boolean)

Since:

  • 1.0.0



237
238
239
240
241
242
# File 'RubyExtension/MSPhysics/settings.rb', line 237

def game_mode_enabled=(state)
  state = state ? true : false
  Sketchup.active_model.set_attribute('MSPhysics', 'Game Mode', state)
  sim = MSPhysics::Simulation.instance
  sim.mode = (state ? 1 : 0) if sim
end

.game_mode_enabled?Boolean

Determine whether game mode is enabled.

Returns:

  • (Boolean)

Since:

  • 1.0.0



229
230
231
232
233
# File 'RubyExtension/MSPhysics/settings.rb', line 229

def game_mode_enabled?
  default = MSPhysics::DEFAULT_SIMULATION_SETTINGS[:game_mode]
  attr = Sketchup.active_model.get_attribute('MSPhysics', 'Game Mode', default)
  return attr ? true : false
end

.gravityNumeric

Get simulation gravitational acceleration along Z-axis, in meters per second per second (m/s/s).

Returns:

  • (Numeric)

Since:

  • 1.0.0



356
357
358
359
360
# File 'RubyExtension/MSPhysics/settings.rb', line 356

def gravity
  default = MSPhysics::DEFAULT_SIMULATION_SETTINGS[:gravity]
  attr = Sketchup.active_model.get_attribute('MSPhysics', 'Gravity', default)
  return attr.to_f
end

.gravity=(acceleration) ⇒ Object

Set simulation gravitational acceleration along Z-axis, in meters per second per second (m/s/s).

Parameters:

  • acceleration (Numeric)

Since:

  • 1.0.0



365
366
367
368
369
370
# File 'RubyExtension/MSPhysics/settings.rb', line 365

def gravity=(acceleration)
  acceleration = acceleration.to_f
  Sketchup.active_model.set_attribute('MSPhysics', 'Gravity', acceleration)
  sim = MSPhysics::Simulation.instance
  sim.world.set_gravity(0, 0, acceleration) if sim
end

.hide_joint_layer_enabled=(state) ⇒ Object

Enable/disable the hide-joint-layer option.

Parameters:

  • state (Boolean)

Since:

  • 1.0.0



254
255
256
257
258
259
260
261
# File 'RubyExtension/MSPhysics/settings.rb', line 254

def hide_joint_layer_enabled=(state)
  state = state ? true : false
  Sketchup.active_model.set_attribute('MSPhysics', 'Hide Joint Layer', state)
  if MSPhysics::Simulation.instance
    layer = Sketchup.active_model.layers['MSPhysics Joints']
    layer.visible = !state if layer && layer.visible? == state
  end
end

.hide_joint_layer_enabled?Boolean

Determine whether the hide-joint-layer option is enabled.

Returns:

  • (Boolean)

Since:

  • 1.0.0



246
247
248
249
250
# File 'RubyExtension/MSPhysics/settings.rb', line 246

def hide_joint_layer_enabled?
  default = MSPhysics::DEFAULT_SIMULATION_SETTINGS[:hide_joint_layer]
  attr = Sketchup.active_model.get_attribute('MSPhysics', 'Hide Joint Layer', default)
  return attr ? true : false
end

.ignore_hidden_instances=(state) ⇒ Object

Enable/disable fancy operation.

Parameters:

  • state (Boolean)

Since:

  • 1.0.0



207
208
209
210
# File 'RubyExtension/MSPhysics/settings.rb', line 207

def ignore_hidden_instances=(state)
  state = state ? true : false
  Sketchup.active_model.set_attribute('MSPhysics', 'Ignore Hidden Instances', state)
end

.ignore_hidden_instances?Boolean

Determine whether hidden instances are ignored.

Returns:

  • (Boolean)

Since:

  • 1.0.0



199
200
201
202
203
# File 'RubyExtension/MSPhysics/settings.rb', line 199

def ignore_hidden_instances?
  default = MSPhysics::DEFAULT_SIMULATION_SETTINGS[:ignore_hidden_instances]
  attr = Sketchup.active_model.get_attribute('MSPhysics', 'Ignore Hidden Instances', default)
  return attr ? true : false
end

.joint_algorithmInteger

Get joint solver model.

Returns:

  • (Integer)

    0 - Accurate; 1 - Don’t Use; 2 - Fast.

Since:

  • 1.0.0



299
300
301
302
303
# File 'RubyExtension/MSPhysics/settings.rb', line 299

def joint_algorithm
  default = MSPhysics::DEFAULT_SIMULATION_SETTINGS[:joint_algorithm]
  attr = Sketchup.active_model.get_attribute('MSPhysics', 'Joint Algorithm', default)
  return AMS.clamp(attr.to_i, 0, 2)
end

.joint_algorithm=(model) ⇒ Object

Note:

Changing this property won’t have an effect until simulation is restarted.

Set joint solver model.

Parameters:

  • model (Integer)

    Joint solver model:

    • 0 - Accurate: Slow but robust

    • 1 - Don’t Use

    • 2 - Fast: Fast but flexible

Since:

  • 1.0.0



312
313
314
315
# File 'RubyExtension/MSPhysics/settings.rb', line 312

def joint_algorithm=(model)
  model = AMS.clamp(model.to_i, 0, 2)
  Sketchup.active_model.set_attribute('MSPhysics', 'Joint Algorithm', model)
end

.key_nav_atimeNumeric

Get the time to accelerate, in seconds, from zero to the desired velocity or omega.

Returns:

  • (Numeric)

Since:

  • 1.0.0



93
94
95
96
97
98
99
# File 'RubyExtension/MSPhysics/settings.rb', line 93

def key_nav_atime
  if @settings.has_key?(:key_nav_atime)
    @settings[:key_nav_atime]
  else
    MSPhysics::DEFAULT_SIMULATION_SETTINGS[:key_nav_atime]
  end
end

.key_nav_atime=(value) ⇒ Object

Set the time to accelerate, in seconds, from zero to the desired velocity or omega.

Parameters:

  • value (Numeric)

Since:

  • 1.0.0



104
105
106
# File 'RubyExtension/MSPhysics/settings.rb', line 104

def key_nav_atime=(value)
  @settings[:key_nav_atime] = AMS.clamp(value.to_f, 0.0, nil)
end

.key_nav_omegaNumeric

Get the maximum omega of keyboard camera navigation in rad/s.

Returns:

  • (Numeric)

Since:

  • 1.0.0



76
77
78
79
80
81
82
# File 'RubyExtension/MSPhysics/settings.rb', line 76

def key_nav_omega
  if @settings.has_key?(:key_nav_omega)
    @settings[:key_nav_omega]
  else
    MSPhysics::DEFAULT_SIMULATION_SETTINGS[:key_nav_omega]
  end
end

.key_nav_omega=(value) ⇒ Object

Set the maximum omega of keyboard camera navigation in rad/s.

Parameters:

  • value (Numeric)

Since:

  • 1.0.0



86
87
88
# File 'RubyExtension/MSPhysics/settings.rb', line 86

def key_nav_omega=(value)
  @settings[:key_nav_omega] = AMS.clamp(value.to_f, 0.01, nil)
end

.key_nav_stateInteger

Get the state of keyboard navigation.

Returns:

  • (Integer)

    State:

    • 0 - off/stop

    • 1 - normal

    • 2 - upright

Since:

  • 1.0.0



42
43
44
45
46
# File 'RubyExtension/MSPhysics/settings.rb', line 42

def key_nav_state
  default = MSPhysics::DEFAULT_SIMULATION_SETTINGS[:key_nav_state]
  attr = Sketchup.active_model.get_attribute('MSPhysics', 'Keyboard Nav State', default)
  return AMS.clamp(attr.to_i, 0, 2)
end

.key_nav_state=(state) ⇒ Object

Set the state of keyboard navigation.

Parameters:

  • state (Integer)

    State:

    • 0 - off/stop

    • 1 - normal

    • 2 - upright

Since:

  • 1.0.0



53
54
55
56
# File 'RubyExtension/MSPhysics/settings.rb', line 53

def key_nav_state=(state)
  state = AMS.clamp(state.to_i, 0, 2)
  Sketchup.active_model.set_attribute('MSPhysics', 'Keyboard Nav State', state)
end

.key_nav_velocityNumeric

Get the maximum velocity of keyboard camera navigation in m/s.

Returns:

  • (Numeric)

Since:

  • 1.0.0



60
61
62
63
64
65
66
# File 'RubyExtension/MSPhysics/settings.rb', line 60

def key_nav_velocity
  if @settings.has_key?(:key_nav_velocity)
    @settings[:key_nav_velocity]
  else
    MSPhysics::DEFAULT_SIMULATION_SETTINGS[:key_nav_velocity]
  end
end

.key_nav_velocity=(value) ⇒ Object

Set the maximum velocity of keyboard camera navigation in m/s.

Parameters:

  • value (Numeric)

Since:

  • 1.0.0



70
71
72
# File 'RubyExtension/MSPhysics/settings.rb', line 70

def key_nav_velocity=(value)
  @settings[:key_nav_velocity] = AMS.clamp(value.to_f, 0.01, nil)
end

.keyboard_navigation_enabled=(state) ⇒ Object

Enable/disable the navigation of camera with keyboard.

Parameters:

  • state (Boolean)

Since:

  • 1.0.0



222
223
224
225
# File 'RubyExtension/MSPhysics/settings.rb', line 222

def keyboard_navigation_enabled=(state)
  state = state ? true : false
  Sketchup.active_model.set_attribute('MSPhysics', 'Keyboard Navigation', state)
end

.keyboard_navigation_enabled?Boolean

Determine whether the navigation of camera with keyboard is enabled.

Returns:

  • (Boolean)

Since:

  • 1.0.0



214
215
216
217
218
# File 'RubyExtension/MSPhysics/settings.rb', line 214

def keyboard_navigation_enabled?
  default = MSPhysics::DEFAULT_SIMULATION_SETTINGS[:keyboard_navigation]
  attr = Sketchup.active_model.get_attribute('MSPhysics', 'Keyboard Navigation', default)
  return attr ? true : false
end

.load_optionsObject

Load settings from registry

Since:

  • 1.0.0



27
28
29
30
31
32
33
34
35
# File 'RubyExtension/MSPhysics/settings.rb', line 27

def load_options
  v = Sketchup.read_default('MSPhysics', 'Settings', '{}')
  begin
    res = eval(v)
    @settings.merge!(res) if res.is_a?(Hash)
  rescue Exception => e
    # Do nothing; use default options.
  end
end

.material_thicknessNumeric

Get simulation material thickness in meters.

Returns:

  • (Numeric)

    A value between 0 and 1/32.

Since:

  • 1.0.0



374
375
376
377
378
# File 'RubyExtension/MSPhysics/settings.rb', line 374

def material_thickness
  default = MSPhysics::DEFAULT_SIMULATION_SETTINGS[:material_thickness]
  attr = Sketchup.active_model.get_attribute('MSPhysics', 'Material Thickness', default)
  return AMS.clamp(attr.to_f, 0, 1/32.0)
end

.material_thickness=(thickness) ⇒ Object

Set simulation material thickness in meters.

Parameters:

  • thickness (Numeric)

    A value between 0 and 1/32.

Since:

  • 1.0.0



382
383
384
385
386
387
# File 'RubyExtension/MSPhysics/settings.rb', line 382

def material_thickness=(thickness)
  thickness = AMS.clamp(thickness.to_f, 0, 1/32.0)
  Sketchup.active_model.set_attribute('MSPhysics', 'Material Thickness', thickness)
  sim = MSPhysics::Simulation.instance
  sim.world.material_thickness = thickness if sim
end

.save_optionsObject

Save settings to registry

Since:

  • 1.0.0



22
23
24
# File 'RubyExtension/MSPhysics/settings.rb', line 22

def save_options
  Sketchup.write_default('MSPhysics', 'Settings', @settings.inspect.inspect[1..-2])
end

.solver_modelInteger

Get simulation solver model.

Returns:

  • (Integer)

    Number of passes, a value between 1 and 256.

Since:

  • 1.0.0



282
283
284
285
286
# File 'RubyExtension/MSPhysics/settings.rb', line 282

def solver_model
  default = MSPhysics::DEFAULT_SIMULATION_SETTINGS[:solver_model]
  attr = Sketchup.active_model.get_attribute('MSPhysics', 'Solver Model', default)
  return AMS.clamp(attr.to_i, 1, 256)
end

.solver_model=(model) ⇒ Object

Set simulation solver model.

Parameters:

  • model (Integer)

    Number of passes, a value between 1 and 256.

Since:

  • 1.0.0



290
291
292
293
294
295
# File 'RubyExtension/MSPhysics/settings.rb', line 290

def solver_model=(model)
  model = AMS.clamp(model.to_i, 1, 256)
  Sketchup.active_model.set_attribute('MSPhysics', 'Solver Model', model)
  sim = MSPhysics::Simulation.instance
  sim.world.solver_model = model if sim
end

.undo_on_end_enabled=(state) ⇒ Object

Enable/disable the undo-on-end option.

Parameters:

  • state (Boolean)

Since:

  • 1.0.0



273
274
275
276
277
278
# File 'RubyExtension/MSPhysics/settings.rb', line 273

def undo_on_end_enabled=(state)
  state = state ? true : false
  Sketchup.active_model.set_attribute('MSPhysics', 'Undo on End', state)
  sim = MSPhysics::Simulation.instance
  sim.undo_on_reset = state if sim
end

.undo_on_end_enabled?Boolean

Determine whether the undo-on-end option is enabled.

Returns:

  • (Boolean)

Since:

  • 1.0.0



265
266
267
268
269
# File 'RubyExtension/MSPhysics/settings.rb', line 265

def undo_on_end_enabled?
  default = MSPhysics::DEFAULT_SIMULATION_SETTINGS[:undo_on_end]
  attr = Sketchup.active_model.get_attribute('MSPhysics', 'Undo on End', default)
  return attr ? true : false
end

.update_rateInteger

Get simulation update rate, the number of times to update newton world per frame.

Returns:

  • (Integer)

    A value between 1 and 100.

Since:

  • 1.0.0



337
338
339
340
341
# File 'RubyExtension/MSPhysics/settings.rb', line 337

def update_rate
  default = MSPhysics::DEFAULT_SIMULATION_SETTINGS[:update_rate]
  attr = Sketchup.active_model.get_attribute('MSPhysics', 'Update Rate', default)
  return AMS.clamp(attr.to_i, 1, 100)
end

.update_rate=(rate) ⇒ Object

Set simulation update rate, the number of times to update newton world per frame.

Parameters:

  • rate (Integer)

    A value between 1 and 100.

Since:

  • 1.0.0



346
347
348
349
350
351
# File 'RubyExtension/MSPhysics/settings.rb', line 346

def update_rate=(rate)
  rate = AMS.clamp(rate.to_i, 1, 100)
  Sketchup.active_model.set_attribute('MSPhysics', 'Update Rate', rate)
  sim = MSPhysics::Simulation.instance
  sim.update_rate = rate if sim
end

.update_timestepNumeric

Get simulation update timestep in seconds.

Returns:

  • (Numeric)

    A value between 1/1200 and 1/30.

Since:

  • 1.0.0



319
320
321
322
323
# File 'RubyExtension/MSPhysics/settings.rb', line 319

def update_timestep
  default = MSPhysics::DEFAULT_SIMULATION_SETTINGS[:update_timestep]
  attr = Sketchup.active_model.get_attribute('MSPhysics', 'Update Timestep', default)
  return AMS.clamp(attr.to_f, 1/1200.0, 1/30.0)
end

.update_timestep=(timestep) ⇒ Object

Set simulation update timestep in seconds.

Parameters:

  • timestep (Numeric)

    A value between 1/1200 and 1/30.

Since:

  • 1.0.0



327
328
329
330
331
332
# File 'RubyExtension/MSPhysics/settings.rb', line 327

def update_timestep=(timestep)
  timestep = AMS.clamp(timestep.to_f, 1/1200.0, 1/30.0)
  Sketchup.active_model.set_attribute('MSPhysics', 'Update Timestep', timestep)
  sim = MSPhysics::Simulation.instance
  sim.update_timestep = timestep if sim
end