# How to write ruby script

**URL:** <https://forums.sketchup.com/t/how-to-write-ruby-script/79390>\
**Category:** Developers\
**Created:** [October 18, 2018, 7:43am UTC](https://forums.sketchup.com/t/how-to-write-ruby-script/79390 "2018-10-18T07:43:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![shitexman](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@shitexman](https://forums.sketchup.com/u/shitexman)\
**Post date:** [October 18, 2018, 7:43am UTC](https://forums.sketchup.com/t/how-to-write-ruby-script/79390/1 "2018-10-18T07:43:11Z")

</div>

Hi guys, pls I’m pretty new to SketchUp and will like to know what a ruby script is and how to write one?.Thanks.

---

<div class="post-metadata">

**Author:** ![Aerilius](https://avatars.discourse-cdn.com/v4/letter/a/e19b73/32.png) [@Aerilius](https://forums.sketchup.com/u/Aerilius)\
**Post date:** [October 18, 2018, 8:06am UTC](https://forums.sketchup.com/t/how-to-write-ruby-script/79390/2 "2018-10-18T08:06:08Z")

</div>

A script is a **plain text file** that contains a simple **program** for automating tasks. You can open a script in a text editor like Notepad (or Notepad++, TextEdit, TextMate, Gedit, etc.). Ruby is the scripting language that SketchUp offers to customize SketchUp, automate modeling tasks or add custom tools.

You should first get familiar with sending commands to SketchUp in the Ruby Console. It is like a conversation (chat with SketchUp).  
You can also install the [Ruby Console+](https://extensions.sketchup.com/en/content/ruby-console) extension which makes it easier to learn Ruby.  
Check out SketchUp’s [developer portal](https://developer.sketchup.com/en) and work through the [beginner tutorials](https://github.com/SketchUp/sketchup-ruby-api-tutorials/tree/master/tutorials).

---

<div class="post-metadata">

**Author:** ![shitexman](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@shitexman](https://forums.sketchup.com/u/shitexman)\
**Post date:** [October 18, 2018, 8:18am UTC](https://forums.sketchup.com/t/how-to-write-ruby-script/79390/3 "2018-10-18T08:18:41Z")

</div>

Thanks, Aerilius will check that out. Very helpful.

---

<div class="post-metadata">

**Author:** ![DanRathbun](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/danrathbun/32/500_2.png) [@DanRathbun](https://forums.sketchup.com/u/DanRathbun)\
**Post date:** [October 18, 2018, 8:44pm UTC](https://forums.sketchup.com/t/how-to-write-ruby-script/79390/4 "2018-10-18T20:44:29Z")

</div>

> [@Ruby Learning Resources \[WikiLists\]](https://forums.sketchup.com/t/ruby-learning-resources-wikilists/22861/):
>
> All seven of the lists below are set as wikis. card_index INDEX [notebook PRIMERS & GUIDES](http://forums.sketchup.com/t/ruby-learning-resources/22861/2)[books BOOKS](http://forums.sketchup.com/t/ruby-learning-resources/22861/3)[mortar_board TUTORIALS](http://forums.sketchup.com/t/ruby-learning-resources/22861/4)[card_box REFERENCE](http://forums.sketchup.com/t/ruby-learning-resources/22861/5)[clipboard TEMPLATES](http://forums.sketchup.com/t/ruby-learning-resources/22861/6)[newspaper NEWS](http://forums.sketchup.com/t/ruby-learning-resources/22861/7)[bulb IDEAS](http://forums.sketchup.com/t/ruby-learning-resources/22861/8)

---

<div class="post-metadata">

**Author:** ![tt\_su](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/tt_su/32/17_2.png) [@tt\_su](https://forums.sketchup.com/u/tt_su)\
**Post date:** [October 19, 2018, 9:13am UTC](https://forums.sketchup.com/t/how-to-write-ruby-script/79390/5 "2018-10-19T09:13:20Z")

</div>

If you are brand to to Ruby/programming, have a look at the Getting Started resources over at Ruby’s website:

[https://www.ruby-lang.org/en/](https://www.ruby-lang.org/en/)

There’s for instance a “Ruby in 20 minutes” section that guides you through the basics: [Ruby in Twenty Minutes](https://www.ruby-lang.org/en/documentation/quickstart/)

Once you have gotten somewhat familiar with the basic concepts of programming, you can look at some of the examples/tutorials we have on our GitHub account. Outlines the basics for a SketchUp extension:

> **[GitHub - SketchUp/sketchup-ruby-api-tutorials: SketchUp Ruby API Tutorials...](https://github.com/SketchUp/sketchup-ruby-api-tutorials)**
>
> SketchUp Ruby API Tutorials and Examples. Contribute to SketchUp/sketchup-ruby-api-tutorials development by creating an account on GitHub.

The simplest extension example demonstrate how to create a menu item and a comment that create a cube. It’s heavily commented: [sketchup-ruby-api-tutorials/tutorials/01\_hello\_cube at main · SketchUp/sketchup-ruby-api-tutorials · GitHub](https://github.com/SketchUp/sketchup-ruby-api-tutorials/tree/master/tutorials/01_hello_cube)

You can have a look at those references, and play in the Ruby Console, (Or @Aerilius’s Ruby Console+) to get yourself familiar with the SketchUp API.

Always keep the Ruby documentation and SketchUp Ruby API documentation handy. (See Dan’s post)
