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

    Creating Ruby Scripts Question

    Scheduled Pinned Locked Moved Developers' Forum
    2 Posts 2 Posters 923 Views 2 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.
    • N Offline
      not registered yet
      last edited by

      How do you create ruby scripts for SketchUp and share the whole world or country? 🤓

      [Invader ZIM]

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

        Primarily, do research to learn about ruby. It helped me that I'd learned BASIC back in the day. [When I learned, there was no DOS because there was no Disk - our first computer loaded software from cassette tapes, and the OS was hard-wired. I still remember going with my dad to have the RAM upgraded from 16K to 64K (no joke!), and then coming home from school another time to find two large gray boxes next to the monitor. They happened to be floppy drives (the big 5.25" kind). So much faster than tapes! Then there was that MOdulator-DEModulator to allow computers to connect over phone lines (a "MODEM", it was called). And there was no such thing as a mouse...]

        Anyway, I digress. Having any background is helpful, but ruby is easy enough to learn even without a programming background. See http://www.ruby-doc.org/docs/ProgrammingRuby/ for a good introduction and research resource for ruby programming.

        Then study the ruby help files for how SketchUp adds its own objects and methods to ruby.

        Then study other scripts to see how they are constructed, what methods they use, etc.

        Some starting points:

        In ruby, the application is referred to as "Sketchup", the model is "Sketchup.active_model", and the geometry is "Sketchup.active_model.entities" (base-level geometry) or "Sketchup.active_model.active_entities" (base- or nested-level geometry).

        Any of these things can be assigned to variables:
        model=Sketchup.active_model
        entities=model.active_entities (because 'model' has been assigned to "Sketchup.active_model", then this assignment is the same as saying "entities=Sketchup.active_model.active_entities")
        selection=model.selection

        So, there's lesson one. Have fun learning!

        RickW
        [www.smustard.com](http://www.smustard.com)

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

        Advertisement