A user with a windows 8 machine running SU 2013 has reported an error that I can't duplicate ( I don't have a windows 8 machine )
puts "starting: dialog.execute_script( js_command )"
dialog.execute_script( js_command )
this code doesn't run
puts "finished: dialog.execute_script( js_command )"
it errors out with this
type: mismatch
code: 0
url: file:///C:/Users/Admin/AppData/Local/Temp/skp8C34.tmp
Is there anyone else with a Windows 8 machine running 2013 who would be willing to try this code.
` require 'sketchup.rb'
#---------------------------------------
show_dialog
#---------------------------------------
def show_dialog()
dlg = UI::WebDialog.new( "Stair Measurements", false, "DialogTest", 200, 150, 150, 150, true );
dlg.add_action_callback( "ruby_callback" ) { |dialog, params|
text = params.to_s
if( text == 'loaded' )
args = 'inside_stringer=Housed|Sawtooth|None' +
'&inside_stringer=1' +
'&inside_option=Has Heel|Has Foot|Both|None' +
'&inside_option=3' +
'&inside_thickness=60' +
'&inside_width=300' +
'&inside_rail=Guard Rail|Wall Rail|None' +
'&inside_rail=2' +
'&outside_stringer=Housed|Sawtooth|None' +
'&outside_stringer=0' +
'&outside_option=Has Heel|Has Foot|Both|None' +
'&outside_option=3' +
'&outside_thickness=60' +
'&outside_width=400' +
'&outside_rail=Guard Rail|Wall Rail|None' +
'&outside_rail=2' +
'&total_rise=2667' +
'&risers=15' +
'&riser_thickness=12.7' +
'&direction=Clockwise|Anti Clockwise' +
'&direction=1' +
'&stair_width=1000' +
'&radius=2400' +
'°rees=90' +
'&floor_thickness=60' +
'&rail_style=Classic|Modern|Round|Square|Standard|Traditional' +
'&rail_style=4' +
'&tread_thickness=38' +
'&average_run=254' +
'&tread_bullnose=12.7' +
'&nosing=25.4' +
'&flare_amount=0' +
'&progressive_flare=20' +
'&flare_count=0'
js_command = "from_ruby( '" + args + "' )"
puts( js_command )
puts "starting: dialog.execute_script( js_command )"
dialog.execute_script( js_command )
puts "finished: dialog.execute_script( js_command )"
else
UI.messagebox( text )
puts( text )
end
dialog.close();
}
html = <<-HTML
<!DOCTYPE html>
<html>
<style type="text/css">
body { background-color: #F9EBD1}
fieldset { float: left; background-color: #F9EBD1; border-color: black; margin: 3px;}
fieldset p {display: table-row;
font-family: Arial, Helvetica, sans-serif;
font-size: 90%;
color: black;
height: 27px}
fieldset input,
fieldset select,
fieldset label {display: table-cell; margin: 2px; width: 120px }
fieldset label {text-align: right;}
fieldset input,
fieldset select {margin-left: 10px; background-color: wheat;}
}
</style>
<head>
<meta http-equiv="MSThemeCompatible" content="Yes">
<script>
function do_click()
{
var items = document.getElementsByTagName( '*' );
var count = items.length;
var text = "";
for ( var i = 0; i < count; i++ )
{
if ( items[i].type == "select-one" )
value = items[i].options[items[i].selectedIndex].value;
else if ( items[i].type == "text" )
value = items[i].value;
else if ( items[i].type == "checkbox" )
value = items[i].checked.toString();
else
value = "";
if ( value.length > 0 )
{
if ( text.length > 0 )
text += "&";
text += ( items[i].id + "=" + value );
}
}
ruby_call( text );
}
function from_ruby( data )
{
var element;
var pair;
var pairs = data.split( '&' );
var count = pairs.length;
for ( var i = 0; i < count; i++ )
{
pair = pairs[i].split( '=' );
element = document.getElementById( pair[0] )
if ( element.type == "select-one" )
{
if ( pair[1].indexOf('|') == -1 )
element.selectedIndex = pair[1];
else
populate_drop_down( element, pair[1] );
}
else if ( element.type == "text" )
element.value = pair[1];
else if ( element.type == "checkbox" )
element.checked = pair[1] == '1';
}
}
function populate_drop_down( element, data )
{
var options = data.split( '|' );
var count = options.length;
var option;
element.innerHTML = "";
for ( var i = 0; i < count; i++ )
{
option = document.createElement( "option" );
option.text = options[i];
element.add( option, null );
}
}
function ruby_call( text )
{
query = 'skp:ruby_callback@' + text;
window.location.href = query;
}
function on_load()
{
ruby_call( 'loaded' );
}
</script>
</head>
<body onload="on_load()">
<form>
<fieldset>
<p><label>Inside Stringer:</label><select id="inside_stringer"></select></p>
<p><label>Options:</label><select id="inside_option"></select></p>
<p><label>Thickness:</label><input type="text" id="inside_thickness"</p>
<p><label>Width:</label><input type="text" id="inside_width"</p>
<p><label>Rail Options:</label><select id="inside_rail"></select></p>
</fieldset>
<fieldset>
<p><label>Outside Stringer:</label><select id="outside_stringer"></select></p>
<p><label>Options:</label><select id="outside_option"></select></p>
<p><label>Thickness:</label><input type="text" id="outside_thickness"</p>
<p><label>Width:</label><input type="text" id="outside_width"</p>
<p><label>Rail Options:</label><select id="outside_rail"></select></p>
</fieldset>
<fieldset>
<p><label>Stair Direction:</label><select id="direction"></select></p>
<p><label>Stair Width:</label><input type="text" id="stair_width"</p>
<p><label>Radius:</label><input type="text" id="radius"</p>
<p><label>Degrees:</label><input type="text" id="degrees"</p>
<p><label>Rail Style:</label><select id="rail_style"></select></p>
<p><label>Open Risers:</label><input type="checkbox" id="open_riser"</p>
<p><label>Total Rise:</label><input type="text" id="total_rise"</p>
<p><label>Risers:</label><input type="text" id="risers"</p>
<p><label>Riser Thickness:</label><input type="text" id="riser_thickness"</p>
</fieldset>
<fieldset>
<p><label>Tread Thickness:</label><input type="text" id="tread_thickness"</p>
<p><label>Average Run:</label><input type="text" id="average_run"</p>
<p><label>Tread Bullnose:</label><input type="text" id="tread_bullnose"</p>
<p><label>Nosing:</label><input type="text" id="nosing"</p>
<p><label>Flare Amount:</label><input type="text" id="flare_amount"</p>
<p><label>Progressive Flare:</label><input type="text" id="progressive_flare"</p>
<p><label>Flare Count:</label><input type="text" id="flare_count"</p>
<p><label>Floor Thickness:</label><input type="text" id= "floor_thickness"</p>
<p><label>Create Stair:</label><input type="button" onclick="do_click()" style="background: silver" value="Ok"></p>
</fieldset>
</form>
</body>
</html>
HTML
dlg.set_html html
dlg.show
end
if ( not file_loaded?( "dialog_test.rb" ) )
UI.menu( "Plugins" ).add_item( "Web Dialog Test" ) { show_dialog() }
file_loaded( "dialog_test.rb" )
end
------------------------------------------------`