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

    SketchUp RUBY API Wishlist [way of coding wishes, please]

    Scheduled Pinned Locked Moved Developers' Forum
    107 Posts 46 Posters 39.8k Views 46 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.
    • M Offline
      MarcioAB
      last edited by

      Access to Model.open ( open method of Model class ) as presented in this topic1 and this topic2.

      Thank you

      1 Reply Last reply Reply Quote 0
      • J Offline
        jessejames
        last edited by

        hello Scott,
        Thanks for your interest in helping out. That game you made was pretty cool.

        I would like to see some convience methods like in the Blender API. This may not be appealing to Gurus but might be quite helpful to the new rubyist. Something like...

        
        obj.LocX --> (0,0,0)
        obj.LocX += 20
        obj.LocX --> (20,0,0)
        obj.loc = 0,0,0 #set loc
        obj.getMatrix()
        
        

        i am also wondering why there is no way to do simple and dirty animations, like...

        
        Loop
            obj.LocX += 10
            sleep(.02)
            SU.Redraw()
        
        

        I really like most of the SU API's layout compared to Blender, except the Transformation module, it seems a little clumsy. But i might be missing something important. I am not an engineer, just a real brave lad, thats all.

        So if you want to enlighten me, feel free 😄

        Always sleep with a loaded gun under your pillow!

        1 Reply Last reply Reply Quote 0
        • daikuD Offline
          daiku
          last edited by

          I'd like to be able to specify the font size for text objects.

          Clark Bremer
          http://www.northernlightstimberframing.com

          1 Reply Last reply Reply Quote 0
          • T Offline
            tomot
            last edited by

            I would like to see a GUI added to the Ruby API. This has been sadly lacking from when the Ruby API was first added to be the scripting language for SU. Please add this to your SU8 wish list. Failing that, perhaps an easier task maybe to add a Python API with GUI to SU. I see no reason why SU can't function with 2 scripting languages.

            [my plugins](http://thingsvirtual.blogspot.ca/)
            tomot

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

              A GUI to the API what do you mean? As oppose to Webdialogs?

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

              1 Reply Last reply Reply Quote 0
              • J Offline
                jessejames
                last edited by

                I think what tomot wants is a GUI toolkit built-in for SU scripting. Web dialogs are quite lacking. Scriptwriters need widgets!

                Text, Listbox, Entry, Button, Frame, Toplevel, Spinbox, Label, Scrollbar, Dialogs, RadioButton, CheckButton, Menu, Scale, LabelFrame, Canvas, OptionMenu, PanedWindow, Image Support

                Python has all this built-in to the language as Tkinter(Tk widgets) An easy to use GUI builder with every thing a script writer/SUupper needs, amoung others.

                I will also volunteer to do most of the dirty work to grow a Python API(and i could get others to help also -- SU DEV would not have to do much).

                One of the best things about Python as compared to Ruby is the tons and tons of great documentation. This would be very appealing to those who wish to script but cannot find good docs for Ruby. And the built-in GUI is just icing on the cake!

                Always sleep with a loaded gun under your pillow!

                1 Reply Last reply Reply Quote 0
                • T Offline
                  tomot
                  last edited by

                  @jessejames said:

                  I think what tomot wants is a GUI toolkit built-in for SU scripting. Web dialogs are quite lacking. Scriptwriters need widgets!

                  Text, Listbox, Entry, Button, Frame, Toplevel, Spinbox, Label, Scrollbar, Dialogs, RadioButton, CheckButton, Menu, Scale, LabelFrame, Canvas, OptionMenu, PanedWindow, Image Support

                  Yes that's exactly what I meant. Here is a Google definition of Webdialogs:

                  By using powerful cross-browser Javascript and CSS, WebDialog renders dialogs, windows and even modal dialogs inside the browser window. It avoids the problems caused by restrictive popup blockers and gives you greater flexibility when designing your web application's user interface.

                  That's not going to help my scripting endeavors without now also having to learn Javascript and CSS.

                  JJ you put a generous offer of the table, I would like to contribute where ever possible. Lets hope we can get ScottLininger on board? Because without some support from Google I can't see this going very far.

                  [my plugins](http://thingsvirtual.blogspot.ca/)
                  tomot

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

                    Coming from a webdesign background I forgot that HTML, CSS and JS is also a thing to be learnt. I see your point. I was just confused because you allready have most of the controls JJ mentioned. But as you say, it a new set of languages to learn.

                    As for the lacking set of widgets, there are many frameworks that can easily be added on to extend the widget collection.

                    But I'm puzzled by another thing, tomot; you would be willing to learn Python to make a GUI, but not CSS+JS?

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

                    1 Reply Last reply Reply Quote 0
                    • T Offline
                      tomot
                      last edited by

                      @thomthom said:

                      But I'm puzzled by another thing, tomot; you would be willing to learn Python to make a GUI, but not CSS+JS?

                      It may surprise you Thomas; I'm not a Ruby programmer or a LISP programmer nor GDL http://en.wikipedia.org/wiki/Geometric_Description_Language programmer.
                      I could not sit down with a text editor and bang out a new Ruby without at the same time having open on my Desktop at least 2 or 3 existing Ruby's whose content may help form the basis of a new ruby idea I'm trying to bring into being. Then through lots of cutting and pasting of code and many trials and errors of loading and reloading the same script into the console, over and over again, I eventually arrive at the solution. The programming related lines I can't solve I usually bring forth to this forum for help from those that have real programming knowledge, and I'm always grateful for their support. The following piece of code was provided by Jim Foltz.

                      normal = useanamehere.normal
                      normal.length = -$xxx
                      tr = Geom;;Transformation.translation(normal)
                      group.transform! tr
                      

                      This small piece of code has been invaluable, its used repeatedly to offset distances that make 2d lines into 3d, planes, without it Window and Door Tools could not exist.

                      Its also one of the reasons I'm grateful that not each Ruby contributor decides to use obfuscation on their code. Obviously if everyone did this, this community would not have benefited from my Window and Door Tools scripts.

                      If this Python API works out, I will approach scripting with it the same way I do with Ruby. Firstly I would ask for some simple existing Ruby's to be converted to Python. I would use that as a springboard to start scripting in Python.

                      [my plugins](http://thingsvirtual.blogspot.ca/)
                      tomot

                      1 Reply Last reply Reply Quote 0
                      • J Offline
                        jessejames
                        last edited by

                        @tomot said:

                        ...I could not sit down with a text editor and bang out a new Ruby without at the same time having open on my Desktop at least 2 or 3 existing Ruby's whose content may help form the basis of a new ruby idea I'm trying to bring into being. Then through lots of cutting and pasting of code and many trials and errors of loading and reloading the same script into the console, over and over again, I eventually arrive at the solution.

                        I agree tomot,
                        The work flow for writing scripts in SU is frustrating. This must be improved. Nobody(pro or not) has the ability to write bug free scripts in one go.

                        1.) A built-in text editor(very simple) with syntax highlight so a new scripter can get started easily
                        2.) a multi-line Console(for testing snippets with proper indentation) to replace the single line Ruby Console
                        3.) a real GUI toolkit(Python has TK built-in to the language)
                        4.) a good SU specific scripting tutorial.( most important )

                        These are the key to happy SU scripting.

                        The current work flow is painful and a real determent to all who wish to learn, or write scripts for SU. Something must be done. Scripting must be made available to all, not just a few professionals at the top.

                        SU design is flawless everywhere but this area. Once we can fix this, the full power of SU will be available to all.

                        Always sleep with a loaded gun under your pillow!

                        1 Reply Last reply Reply Quote 0
                        • Al HartA Offline
                          Al Hart
                          last edited by

                          UI.openpanel - bugs and improvement requests

                          I would like UI.openpanel to be much more powerful.

                          I have at three problems with it.

                          1. Patterns for file extensions

                          This first code snippet should display all files with either a .zip or .rb extension.
                          When I use it in SU 7 Windows, the openfile panel displays only the .zip files, (no .rb files), and showed this '*.zip;_.rb' in the File name box: (with an underscore instead of a *)

                          fn = UI.openpanel "Select a zip file.", "",  "*.zip;*.rb"
                          
                          

                          When I pass it just one extension, it works:

                          UI.openpanel "Select a zip file.", "",  "*.zip"
                          

                          But if I pass it a starting folder it fails:

                          UI.openpanel "Select a zip file.", "c;/tmp",  "*.zip"
                          

                          showing '_.zip' in the File Name box

                          1. Passing patterns and a starting file separately

                          I should be able pass a file name (e.g. the last file the user opened), as well as a set of patterns.

                          1. Passing filters.

                          The Windows openfile dialog allows you to pass a set of filters which display at the bottom. UI.openfile should have a similar set of patterns.

                          #2 and #3 could be implemented with new, optional parameters.

                          1. Required file

                          Windows Openfile has a setting that required that the user enter a valid, existing file. This would be a nice feature for UI.openpanel.

                          Al Hart

                          http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
                          IRender nXt from Render Plus

                          1 Reply Last reply Reply Quote 0
                          • Al HartA Offline
                            Al Hart
                            last edited by

                            Bug/new feature request for Sketchup.load

                            Sketchup.load does not set the filename or binding properly. errors during loading are not reported, and executaion errors are not reported properly.

                            Here is a test file with an error which only occurs during execution.

                            rps_test1.rb

                            
                            printf "rps_test1.rb\n"
                            def test1
                                    printf xxx
                            end
                            
                            

                            When you load it with ruby's load and execute 'test1' you get this error:

                            
                            Error; #<NameError; c;/tmp/rps_test1.rb;6;in `test1'; undefined local variable or method `xxx' for main;Object>
                            c;/devc_2005/rptools/rpt_debug/ruby/rps_test1.rb;6
                            
                            

                            When you load it in Sketchup.load (either the .rb or the compressed .rbs), you get this error message:

                            
                            
                            Error; #<NameError; (eval);11;in `test1'; undefined local variable or method `xxx' for main;Object>
                            (eval);11
                            
                            

                            Having the file name and line number for a ruby is very important both when creating a ruby application and when debugging client problems. I have to go to a lot of trouble to work around this bug. 😞

                            Assuming that 'eval()' is eventually used by Skethcup.load to load, binding and a file name could be passed to cause errors to be reported properly.

                            e.g.: eval(string, TOPLEVEL_BINDING, filename, start_line)

                            Al Hart

                            http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
                            IRender nXt from Render Plus

                            1 Reply Last reply Reply Quote 0
                            • T Offline
                              todd burch
                              last edited by

                              I haven't read through this post, so some of these might be duplicates. If they are, consider mine a +1.

                              • Expose the Surface class.
                              • Change the data model for Text so its not a global thing, but an entity thing. That way, each text-related entity can have it own font and other attributes.
                              • Expose Dimensions.
                              • Fix all the bugs I've reported. Really. 😒
                                Thanks, Todd
                              1 Reply Last reply Reply Quote 0
                              • N Offline
                                NewOne
                                last edited by

                                Sorry if off-topic.
                                But... did you guys heard something about Sketchup 7 ruby documentation? What's really new here? Will it appear? When?

                                Thank you. 😄

                                1 Reply Last reply Reply Quote 0
                                • scottliningerS Offline
                                  scottlininger
                                  last edited by

                                  We summarized the new SU7 features in a blog post:

                                  Link Preview Image
                                  What's New in SketchUp 7

                                  Posted by Scott Lininger, SketchUp Team SketchUp 7 contains several improvements to the Ruby API. Here's a quick tour of the best changes. I...

                                  favicon

                                  (sketchupapi.blogspot.com)

                                  I can't give an exact date for the detailed documentation. We're working on it.

                                  Thanks,

                                  • Scott Lininger
                                    SketchUp Software Engineer
                                    Have you visited the Ruby API Docs?
                                  1 Reply Last reply Reply Quote 0
                                  • thomthomT Offline
                                    thomthom
                                    last edited by

                                    My suggestion of way of coding: Being able to hook up a debugger. Sorely needed some times.

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

                                    1 Reply Last reply Reply Quote 0
                                    • N Offline
                                      NewOne
                                      last edited by

                                      To be able to add new menus in SketchUp menu bar.


                                      2009-03-10_135226.png

                                      1 Reply Last reply Reply Quote 0
                                      • J Offline
                                        jadema
                                        last edited by

                                        Extend the UI class to support the selection of a directory. Currently you can select files, but there doesn't seem to be a way to select a directory or folder.

                                        1 Reply Last reply Reply Quote 0
                                        • snicoloS Offline
                                          snicolo
                                          last edited by

                                          The New Ruby API documentation is up and running.

                                          Take a look at:
                                          http://code.google.com/apis/sketchup/docs/index.html

                                          enjoy.
                                          Simone.

                                          Simone Nicolo
                                          QA Manager
                                          http://www.sketchup.com

                                          1 Reply Last reply Reply Quote 0
                                          • J Offline
                                            jadema
                                            last edited by

                                            How about a method to refresh the SketchUp display when executing long scripts? Today the interface looks like it is frozen when you change focus to another window and then back to SketchUp. The display gets refreshed only when the script completes or a dialog box that requires user input is displayed.

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

                                            Advertisement