![](https://static.wixstatic.com/media/a27d24_a808b6d110cd47d68c6273c30f11a7d7~mv2.gif/v1/fill/w_640,h_360,al_c,pstr/a27d24_a808b6d110cd47d68c6273c30f11a7d7~mv2.gif)
In this tutorial, we're writing a SketchUp script that will automatically create scenes with the names of every layer in your model. The best part is that entities that belong to a specific layer will only be visible in the scene that matches that layer's name.
![](https://static.wixstatic.com/media/a27d24_7a7cbf9e68c84da9bc1a1c6183d28e4b~mv2.png/v1/fill/w_620,h_465,al_c,q_85,enc_avif,quality_auto/a27d24_7a7cbf9e68c84da9bc1a1c6183d28e4b~mv2.png)
The instructions on how to run the script with the Ruby Code Editor Plugin is in my first tutorial.
But, If you like LayerScene and want to install it as a SketchUp Extension/Plugin which includes a toolbar button, then you can buy it for a small fee in the link below.
Before explaining what each line of code does, let me recommend the following book so you can better understand the Ruby syntax.
Click the link and get a copy of this book, it will give you the knowledge to start coding with Ruby which is the language that SketchUp uses to create Extensions/Plugins.
Let's Begin!
![](https://static.wixstatic.com/media/a27d24_72e7b64f21bb4c589d5c3902a5e7d8d3~mv2.png/v1/fill/w_896,h_504,al_c,q_90,enc_avif,quality_auto/a27d24_72e7b64f21bb4c589d5c3902a5e7d8d3~mv2.png)
When you're starting to prototype ideas it is best to start small and at this point, 14 lines of code were all we needed to prove our concept. The following is a breakdown of the logic behind each line of code and the API calls used in the script...Enjoy!
![](https://static.wixstatic.com/media/a27d24_d2f9df89ea4b41f296b925ad8d5877c9~mv2.png/v1/fill/w_896,h_131,al_c,q_85,enc_avif,quality_auto/a27d24_d2f9df89ea4b41f296b925ad8d5877c9~mv2.png)
API: Model , Entities , Pages , Layes , Model #activelayer
![](https://static.wixstatic.com/media/a27d24_7e2a009c82c24e7587a430062a6483a7~mv2.png/v1/fill/w_896,h_34,al_c,q_85,enc_avif,quality_auto/a27d24_7e2a009c82c24e7587a430062a6483a7~mv2.png)
API: Layers #each
![](https://static.wixstatic.com/media/a27d24_b6085c5e60f5428ea508b70ee820bd17~mv2.png/v1/fill/w_896,h_24,al_c,q_85,enc_avif,quality_auto/a27d24_b6085c5e60f5428ea508b70ee820bd17~mv2.png)
API: Layer
![](https://static.wixstatic.com/media/a27d24_0aeca6c61b864b7fa420affdc10a43a8~mv2.png/v1/fill/w_896,h_26,al_c,q_85,enc_avif,quality_auto/a27d24_0aeca6c61b864b7fa420affdc10a43a8~mv2.png)
API: Pages #each , Pages #erase , Layer #name , Page #name
![](https://static.wixstatic.com/media/a27d24_110ed55b78804e2cbd4808d0d58fd77f~mv2.png/v1/fill/w_896,h_26,al_c,q_85,enc_avif,quality_auto/a27d24_110ed55b78804e2cbd4808d0d58fd77f~mv2.png)
API: Pages #add , Layer #name
![](https://static.wixstatic.com/media/a27d24_88d23f9ba7c14318920e102a6b3f7d41~mv2.png/v1/fill/w_896,h_26,al_c,q_85,enc_avif,quality_auto/a27d24_88d23f9ba7c14318920e102a6b3f7d41~mv2.png)
![](https://static.wixstatic.com/media/a27d24_4ad6c04ded1f4e3582d4307f8f03fa56~mv2.png/v1/fill/w_896,h_24,al_c,q_85,enc_avif,quality_auto/a27d24_4ad6c04ded1f4e3582d4307f8f03fa56~mv2.png)
API: Pages #selected_page , Page #update
![](https://static.wixstatic.com/media/a27d24_6d073c5f8eee47c48e027abdda15033f~mv2.png/v1/fill/w_896,h_26,al_c,q_85,enc_avif,quality_auto/a27d24_6d073c5f8eee47c48e027abdda15033f~mv2.png)
Finished!
I hope this tutorial was useful and helped you see that making tools for SketchUp can be easier than you initially thought. There is still more ground to cover so please subscribe to the website to receive email notifications about updates, tutorials, deals and much more. Also, tell me if you have an idea for a script you want me to try to solve together. See you next time for my next blog post tutorial!
Comments