sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    [plugin] Ruby Code Editor - UPDATED to v3.0 3/4/2013

    Scheduled Pinned Locked Moved Plugins
    56 Posts 11 Posters 39.8k Views 11 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.
    • D Offline
      driven
      last edited by

      @unknownuser said:

      Exactly, the Mac 'flaw' is the best feature

      Dan, I got this far last night and I'll have another look, with your new input in mind, but what do think??

      #
      > #  _PDF_Viewer.rb
      > 
      > #  seems to only work with adobe pdf format, but that's what safari saves pdfs to, so if it won't open, re-save from safari
      > #  seems to open most image files at full size so you may want smaller copies, export to mail and post to self is cheap and easy,
      > #  batch conversion, or graphics convertor.
      > 
      > #  helpmenue.rb Created by Dan Rathbun on 14/02/2010.
      > #  2010 @SCF. No? rights reserved.
      > 
      > #  modified for modal Mac usage by john@drivenupthewall.co.uk
      > #  show_modal works differently on PC's
      > #  user selected pdf + image veiwer 
      > #  for PLAT=Mac & OS=OSX
      > 
      > module SU_User
      >    module Menus
      > 
      > require "sketchup.rb"
      > # Check to see if the plugin is already loaded 
      > if not file_loaded? "_PDF_Viewer.rb" 
      > 
      > 
      > 
      > 
      > # where to look for it
      >    helpmenu=UI.menu('Help')
      >    helpmenu.add_separator
      > 
      > # it's name in the Help menu
      > 	
      >    helpmenu.add_item('PDF_Viewer') {
      >       file = UI.openpanel;
      >       get_dialog = UI;;WebDialog.new;
      >       get_dialog.show_modal;
      >       get_dialog.set_url(file)
      >    }
      > 	
      > 	
      >   end
      >     end
      > 
      > 
      >  file_loaded "_PDF_Viewer"
      > end
      

      If I move get_dialog.set_url(file) to the top will that allow multi-windows? I do get new file, iff I shut the first window

      chee

      Exactly, the Mac 'flaw' is the best feature

      Dan, I got this far last night and I'll have another look, with your new input in mind, but what do think??

      #
      #  _PDF_Viewer.rb
      
      #  seems to only work with adobe pdf format, but that's what safari saves pdfs to, so if it won't open, re-save from safari
      #  seems to open most image files at full size so you may want smaller copies, export to mail and post to self is cheap and easy,
      #  batch conversion, or graphics convertor.
      
      #  helpmenue.rb Created by Dan Rathbun on 14/02/2010.
      #  2010 @SCF. No? rights reserved.
      
      #  modified for modal Mac usage by john@drivenupthewall.co.uk
      #  show_modal works differently on PC's
      #  user selected pdf + image veiwer 
      #  for PLAT=Mac & OS=OSX
      
      module SU_User
         module Menus
      
      require "sketchup.rb"
      # Check to see if the plugin is already loaded 
      if not file_loaded? "_PDF_Viewer.rb" 
      
      
      
      
      # where to look for it
         helpmenu=UI.menu('Help')
         helpmenu.add_separator
      
      # it's name in the Help menu
      	
         helpmenu.add_item('PDF_Viewer') {
            file = UI.openpanel;
            get_dialog = UI;;WebDialog.new;
            get_dialog.show_modal;
            get_dialog.set_url(file)
         }
      	
      	
        end
          end
      
      
       file_loaded "_PDF_Viewer"
      end
      

      If I move get_dialog.set_url(file) to the top will that allow multi-windows? I do get new file, iff I shut the first window

      cheers
      john

      learn from the mistakes of others, you may not live long enough to make them all yourself...

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        @driven said:

        Exactly, the Mac 'flaw' is the best feature

        ? It's terrible. Makes it impossible to make replacements for UI.inputbox.

        Thomas Thomassen β€” SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • D Offline
          driven
          last edited by

          @thomthom said:

          ? It's terrible. Makes it impossible to make replacements for UI.inputbox.

          I'll more than likely agree if/when I get to that stage in coding, but being able to simply float the 'TextBook' over SU has already increased my workflow, so for now I see it as a blessing which I may curse later on...

          BTW: I found the your 'missing manual' page helpful, but only found it through google after I almost last-night.

          learn from the mistakes of others, you may not live long enough to make them all yourself...

          1 Reply Last reply Reply Quote 0
          • thomthomT Offline
            thomthom
            last edited by

            Yea - it'd odd that show on PC keeps the window ontop of SU, while on OSX it doesn't. So much for consistency. πŸ˜’

            ??? == osx.show() pc.show() == osx.show_modal() pc.show_modal() == ???

            Oh the sanity of being a SketchUp scripter!

            Thomas Thomassen β€” SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

            1 Reply Last reply Reply Quote 0
            • D Offline
              driven
              last edited by

              @thomthom said:

              Yea - it'd odd that show on PC keeps the window ontop of SU, while on OSX it doesn't.

              on the PC, if you are watching a tutorial in a wd viewer, can you pause to draw and still see the video, or does it jump to the back,under SU, where you have to go find it to carry on?

              learn from the mistakes of others, you may not live long enough to make them all yourself...

              1 Reply Last reply Reply Quote 0
              • thomthomT Offline
                thomthom
                last edited by

                Webdialogs on PC created using .show() is always parent to the SU window and will stay on top. Like SU's toolwindows.

                Thomas Thomassen β€” SketchUp Monkey & Coding addict
                List of my plugins and link to the CookieWare fund

                1 Reply Last reply Reply Quote 0
                • Dan RathbunD Offline
                  Dan Rathbun
                  last edited by

                  @driven said:

                  BTW: I found the your 'missing manual' page helpful, but only found it through google after I almost last-night.

                  Check out these links (bookmark them!):

                  Sketchup Ruby resources
                  http://forums.sketchucation.com/viewtopic.php?f=180&t=10142

                  Developer's Forum Sticky Links
                  http://forums.sketchucation.com/viewtopic.php?f=180&t=20427

                  State of Observers
                  http://forums.sketchucation.com/viewtopic.php?f=180&t=20676

                  I'm not here much anymore.

                  1 Reply Last reply Reply Quote 0
                  • D Offline
                    driven
                    last edited by

                    cheers for those Dan, it is a bit hard to navigate this forum, when your not quite sure what your looking for...

                    don't suppose you know a way of turning off

                    UI.play_sound(Sketchup.get_resource_path("video/fera.mp3"))
                    
                    #in sync with
                    
                    when "stop"
                    		UI.stop_timer @timer1;"video/fera.mp3"
                    

                    I know this dosen't work but I can't find any method of having the sound pause or stop when I turn off the video texture, which I can turn on and of at will.

                    I could change a new page and switch to another .mp3 (blank), but as an exercise I'm trying to avoid that as instead off pause, continue, need to start over to keep in sync...

                    john

                    learn from the mistakes of others, you may not live long enough to make them all yourself...

                    1 Reply Last reply Reply Quote 0
                    • C Offline
                      chyn2000
                      last edited by

                      I wanted to say that this is an AWESOME plugin!

                      Some functionality suggestions that (IMHO) would make your interface even more invaluable:

                      Add break point capability:
                      At break points, the pluging could add a popup before execution (behind the scenes, not in the viewable text field). The user would just press 'OK' to continue on.

                      Add Escape or Kill button:
                      The Escape would be an emergency breakout to stop execution if the user created an inf loop. Maybe force inserted into any loop conditions (again, behind the sceens).

                      Add Variable Watcher window:
                      This might be pretty hard, but then maybe not, but also a variable watcher window sharing the space with the results/error window. I could see this working by having pairs of fields. Type the variable name in one field and the program updates that fields pair with the in scope value.

                      Reduce Web Console's realestate during execution:
                      Have the option to hide, minimize or make the Web Console transparent during code execution.

                      Just some suggestions, though I'm sure you are busy doing things that actually make you money so you can pay for internet access (oh, and I guess eat and have a place to sleep too... πŸ˜‰ )

                      Cheers!
                      Reg

                      1 Reply Last reply Reply Quote 0
                      • Dan RathbunD Offline
                        Dan Rathbun
                        last edited by

                        @driven said:

                        don't suppose you know a way of turning off ...
                        This needs to be broken off into a new thread. It's far removed from the WebConsole/RubyEditor discussion.
                        (and sorry.. John, I don't mess with sound in Sketchup or WebDialogs. My only suggestion would be to embed a media player of some kind in the webpage. Check up on the html OBJECT tag. [EMBED and APPLET are deprecated.])
                        http://msdn.microsoft.com/en-us/library/ms535859(VS.85).aspx

                        I'm not here much anymore.

                        1 Reply Last reply Reply Quote 0
                        • chrisglasierC Offline
                          chrisglasier
                          last edited by

                          Here's yet another plugin related to this from 2006.

                          The introspection aspect is interesting but it seems to have some problems with XP.


                          suapi.rb

                          With TBA interfaces we can analyse what is to be achieved so that IT can help with automation to achieve it.

                          1 Reply Last reply Reply Quote 0
                          • Dan RathbunD Offline
                            Dan Rathbun
                            last edited by

                            @driven said:

                            Is it possible, or could I put it on my website and read it from there (less preferable as the books not published yet)?

                            I think it would be better to open the PDF file using the Adobe Reader browser plugin running in a normal instance of Safari (in your case.)

                            How to Access a PDF in your default Browser
                            Safari on Mac | MS Internet Explorer on PC

                            Copy the code below save it to a file name 'helpmenu.rb' and put it in your plugins directory.

                            
                            # helpmenu.rb for PLAT=Mac & OS=OSX
                            # Public Domain
                            module SU_User
                              module Menus
                                helpmenu=UI.menu('Help')
                                helpmenu.add_separator
                                # Edit the 'Your TextBook Title' Menu Item Title below
                                # Edit the pathname to your textbook pdf file below
                                helpmenu.add_item('Your TextBook Title') { 
                                  UI.openURL("file;//localhost#{ENV['HOME']}/ruby/help/textbook.pdf")
                                }
                                #   #{ENV['HOME']} inside a double-quoted string
                                #   should return something like; '/Users/John' on the Mac
                                #   For PC, the HOME variable must be changed to USERPROFILE
                              end # module Menus
                            end # module SU_User
                            
                            

                            Revised: Added 'file://localhost' to openURL argument.(see posts below.)

                            I'm not here much anymore.

                            1 Reply Last reply Reply Quote 0
                            • R Offline
                              rvs1977
                              last edited by

                              looks great!

                              I discovered a strange behavior with my (danish)keyboard. When I want to
                              make brackets [ ], it opens a small textarea inside the console.
                              The textareabox appears when I push the AltGr key. When I enter numbers
                              and press Enter, it submits it at the top op the console???

                              anyone seen that too?


                              Get a Ruby

                              1 Reply Last reply Reply Quote 0
                              • alexschreyerA Offline
                                alexschreyer Extension Creator
                                last edited by

                                Just updated to version 2.0.

                                Cheers,
                                Alex

                                Author of "Architectural Design with SketchUp":
                                http://sketchupfordesign.com/

                                1 Reply Last reply Reply Quote 0
                                • GaieusG Offline
                                  Gaieus
                                  last edited by

                                  Alex (or anyone as a matter of fact): excuse my utter ignorance but how do I launch this plugin at all? 😳

                                  Gai...

                                  1 Reply Last reply Reply Quote 0
                                  • D Offline
                                    driven
                                    last edited by

                                    it's under Window >> Ruby Code Editor, not Plugins

                                    make sure it's 'checked' as an extension in prefs if not showing up

                                    john

                                    learn from the mistakes of others, you may not live long enough to make them all yourself...

                                    1 Reply Last reply Reply Quote 0
                                    • GaieusG Offline
                                      Gaieus
                                      last edited by

                                      Holy crap! I did not even think of that location. Thanks a bunch! πŸ‘

                                      (And of course, to Alex for the plugin) πŸ‘

                                      Gai...

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

                                      Advertisement