sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🫛 Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    Ruby beginner

    Scheduled Pinned Locked Moved Developers' Forum
    2 Posts 2 Posters 336 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.
    • J Offline
      Joe52
      last edited by

      I'm needing some help with my first attempt at learning Ruby and making a Ruby script. I got Beginning Ruby by Peter Cooper; I'm still looking for something on file conversion and exporting, and for the SketchUp Ruby library similar to the Just Java guides Sun published for Java. The last time that I had programmed was about 10 years ago, so for all purposes I'm a beginner.

      The first five lines below are a description of what the script should do. The remainder below is POV-Ray code that does this with embedded coordinates for the model, a 2D Bézier spline rotated around an axis (part in the lathe { bezier_spline 24) procedure. For the script, I want to use a procedure to get the model's coordinates. How do I simulate the part for each ray from the center of the sphere to a grid point compute the intersection of the ray with the object for at least one ray?

      • draw a sphere around the object to be represented

      • draw a 64x64 grid on the sphere (like parallels and meridans on a world map)

      • for each ray from the center of the sphere to a grid point

      • compute the intersection of the ray with the object

      • Scale, normalize, etc to fit into 0-255 range.
        ` #declare t_sculpty = texture {
        pigment {
        average
        pigment_map {
        [1 gradient x color_map {[0 rgb 0][1 rgb <1,0,0>]}]
        [1 gradient y color_map {[0 rgb 0][1 rgb <0,0,1>]}]
        [1 gradient z color_map {[0 rgb 0][1 rgb <0,1,0>]}]
        }
        translate -0.5
        }
        finish { ambient 3 diffuse 0 }
        }

      lathe { bezier_spline 24,
      <0.000,0.005>, <0.000,0.005>, <0.102,0.005>, <0.102,0.005>,
      <0.102,0.005>, <0.102,0.102>, <0.060,0.154>, <0.214,0.212>,
      <0.214,0.212>, <0.370,0.270>, <0.450,0.307>, <0.450,0.410>,
      <0.450,0.410>, <0.450,0.511>, <0.450,0.957>, <0.450,0.974>,
      <0.450,0.974>, <0.450,0.990>, <0.371,0.997>, <0.352,0.990>,
      <0.352,0.990>, <0.332,0.985>, <0.175,0.975>, <0.000,0.975>
      sturm
      translate y*-0.5
      scale <1,-1,1>
      texture { t_sculpty }
      }

      sphere { 0, 1.001 inverse
      finish { ambient 0 diffuse 0 reflection 1 }
      }

      camera { spherical location 0 look_at z*-1 }`

      1 Reply Last reply Reply Quote 0
      • M Offline
        MartinRinehart
        last edited by

        Start here:

        http://www.MartinRinehart.com/models/tutorial/tutorial_11.html

        You'll need chapter 15, too, which I'm working on at the moment. 11 through 14 cover a lot of ground.

        Good luck. Pick a simpler project for your starting go.

        Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

        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