Module: AMS::Sketchup

Defined in:
sketchup.rb

Class Method Summary (collapse)

Class Method Details

+ (Boolean) activate Also known as: bring_to_top

Set main window active.

Returns:

  • (Boolean)

    success

Since:

  • 2.0.0



190
191
192
# File 'sketchup.rb', line 190

def activate
  AMS::C.bring_window_to_top(AMS::C.get_main_window())
end

+ (Boolean) add_observer(object)

Note:

An observer can be a class, module, or a class instance. Your observer will work as long as the callback methods are public.

Note:

Your observer is not supposed to contain every callback method from the observers list. You may include/elude those as you wish.

Note:

A unique extension swp or swo is added in front of each observer method. SWP stands for Sketchup Window Procedure, and SWO stands for Sketchup Window Observer. Both SWP and SWO events are capable to monitor window messages, but SWP events are also capable to make decisions to the message, whether or not the message should interact with SketchUp window. If the return value for the SWP callback method is 1, then the message associated with the event will not interact with SketchUp window. For example, returning 1 in the swp_on_key_down event will prevent the key from interacting with SketchUp window, which means any shortcut associated with such key will not be triggered. SWP events may come handy for extensions that want more control over SketchUp.

Add object to the observers list.

Examples:

Adding observer from class instance:

class MySketchupObserver
  def swo_on_switch_full_screen(state)
    puts 'Main window set full screen!' if state
  end
end # module MySketchupObserver
AMS::Sketchup.add_observer(MySketchupObserver.new)

Adding observer from module:

module MySketchupObserver
  def self.swo_on_switch_full_screen(state)
    puts 'Main window set full screen!' if state
  end
end # module MySketchupObserver
AMS::Sketchup.add_observer(MySketchupObserver)

Another way to add observer from module:

module MySketchupObserver
  class << self
    def swo_on_switch_full_screen(state)
      puts 'Main window set full screen!' if state
    end
  end # class << self
end # module MySketchupObserver
AMS::Sketchup.add_observer(MySketchupObserver)

You may also add observer by inheriting, but it's not required:

class MySketchupObserver < AMS::SketchupObserver
  def swo_on_switch_full_screen(state)
    puts 'Main window set full screen!' if state
  end
end # module MySketchupObserver
AMS::Sketchup.add_observer(MySketchupObserver.new)

Parameters:

  • object (Object)

Returns:

  • (Boolean)

    success

See Also:

Since:

  • 2.0.0



704
705
706
# File 'sketchup.rb', line 704

def add_observer(object)
  AMS::C.add_observer(object)
end

+ (void) close

Note:

This behaves the same as clicking the 'X' button.

This method returns an undefined value.

Close current SketchUp application.

Since:

  • 2.0.0



650
651
652
# File 'sketchup.rb', line 650

def close
  AMS::C.close_window(AMS::C.get_main_window())
end

+ (Fixnum) close_dialogs

Note:

Ignored windows won't be included in this operation.

Close all dialogs.

Returns:

  • (Fixnum)

    number of dialogs closed.

Since:

  • 2.0.0



475
476
477
478
479
480
481
482
483
484
485
# File 'sketchup.rb', line 475

def close_dialogs
  count = 0
  (@dialogs + AMS::C.get_visible_dialogs()).each { |handle|
    next unless AMS::C.is_window?(handle)
    next if @dialogs_to_ignore.include?(handle)
    AMS::C.close_window(handle)
    count += 1
  }
  @dialogs.clear
  count
end

+ (Fixnum) close_toolbars

Close all floating toolbars.

Returns:

  • (Fixnum)

    number of floating toolbars closed.

Since:

  • 2.0.0



542
543
544
545
546
547
548
549
550
551
# File 'sketchup.rb', line 542

def close_toolbars
  count = 0
  (@toolbars + AMS::C.get_visible_toolbars()).each { |handle|
    next unless AMS::C.is_window?(handle)
    AMS::C.close_window(handle)
    count += 1
  }
  @toolbars.clear
  count
end

+ (Fixnum?) find_window_by_caption(caption)

Note:

This function will irritate through the windows of the current SketchUp process only. All windows belong to a different process or a different SketchUp application will not be searched.

Find a handle to the window with the specified caption.

Returns:

  • (Fixnum, nil)

    A handle to the window if successful.

Since:

  • 2.0.0



575
576
577
# File 'sketchup.rb', line 575

def find_window_by_caption(caption)
  AMS::C.find_window_by_caption(caption)
end

+ (Array<Fixnum>) get_active_dialogs

Note:

Ignored dialogs are included in the list.

Get all used pop-up windows of the current SketchUp application.

Returns:

  • (Array<Fixnum>)

    An array of window handles.

Since:

  • 2.0.0



591
592
593
# File 'sketchup.rb', line 591

def get_active_dialogs
  (AMS::C.get_visible_dialogs() + @dialogs - @dialogs_to_ignore).uniq
end

+ (Array<Fixnum>) get_active_toolbars

Get all used floating toolbars.

Returns:

  • (Array<Fixnum>)

    An array of window handles.

Since:

  • 2.0.0



613
614
615
# File 'sketchup.rb', line 613

def get_active_toolbars
  (AMS::C.get_visible_toolbars() + @toolbars).uniq
end

+ (String) get_caption

Get main window title text.

Returns:

  • (String)

Since:

  • 2.0.0



627
628
629
# File 'sketchup.rb', line 627

def get_caption
  AMS::C.get_window_text(AMS::C.get_main_window()).unpack('C*').pack('U*')
end

+ (Array<Fixnum>) get_dialogs

Note:

Ignored dialogs are included in the list.

Get all pop-up windows of the current SketchUp application.

Returns:

  • (Array<Fixnum>)

    An array of window handles.

Since:

  • 2.0.0



583
584
585
# File 'sketchup.rb', line 583

def get_dialogs
  AMS::C.get_dialogs() - @dialogs_to_ignore
end

+ (String) get_executable_path

Get full path to the current SketchUp executable.

Returns:

  • (String)

Since:

  • 2.0.0



39
40
41
42
43
# File 'sketchup.rb', line 39

def get_executable_path
  path = AMS::C.get_executable_path().unpack('C*').pack('U*')
  path.gsub!(/\\/, '/')
  path
end

+ (Fixnum) get_main_window

Get handle to the main window of the current SketchUp application.

Returns:

  • (Fixnum)

Since:

  • 2.0.0



77
78
79
# File 'sketchup.rb', line 77

def get_main_window
  AMS::C.get_main_window
end

+ (Fixnum) get_menu_bar

Get handle to the menu bar of the main window.

Returns:

  • (Fixnum)

Since:

  • 2.0.0



84
85
86
# File 'sketchup.rb', line 84

def get_menu_bar
  AMS::C.get_main_window_menu_bar
end

+ (Fixnum) get_module_handle

Get module handle to the current SketchUp application.

Returns:

  • (Fixnum)

Since:

  • 2.0.0



32
33
34
# File 'sketchup.rb', line 32

def get_module_handle
  AMS::C.get_module_handle
end

+ (Fixnum) get_process_id

Get process id of the current SketchUp application.

Returns:

  • (Fixnum)

Since:

  • 2.0.0



63
64
65
# File 'sketchup.rb', line 63

def get_process_id
  AMS::C.get_process_id
end

+ (String) get_registry_path

Get registry path of the current SketchUp application.

Returns:

  • (String)

Since:

  • 2.0.0



48
49
50
51
52
53
54
55
56
57
58
# File 'sketchup.rb', line 48

def get_registry_path
  version = Sketchup.version.to_i
  case version
  when 5
   "HKEY_CURRENT_USER/Software/Google/Google SketchUp5/"
  when 6..8
    "HKEY_CURRENT_USER/Software/Google/SketchUp#{version}/"
  else
    "HKEY_CURRENT_USER/Software/SketchUp/SketchUp 20#{version}/"
  end
end

+ (Fixnum) get_scenes_bar

Get handle to the scenes bar of the main window.

Returns:

  • (Fixnum)

Since:

  • 2.0.0



105
106
107
# File 'sketchup.rb', line 105

def get_scenes_bar
  AMS::C.get_scenes_bar
end

+ (Fixnum) get_status_bar

Get handle to the status bar of the main window.

Returns:

  • (Fixnum)

Since:

  • 2.0.0



98
99
100
# File 'sketchup.rb', line 98

def get_status_bar
  AMS::C.get_status_bar
end

+ (Fixnum) get_thread_id

Get thread id of the current SketchUp application.

Returns:

  • (Fixnum)

Since:

  • 2.0.0



70
71
72
# File 'sketchup.rb', line 70

def get_thread_id
  AMS::C.get_thread_id
end

+ (Array<Fixnum>) get_toolbar_containers

Get handle to the four toolbar containers of the main window.

Returns:

  • (Array<Fixnum>)

    [top toolbar, bottom toolbar, left toolbar, right toolbar]

Since:

  • 2.0.0



112
113
114
# File 'sketchup.rb', line 112

def get_toolbar_containers
  AMS::C.get_control_bars
end

+ (Array<Fixnum>) get_toolbars

Get all floating toolbars of the current SketchUp application.

Returns:

  • (Array<Fixnum>)

    An array of window handles.

Since:

  • 2.0.0



606
607
608
# File 'sketchup.rb', line 606

def get_toolbars
  AMS::C.get_toolbars()
end

+ (Fixnum) get_viewport

Get handle to the view window of the main window.

Returns:

  • (Fixnum)

Since:

  • 2.0.0



91
92
93
# File 'sketchup.rb', line 91

def get_viewport
  AMS::C.get_viewport
end

+ (Array<Fixnum>) get_viewport_center

Get viewport center in screen coordinates.

Returns:

  • (Array<Fixnum>)

    [x,y]

Since:

  • 2.0.0



406
407
408
409
# File 'sketchup.rb', line 406

def get_viewport_center
  r = AMS::C.get_viewport_rect()
  [((r[2] - r[0])*0.5).round, ((r[3] - r[1])*0.5).round]
end

+ (Array<Fixnum>) get_viewport_origin

Get upper-left corner of the view window in screen coordinates.

Returns:

  • (Array<Fixnum>)

    [x,y]

Since:

  • 2.0.0



390
391
392
# File 'sketchup.rb', line 390

def get_viewport_origin
  AMS::C.get_viewport_rect()[0,2]
end

+ (Array<Fixnum>) get_viewport_rect

Get upper-left and lower-right corners of the view window in screen coordinates, relatives to the upper-left corner of the screen.

Returns:

  • (Array<Fixnum>)

    [x1,y1, x2,y2]

Since:

  • 2.0.0



383
384
385
# File 'sketchup.rb', line 383

def get_viewport_rect
  AMS::C.get_viewport_rect()
end

+ (Array<Fixnum>) get_viewport_size

Note:

This is same as view.vp_width and view.vp_height.

Get width and height of the view window.

Returns:

  • (Array<Fixnum>)

    [width, height]

Since:

  • 2.0.0



398
399
400
401
# File 'sketchup.rb', line 398

def get_viewport_size
  r = AMS::C.get_viewport_rect()
  [ r[2] - r[0], r[3] - r[1] ]
end

+ (Array<Fixnum>) get_visible_dialogs

Note:

Ignored dialogs are included in the list.

Get all visible pop-up windows of the current SketchUp application.

Returns:

  • (Array<Fixnum>)

    An array of window handles.

Since:

  • 2.0.0



599
600
601
# File 'sketchup.rb', line 599

def get_visible_dialogs
  AMS::C.get_visible_dialogs() - @dialogs_to_ignore
end

+ (Array<Fixnum>) get_visible_toolbars

Get all visible floating toolbars of the current SketchUp application.

Returns:

  • (Array<Fixnum>)

    An array of window handles.

Since:

  • 2.0.0



620
621
622
# File 'sketchup.rb', line 620

def get_visible_toolbars
  AMS::C.get_visible_toolbars()
end

+ (Boolean) ignore_dialog(handle)

Elude dialog from the show_dialogs and close_dialogs operations.

Parameters:

  • handle (Fixnum)

    A handle to the window.

Returns:

  • (Boolean)

    success

Since:

  • 2.0.0



501
502
503
504
505
506
507
508
509
510
511
512
513
# File 'sketchup.rb', line 501

def ignore_dialog(handle)
  # Verify given handle is not already in the ignore list.
  return false if @dialogs_to_ignore.include?(handle)
  # Verify given handle is a window.
  return false unless AMS::C.is_window?(handle)
  # Verify given handle is part of the current SketchUp process.
  return false if AMS::C.get_window_process_id(handle) != AMS::C.get_process_id()
  # Verify given handle is a pop-up window.
  return false if AMS::C.get_window_class_name(handle) != '#32770'
  # Add handle to the ignore list if it passed all the tests.
  @dialogs_to_ignore << handle
  true
end

+ (Boolean) include_dialog(handle)

Note:

By default, all dialogs are included in the show/hide/close dialogs operation. This method is used to remove dialog from the ignore list.

Include dialog in the show_dialogs and close_dialogs operations.

Parameters:

  • handle (Fixnum)

    A handle to the window.

Returns:

  • (Boolean)

    success

Since:

  • 2.0.0



493
494
495
# File 'sketchup.rb', line 493

def include_dialog(handle)
  @dialogs_to_ignore.delete(handle) ? true : false
end

+ (Boolean) is_32bit?

Determine whether current SketchUp application is 32bit.

Returns:

  • (Boolean)

Since:

  • 2.0.0



18
19
20
# File 'sketchup.rb', line 18

def is_32bit?
  !@is_64bit
end

+ (Boolean) is_64bit?

Determine whether current SketchUp application is 64bit.

Returns:

  • (Boolean)

Since:

  • 2.0.0



25
26
27
# File 'sketchup.rb', line 25

def is_64bit?
  @is_64bit
end

+ (Boolean) is_active?

Determine whether the current active window belongs to the current SketchUp application.

Returns:

  • (Boolean)

Since:

  • 2.0.0



564
565
566
567
# File 'sketchup.rb', line 564

def is_active?
  handle = AMS::C.get_active_window()
  AMS::C.get_window_process_id(handle) == AMS::C.get_process_id()
end

+ (Boolean) is_full_screen?

Determine whether main window is full screen.

Returns:

  • (Boolean)

Since:

  • 2.0.0



129
130
131
# File 'sketchup.rb', line 129

def is_full_screen?
  AMS::C.is_main_window_full_screen?
end

+ (Boolean) is_main_window_active?

Determine whether SketchUp main window is active.

Returns:

  • (Boolean)

Since:

  • 2.0.0



556
557
558
# File 'sketchup.rb', line 556

def is_main_window_active?
  AMS::C.get_active_window() == AMS::C.get_main_window()
end

+ (Boolean) is_maximized?

Determine whether main window is maximized.

Returns:

  • (Boolean)

Since:

  • 2.0.0



146
147
148
149
# File 'sketchup.rb', line 146

def is_maximized?
  return false if AMS::C.is_main_window_full_screen?
  AMS::C.is_window_maximized?(AMS::C.get_main_window())
end

+ (Boolean) is_menu_bar_set?

Determine whether menu bar is set.

Returns:

  • (Boolean)

Since:

  • 2.0.0



207
208
209
# File 'sketchup.rb', line 207

def is_menu_bar_set?
  AMS::C.is_main_window_menu_bar_set?
end

+ (Boolean) is_minimized?

Determine whether main window is minimized.

Returns:

  • (Boolean)

Since:

  • 2.0.0



163
164
165
# File 'sketchup.rb', line 163

def is_minimized?
  AMS::C.is_window_minimized?(AMS::C.get_main_window())
end

+ (Boolean) is_restored?

Determine whether main window is restored.

Returns:

  • (Boolean)

Since:

  • 2.0.0



180
181
182
183
184
185
# File 'sketchup.rb', line 180

def is_restored?
  return false if AMS::C.is_main_window_full_screen?
  return false if AMS::C.is_window_minimized?(AMS::C.get_main_window())
  return false if AMS::C.is_window_maximized?(AMS::C.get_main_window())
  true
end

+ (Boolean) is_scenes_bar_empty?

Determine whether scenes bar is empty. Scenes bar is empty if there are no pages in the model.

Returns:

  • (Boolean)

Since:

  • 2.0.0



271
272
273
# File 'sketchup.rb', line 271

def is_scenes_bar_empty?
  AMS::C.is_scenes_bar_empty?()
end

+ (Boolean) is_scenes_bar_filled?

Determine whether scenes bar is filled. Scenes bar is filled if there is at least one page in the model.

Returns:

  • (Boolean)

Since:

  • 2.0.0



263
264
265
# File 'sketchup.rb', line 263

def is_scenes_bar_filled?
  AMS::C.is_scenes_bar_filled?()
end

+ (Boolean) is_scenes_bar_visible?

Determine whether scenes bar is visible.

Returns:

  • (Boolean)

Since:

  • 2.0.0



255
256
257
# File 'sketchup.rb', line 255

def is_scenes_bar_visible?
  AMS::C.is_scenes_bar_visible?
end

+ (Boolean) is_status_bar_visible?

Determine whether status bar is visible.

Returns:

  • (Boolean)

Since:

  • 2.0.0



238
239
240
# File 'sketchup.rb', line 238

def is_status_bar_visible?
  AMS::C.is_status_bar_visible?
end

+ (Boolean) is_toolbar_container_empty?(bar)

Determine whether toolbar container(s) is/are empty.

Parameters:

  • bar (Fixnum)

    1 - top, 2 - bottom, 3 - left, 4 - right, 5 - at least one, 6 - all.

Returns:

  • (Boolean)

Since:

  • 2.0.0



361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
# File 'sketchup.rb', line 361

def is_toolbar_container_empty?(bar)
  bar = AMS.clamp(bar.to_i, 1, 6)
  case bar
  when 1..4
    AMS::C.is_toolbar_container_empty?(bar)
  when 5
    for i in 1..4
      return true if AMS::C.is_toolbar_container_empty?(i)
    end
    false
  else
    for i in 1..4
      return false unless AMS::C.is_toolbar_container_empty?(i)
    end
    true
  end
end

+ (Boolean) is_toolbar_container_filled?(bar)

Determine whether toolbar container(s) is/are filled.

Parameters:

  • bar (Fixnum)

    1 - top, 2 - bottom, 3 - left, 4 - right, 5 - at least one, 6 - all.

Returns:

  • (Boolean)

Since:

  • 2.0.0



338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
# File 'sketchup.rb', line 338

def is_toolbar_container_filled?(bar)
  bar = AMS.clamp(bar.to_i, 1, 6)
  case bar
  when 1..4
    AMS::C.is_toolbar_container_filled?(bar)
  when 5
    for i in 1..4
      return true if AMS::C.is_toolbar_container_filled?(i)
    end
    false
  else
    for i in 1..4
      return false unless AMS::C.is_toolbar_container_filled?(i)
    end
    true
  end
end

+ (Boolean) is_toolbar_container_visible?(bar)

Determine whether toolbar container(s) is/are visible.

Parameters:

  • bar (Fixnum)

    1 - top, 2 - bottom, 3 - left, 4 - right, 5 - at least one, 6 - all, 7 - all filled.

Returns:

  • (Boolean)

Since:

  • 2.0.0



309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
# File 'sketchup.rb', line 309

def is_toolbar_container_visible?(bar)
  bar = AMS.clamp(bar.to_i, 1, 7)
  case bar
  when 1..4
    AMS::C.is_toolbar_container_visible?(bar)
  when 5
    for i in 1..4
      return true if AMS::C.is_toolbar_container_visible?(i)
    end
    false
  when 6
    for i in 1..4
      return false unless AMS::C.is_toolbar_container_visible?(i)
    end
    true
  else
    count = 0
    for i in 1..4
      return false if AMS::C.is_toolbar_container_filled?(i) && !AMS::C.is_toolbar_container_visible?(i)
    end
    true
  end
end

+ (Boolean) is_viewport_border_set?

Determine whether viewport border is set.

Returns:

  • (Boolean)

Since:

  • 2.0.0



222
223
224
# File 'sketchup.rb', line 222

def is_viewport_border_set?
  AMS::C.is_viewport_border_set?
end

+ (Boolean) maximize

Set main window maximized.

Returns:

  • (Boolean)

    success

Since:

  • 2.0.0



136
137
138
139
140
141
# File 'sketchup.rb', line 136

def maximize
  return false if is_maximized?
  AMS::C.set_main_window_full_screen(false, 1)
  AMS::C.show_window(AMS::C.get_main_window(), 3)
  true
end

+ (Boolean) minimize

Set main window minimized.

Returns:

  • (Boolean)

    success

Since:

  • 2.0.0



154
155
156
157
158
# File 'sketchup.rb', line 154

def minimize
  return false if is_minimized?
  AMS::C.show_window(AMS::C.get_main_window(), 3)
  true
end

+ (void) refresh

This method returns an undefined value.

Refresh current SketchUp application.

Since:

  • 2.0.0



642
643
644
# File 'sketchup.rb', line 642

def refresh
  AMS::C.refresh_window(AMS::C.get_main_window())
end

+ (Boolean) remove_observer(object)

Remove object from the observers list.

Parameters:

  • object (Object)

Returns:

  • (Boolean)

    success

Since:

  • 2.0.0



712
713
714
# File 'sketchup.rb', line 712

def remove_observer(object)
  AMS::C.remove_observer(object)
end

+ (Boolean) restore

Set main window to normal placement.

Returns:

  • (Boolean)

    success

Since:

  • 2.0.0



170
171
172
173
174
175
# File 'sketchup.rb', line 170

def restore
  return false if is_restored?
  AMS::C.set_main_window_full_screen(false, 0)
  AMS::C.show_window(AMS::C.get_main_window(), 9)
  true
end

+ (Boolean) set_caption(caption)

Set main window title text.

Parameters:

  • caption (String)

Returns:

  • (Boolean)

    success

Since:

  • 2.0.0



635
636
637
# File 'sketchup.rb', line 635

def set_caption(caption)
  AMS::C.set_window_text(AMS::C.get_main_window(), caption.to_s.unpack('U*').pack('C*'))
end

+ (Boolean) set_menu_bar(state)

Set/Remove menu bar.

Parameters:

  • state (Boolean)

Returns:

  • (Boolean)

    success

Since:

  • 2.0.0



200
201
202
# File 'sketchup.rb', line 200

def set_menu_bar(state)
  AMS::C.set_main_window_menu_bar(state)
end

+ (Boolean) set_viewport_border(state)

Set/Remove viewport border, a thin edge surrounding the view.

Parameters:

  • state (Boolean)

Returns:

  • (Boolean)

    success

Since:

  • 2.0.0



215
216
217
# File 'sketchup.rb', line 215

def set_viewport_border(state)
  AMS::C.set_viewport_border(state)
end

+ (Fixnum) show_dialogs(state)

Note:

Ignored windows won't be included in this operation.

Show/Hide all dialogs.

Parameters:

  • state (Boolean)

Returns:

  • (Fixnum)

    number of dialogs shown or hidden.

Since:

  • 2.0.0



416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
# File 'sketchup.rb', line 416

def show_dialogs(state)
  count = 0
  su_dialogs = []
  if state
    @dialogs.each { |handle|
      next unless AMS::C.is_window?(handle)
      next if @dialogs_to_ignore.include?(handle) || AMS::C.is_window_visible?(handle)
      caption = AMS::Window.get_text(handle)
      if @su_controlled_dialogs.include?(caption)
        su_dialogs << handle
      else
        AMS::C.show_window(handle, 8) # SW_SHOWNA
      end
      count += 1
    }
    @dialogs.clear
    unless su_dialogs.empty?
      Sketchup.send_action(21926)
      UI.start_timer(0.1, false){
        su_dialogs.each { |handle|
          next unless AMS::C.is_window?(handle)
          next if AMS::C.is_window_visible?(handle)
          Sketchup.send_action(21926)
          break
        }
      }
    end
  else
    visible_dialogs = AMS::C.get_visible_dialogs()
    @dialogs.concat visible_dialogs
    visible_dialogs.each { |handle|
      next if @dialogs_to_ignore.include?(handle)
      caption = AMS::Window.get_text(handle)
      if @su_controlled_dialogs.include?(caption)
        su_dialogs << handle
      else
        AMS::C.show_window(handle, 0) # SW_HIDE
      end
      count += 1
    }
    unless su_dialogs.empty?
      Sketchup.send_action(21926)
      UI.start_timer(0.1, false){
        su_dialogs.each { |handle|
          next unless AMS::C.is_window?(handle)
          next unless AMS::C.is_window_visible?(handle)
          Sketchup.send_action(21926)
          break
        }
      }
    end
  end
  count
end

+ (Boolean) show_scenes_bar(state, refresh = true)

Show/Hide scenes bar.

Parameters:

  • state (Boolean)
  • refresh (Boolean) (defaults to: true)

    Whether to update after changing state.

Returns:

  • (Boolean)

    success

Since:

  • 2.0.0



247
248
249
250
# File 'sketchup.rb', line 247

def show_scenes_bar(state, refresh = true)
  return false if state && AMS::C.is_scenes_bar_empty?()
  AMS::C.set_scenes_bar_visible(state, refresh)
end

+ (Boolean) show_status_bar(state, refresh = true)

Show/Hide status bar.

Parameters:

  • state (Boolean)
  • refresh (Boolean) (defaults to: true)

    Whether to update after changing state.

Returns:

  • (Boolean)

    success

Since:

  • 2.0.0



231
232
233
# File 'sketchup.rb', line 231

def show_status_bar(state, refresh = true)
  AMS::C.set_status_bar_visible(state, refresh)
end

+ (Boolean) show_toolbar_container(bar, state, refresh = true)

Show/Hide toolbar container(s).

Parameters:

  • bar (Fixnum)

    1 - top, 2 - bottom, 3 - left, 4 - right, 5 - all filled, 6 - all.

  • state (Boolean)
  • refresh (Boolean) (defaults to: true)

    Whether to update after changing state.

Returns:

  • (Boolean)

    success

Since:

  • 2.0.0



282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
# File 'sketchup.rb', line 282

def show_toolbar_container(bar, state, refresh = true)
  bar = AMS.clamp(bar.to_i, 1, 6)
  case bar
  when 1..4
    AMS::C.set_toolbar_container_visible(bar, state, refresh)
  when 5
    change = false
    for i in 1..4
      if AMS::C.is_toolbar_container_filled?(i)
        change = true if AMS::C.set_toolbar_container_visible(i, state, refresh)
      end
    end
    change
  else
    change = false
    for i in 1..4
      change = true if AMS::C.set_toolbar_container_visible(i, state, refresh)
    end
    change
  end
end

+ (Fixnum) show_toolbars(state)

Show/Hide all floating toolbars.

Parameters:

  • state (Boolean)

Returns:

  • (Fixnum)

    number of floating toolbars shown or hidden.

Since:

  • 2.0.0



519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
# File 'sketchup.rb', line 519

def show_toolbars(state)
  count = 0
  if state
    @toolbars.each { |handle|
      next unless AMS::C.is_window?(handle)
      AMS::C.show_window(handle, 8) # SW_SHOWNA
      count += 1
    }
    @toolbars.clear
  else
    visible_toolbars = AMS::C.get_visible_toolbars()
    @toolbars.concat visible_toolbars
    visible_toolbars.each { |handle|
      AMS::C.show_window(handle, 0) # SW_HIDE
      count += 1
    }
  end
  count
end

+ (Boolean) switch_full_screen(state, reset_mode = 2)

Set main window full screen.

Parameters:

  • state (Boolean)
  • reset_mode (Fixnum) (defaults to: 2)

    Whether to set restored (0), set maximized (1), or set to original placement (2) when main window is unset full screen.

Returns:

  • (Boolean)

    success

Since:

  • 2.0.0



122
123
124
# File 'sketchup.rb', line 122

def switch_full_screen(state, reset_mode = 2)
  AMS::C.set_main_window_full_screen(state, reset_mode.to_i)
end