Ruby WebDialog that invokes a Java Calculator Applet
-
I threw this together some time back. I snagged the Java calculator off the net and created the webdialog to wrap around it to do a quick proof of concept that a java applet could be used inside SketchUp. It works just fine on a Mac. I just tested it on Windows (SketchUp 6.0.515 with java 1.6.0_05 and Internet Explorer 6.0.2900.2180) and under SketchUp, the applet does not appear (just a grey window), but it does appear properly when Calculator.html is double-clicked under Explorer and it runs under IE natively... )
The calculator applet could use some cleaning up, but otherwise, it's functional.
I've packed it all up in a .zip file. If you want to see it work, dump everything (4 files) in your /Plugins folder.
calcu.rb - the ruby webdialog script
Calculator.html - the html window call by Ruby
Calculator.class - the compiled java bytecode
Calculator.java - the java source code in case you want to play around with it.Todd
-
Hi Todd,
apropos calculator:
Is it possible to write a Ruby that enables you to do simple type in calculations?
for example, I copy(move) an object and type in the distance (lets say 50), then hit enter. but if I want to move it only one third of the distance I just type in
50 / 3
and the object is moved one third of 50.
the same could work when drawing geometry like a line.but I guess this is something the SketchUp guys themselve have to do because ruby doesnt give enough freedom to change every keyboard input, am I right?
-
working on Windows with SU 6.4.112, Java 1.6.0_10 beta 13
-
@plot-paris said:
Hi Todd,
apropos calculator:
Is it possible to write a Ruby that enables you to do simple type in calculations?
for example, I copy(move) an object and type in the distance (lets say 50), then hit enter. but if I want to move it only one third of the distance I just type in
50 / 3
and the object is moved one third of 50.
the same could work when drawing geometry like a line.but I guess this is something the SketchUp guys themselve have to do because ruby doesnt give enough freedom to change every keyboard input, am I right?
I guess I don't understand. Like you said, you can type in 50 / 3 right now in the VCB and the object will move 16 2/3 units.
A Ruby calculator is possible, but I guess I'm missing the use case.
-
@unknownuser said:
working on Windows with SU 6.4.112, Java 1.6.0_10 beta 13
Good to know! Thanks TBD.
-
oh my god! didn't know this is possible!!!
(tried it ages ago and it didn't work. dont know why)Todd, you made my day!
but why does it only work for / but not for *****, + or -? isn't that a bit inconsequent?
-
You are right. Now, I see a use case for a MOVE tool with Calculator. This could be done. (Although I would rather Google modify the VCB to allow this!)
Todd
-
see Move Tool help
think that / is more for creating copies at an equal distance apart than a calculator.
found out that we can move things to [x,y,z] - nice.
sorry Todd for the hijack.
-
At the risk of sounding stupid, could you give us a screen shot of how this would work and what the application would be?
Scott
-
@plot-paris said:
for example, I copy(move) an object and type in the distance (lets say 50), then hit enter. but if I want to move it only one third of the distance I just type in
50 / 3
and the object is moved one third of 50.
the same could work when drawing geometry like a line.The only problem with the VCB is that it does not work when you have decimalsin the numbers
For instance, if your unit is Centimeters and you type in the Line tool:- "50.0/3" will give 3 cm
- "50.0/3.0" will give 50 cm
It's not very complex to supersede this in Ruby, but the trick is that you have to convert numbers to Float first. Otherwise, 50/3 will simply give 16, not 16.67. You can try in the Ruby console. So a straightforward #Eval() won't make it.
I had to do it in my script PlaneShear for entering angles (in degrees, radians or as a tangent value)
Advertisement