• Login
sketchucation logo sketchucation
  • Login
πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Ruby WebDialog that invokes a Java Calculator Applet

Scheduled Pinned Locked Moved Developers' Forum
10 Posts 5 Posters 890 Views 5 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    todd burch
    last edited by 3 Jun 2008, 12:39

    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


    sketchup_ruby_java_calculator.zip

    1 Reply Last reply Reply Quote 0
    • P Offline
      plot-paris
      last edited by 3 Jun 2008, 12:59

      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? πŸ˜•

      1 Reply Last reply Reply Quote 0
      • T Offline
        tbd
        last edited by 3 Jun 2008, 13:01

        working on Windows with SU 6.4.112, Java 1.6.0_10 beta 13

        SketchUp Ruby Consultant | Podium 1.x developer
        http://plugins.ro

        1 Reply Last reply Reply Quote 0
        • T Offline
          todd burch
          last edited by 3 Jun 2008, 13:15

          @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.

          1 Reply Last reply Reply Quote 0
          • T Offline
            todd burch
            last edited by 3 Jun 2008, 13:15

            @unknownuser said:

            working on Windows with SU 6.4.112, Java 1.6.0_10 beta 13

            Good to know! Thanks TBD.

            1 Reply Last reply Reply Quote 0
            • P Offline
              plot-paris
              last edited by 3 Jun 2008, 13:32

              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?

              1 Reply Last reply Reply Quote 0
              • T Offline
                todd burch
                last edited by 3 Jun 2008, 13:51

                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

                1 Reply Last reply Reply Quote 0
                • T Offline
                  tbd
                  last edited by 3 Jun 2008, 14:24

                  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.

                  SketchUp Ruby Consultant | Podium 1.x developer
                  http://plugins.ro

                  1 Reply Last reply Reply Quote 0
                  • S Offline
                    ScottPara
                    last edited by 3 Jun 2008, 14:32

                    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

                    Love the fact that some HATE my avatar.....

                    1 Reply Last reply Reply Quote 0
                    • fredo6F Offline
                      fredo6
                      last edited by 5 Jun 2008, 03:46

                      @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)

                      1 Reply Last reply Reply Quote 0
                      • 1 / 1
                      1 / 1
                      • First post
                        1/10
                        Last post
                      Buy SketchPlus
                      Buy SUbD
                      Buy WrapR
                      Buy eBook
                      Buy Modelur
                      Buy Vertex Tools
                      Buy SketchCuisine
                      Buy FormFonts

                      Advertisement