สร้าง Dialog ด้วย HTML & URL ใหม่

Ruby & Sketchup by Keptcode.com

Last Updated: 2024-07-06 11:37

สร้าง Dialog & HTML File ใหม่

Path: [skeleton]\ruby-sketchup\html.rb

Language: Ruby

# Require
Sketchup::require('sketchup')

# Setting
html_width = 633
html_max_width = 993
html_height = 914

# New Dialog
dialog = UI::HtmlDialog.new({
  :dialog_title => 'สร้าง Dialog & HTML File ใหม่',
  :preferences_key => 'สร้าง Dialog & HTML File ใหม่',
  :scrollable => true,
  :resizable => true,
  :width => html_width,
  :height => html_height,     
  :min_width => html_width,
  :min_height => html_height,
  :max_width => html_max_width,
  :max_height => -1,
  :full_security => false,
  :style => UI::HtmlDialog::STYLE_DIALOG
})

# Path
path_file = File.dirname(__FILE__) + '/KeptcodeExtension'

# Add Files
if File.exists?(path_file + '/new.html')
  dialog.set_file(path_file + '/new.html')
else
  dialog.set_file(path_file + '/index.html')
end

# New Action
dialog.add_action_callback('callback') do | action_context |
  puts 'Callback: callback()'
  model = Sketchup.active_model
end

# Show
dialog.show

# Option
dialog.set_size(html_width, html_height)

สร้าง Dialog & Web HTML ใหม่

Path: [skeleton]\ruby-sketchup\html.rb

Language: Ruby

# Require
Sketchup::require('sketchup')

# Setting
html_width = 633
html_max_width = 993
html_height = 914

# New Dialog
dialog = UI::HtmlDialog.new({
  :dialog_title => 'สร้าง Dialog & Web HTML ใหม่',
  :preferences_key => 'สร้าง Dialog & Web HTML ใหม่',
  :scrollable => true,
  :resizable => true,
  :width => html_width,
  :height => html_height,     
  :min_width => html_width,
  :min_height => html_height,
  :max_width => html_max_width,
  :max_height => -1,
  :full_security => false,
  :style => UI::HtmlDialog::STYLE_DIALOG
})

# Add URL
dialog.set_url('https://keptcode.com/html')

# New Action
dialog.add_action_callback('callback') do | action_context |
  puts 'Callback: callback()'
  model = Sketchup.active_model
end

# Show
dialog.show

# Option
dialog.set_size(html_width, html_height)