How to use it:
Open up you favourie notepad editor (a simple notepad will do) or you can download Notepad++ (Notepad++ download), copy and paste this script on your notepad. Save as .rb file. This will then make the file as ruby file.
Save the file name as "stairs" (...or anything you want). Put in on your plugins folder where your computer put all of your sketchup plugins folder. It's usually situated in this path if you're using SketchUp 2014 :(C:\Users\user\AppData\Roaming\SketchUp\SketchUp 2014\SketchUp\Plugins)
Save the file again on the notepad. Open up Sketchup.
There's a menu under the "Plugin" tab, "Draw Stairs". When you you click it it will state a command line on Ruby API, then it will execute the command. The resulting command actually produce 10 steps of stairs right on the origin.
Here's the script:
# Standard APIrequire 'sketchup.rb'# Show Ruby console at start-up so we can see any programming errorsSKETCHUP_CONSOLE.show# Add a menu item to launch our plugin.UI.menu("Plugins").add_item("Draw stairs") {UI.messagebox("I'm about to draw stairs")# Call our new methoddraw_stairs}def draw_stairs# Create some variablesstairs = 10rise = 8run = 12width = 100thickness = 3# Get "handles" to our model and the entities collection it contains.model = Sketchup.active_modelentities = model.entities#Loop across the same code several timesfor step in 1..stairs# Calculate our stairs cornersx1 = 0x2 = widthy1 = run * stepy2 = run * (step + 1)z = rise * step# Create a series of "points", each a 3-item array containing x,y, and zpt1 = [x1, y1, z]pt2 = [x2, y1, z]pt3 = [x2, y2, z]pt4 = [x1, y2, z]# Call methods on the Entities collection to draw stuffnew_face = entities.add_face pt1, pt2, pt3, pt4new_face.pushpull thicknessendend
It will look something like this on your notepad (or any note editor):
SOURCE: Ruby Language Sketchup Tutorial - How to make stairs
GLHF!
AND ONCE AGAIN. THANK YOU GOOGLE!
No comments:
Post a Comment