# Open Cutlist Extension - Using Ruby Code

**URL:** <https://forums.sketchup.com/t/open-cutlist-extension-using-ruby-code/230315>\
**Category:** Extensions\
**Tags:** mac, ruby, beginner, opencutlist\
**Created:** [May 17, 2023, 3:05am UTC](https://forums.sketchup.com/t/open-cutlist-extension-using-ruby-code/230315 "2023-05-17T03:05:32Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![mattstrobel1](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/mattstrobel1/32/180238_2.png) [@mattstrobel1](https://forums.sketchup.com/u/mattstrobel1)\
**Post date:** [May 17, 2023, 3:05am UTC](https://forums.sketchup.com/t/open-cutlist-extension-using-ruby-code/230315/1 "2023-05-17T03:05:32Z")

</div>

Hey folks!

Complete noob at ruby code. Like so new that I just heard the phrase for the first time like 3 days ago.

I work at a custom furniture shop and I’m trying to overhaul our design and pricing process. I’ve opted to use Open Cutlist as a tool to help us quickly generate lots of projects data. We’re currently using spreadsheets to price things and that just doesn’t make sense to me since were drawing it all in the first place. The data is all there already, no need to do extra work!?

Anyway, I don’t know anything about coding in general, I don’t even know if this is considered ‘coding’. My tech friends would probably laugh at me with how simple this probably is. Here’s what I’m trying to do:

I need to find out what the ruby code would be for calculating BDFT price. I know there are ways to make your own custom badges and apply them to the summary but I also want it on the parts list. Can someone help me please?

---

<div class="post-metadata">

**Author:** ![3DxJFD](https://avatars.discourse-cdn.com/v4/letter/3/f07891/32.png) [@3DxJFD](https://forums.sketchup.com/u/3DxJFD)\
**Post date:** [May 17, 2023, 8:03am UTC](https://forums.sketchup.com/t/open-cutlist-extension-using-ruby-code/230315/3 "2023-05-17T08:03:52Z")

</div>

It seems like there should be an “@price” option in the formulas. This might work but you’d have to change the price variable all of the time:

```auto
price = 2
length= @bbox_length
width = @bbox_width
thickness = @bbox_thickness
  
volume = length * width * thickness

BRFT = volume * 12

BRFT * price

```

I did have an error with the materials so maybe price does show up when materials are working.

Dynamic Components seem to be able to do it and export it.

---

<div class="post-metadata">

**Author:** ![pcmoor](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/pcmoor/32/3427_2.png) [@pcmoor](https://forums.sketchup.com/u/pcmoor)\
**Post date:** [May 17, 2023, 10:54am UTC](https://forums.sketchup.com/t/open-cutlist-extension-using-ruby-code/230315/4 "2023-05-17T10:54:08Z")

</div>

> [@mattstrobel1](#):
>
> BDFT

do you use dimensional material to get the BDFT?

[summary.skp](https://forums.sketchup.com/uploads/short-url/mP920oluw681ZkfVFm1RrJM8BXU.skp) (44.8 KB)

one can add the price in the material-  
[summary2.skp](https://forums.sketchup.com/uploads/short-url/cxhq35QIt353XFyhgFseCcnHR0X.skp) (60.7 KB)  
and get an estimate

@boris.beaulant  
I am having trouble getting result to be dollars when I try to use ruby in the summary report

---

<div class="post-metadata">

**Author:** ![boris.beaulant](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/boris.beaulant/32/31562_2.png) [@boris.beaulant](https://forums.sketchup.com/u/boris.beaulant)\
**Post date:** [May 17, 2023, 11:16am UTC](https://forums.sketchup.com/t/open-cutlist-extension-using-ruby-code/230315/5 "2023-05-17T11:16:57Z")

</div>

> [@pcmoor](#):
>
> I am having trouble getting result to be dollars when I try to use ruby in the summary report

`@total_cutting_length` is a Length. If you multiply it by a float it stays a length that by default output as its string representation according to the model unit. To transform it into a number, you need to do :

- `@total_cutting_length.to_f` (and you get a float in inches)
- `@total_cutting_length.to_feet` (and you get a float in feet)

 ![Capture d’écran 2023-05-17 à 13.13.35](https://global.discourse-cdn.com/sketchup/original/3X/8/6/86e2a16435069307c93aa10a18a69aac9866985d.png)

---

<div class="post-metadata">

**Author:** ![boris.beaulant](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/boris.beaulant/32/31562_2.png) [@boris.beaulant](https://forums.sketchup.com/u/boris.beaulant)\
**Post date:** [May 17, 2023, 11:38am UTC](https://forums.sketchup.com/t/open-cutlist-extension-using-ruby-code/230315/6 "2023-05-17T11:38:25Z")

</div>

@mattstrobel1 what is a BDFT price ?

Solid wood material offers $/FBM unit to set price. Is this what you need ?

 ![Capture d’écran 2023-05-17 à 13.36.29](https://global.discourse-cdn.com/sketchup/original/3X/e/b/ebfd13834af3d1e7a549ef2173066b6580dda62c.jpeg)

And then use it in **Estimate**.

 ![Capture d’écran 2023-05-17 à 14.58.58](https://global.discourse-cdn.com/sketchup/original/3X/f/2/f23358cc67e86a1bb20551fd1007741ceb6101ce.jpeg)

---

<div class="post-metadata">

**Author:** ![mattstrobel1](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/mattstrobel1/32/180238_2.png) [@mattstrobel1](https://forums.sketchup.com/u/mattstrobel1)\
**Post date:** [May 17, 2023, 3:20pm UTC](https://forums.sketchup.com/t/open-cutlist-extension-using-ruby-code/230315/7 "2023-05-17T15:20:42Z")

</div>

> [@boris.beaulant](#):
>
> @total\_cutting\_length.to\_f

I’m in the parts list, I’m getting what I need in the summary. I probably should have said that first, my bad!

- I’m trying to get a breakdown of individual part price, & total part price. I’m using the dimensional material because I have plywood, steel tubing & solid wood.

---

<div class="post-metadata">

**Author:** ![boris.beaulant](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/boris.beaulant/32/31562_2.png) [@boris.beaulant](https://forums.sketchup.com/u/boris.beaulant)\
**Post date:** [May 18, 2023, 2:27pm UTC](https://forums.sketchup.com/t/open-cutlist-extension-using-ruby-code/230315/8 "2023-05-18T14:27:46Z")

</div>

> [@3DxJFD](#):
>
> It seems like there should be an “@price” option in the formulas.

Adding a “price” variable in part list is **not** possible for _Sheet Good_ or _Dimensional_ parts **without** computing cutting diagram because multiple prices can be defined on material for specific **full sheet size** and thickness.

That’s why we add the specific Estimate (formerly Report) module that do this job. But yes it doesn’t display the price of each part.

---

<div class="post-metadata">

**Author:** ![3DxJFD](https://avatars.discourse-cdn.com/v4/letter/3/f07891/32.png) [@3DxJFD](https://forums.sketchup.com/u/3DxJFD)\
**Post date:** [May 18, 2023, 3:37pm UTC](https://forums.sketchup.com/t/open-cutlist-extension-using-ruby-code/230315/9 "2023-05-18T15:37:36Z")

</div>

That was the first time I tried using OCL. Even though I wasn’t familiar with BRFT or the software and had an error pop up about materials, it was easy to use and see just how plain nice OCL is. I also saw some of the options you mentioned above for creating estimates. I’m sure I didn’t pay close attention when I quickly added a material and that’s why I had an error.

I have a couple of projects that will provide opportunities to put OCL to use in the near future. I’m looking forward to getting to know the how to use it better then 🙂

Thanks for your reply.

---

<div class="post-metadata">

**Author:** ![boris.beaulant](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/boris.beaulant/32/31562_2.png) [@boris.beaulant](https://forums.sketchup.com/u/boris.beaulant)\
**Post date:** [May 18, 2023, 3:51pm UTC](https://forums.sketchup.com/t/open-cutlist-extension-using-ruby-code/230315/10 "2023-05-18T15:51:20Z")

</div>

> [@3DxJFD](#):
>
> and had an error pop up about materials

Do you remember what was this error ?

> [@3DxJFD](#):
>
> I’m looking forward to getting to know the how to use it better then

😉

---

<div class="post-metadata">

**Author:** ![boris.beaulant](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/boris.beaulant/32/31562_2.png) [@boris.beaulant](https://forums.sketchup.com/u/boris.beaulant)\
**Post date:** [May 18, 2023, 3:59pm UTC](https://forums.sketchup.com/t/open-cutlist-extension-using-ruby-code/230315/11 "2023-05-18T15:59:10Z")

</div>

> [@mattstrobel1](#):
>
> I’m trying to get a breakdown of individual part price, & total part price.

Currently, it’s not impossible, but it will be a big tweak to compute individual part price in part list export. Because parts list merge all type of material, and I suppose that each type doesn’t have the same “volumic price”.

And as said before, export can’t extract price defined on each material without determining first the raw material size.

---

<div class="post-metadata">

**Author:** ![3DxJFD](https://avatars.discourse-cdn.com/v4/letter/3/f07891/32.png) [@3DxJFD](https://forums.sketchup.com/u/3DxJFD)\
**Post date:** [May 18, 2023, 4:08pm UTC](https://forums.sketchup.com/t/open-cutlist-extension-using-ruby-code/230315/12 "2023-05-18T16:08:56Z")

</div>

I quickly re-created it:

 ![Oak Material error](https://global.discourse-cdn.com/sketchup/original/3X/4/1/415462afe18d69cad007f8faa80760871f8a0bad.png)  
 ![Oak Dimensional error](https://global.discourse-cdn.com/sketchup/original/3X/7/2/7219fcd3a4c2984f752d2a4fb44ff2dfd3fadf1e.png)

I basically followed what was a very easy and intuitive process to create a “Oak” material for a “2x4” component I made in SU (no materials). I selected “dimensional” because that seemed correct.

I was basically trying to test Ruby in the export options. Since I couldn’t quite do it, I started looking at the estimate options looking for an easier way and that’s why I made the material (if I recall, Estimate is not available without materials). It looks like user error since I didn’t fill in any other options.

---

<div class="post-metadata">

**Author:** ![boris.beaulant](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/boris.beaulant/32/31562_2.png) [@boris.beaulant](https://forums.sketchup.com/u/boris.beaulant)\
**Post date:** [May 18, 2023, 4:30pm UTC](https://forums.sketchup.com/t/open-cutlist-extension-using-ruby-code/230315/13 "2023-05-18T16:30:56Z")

</div>

Ok 🙂

Estimate, run in background the “cutting diagram” feature for each group of part to select the good price. In your case the parts list group **Oak / 3 1/2" x 1 1/2"**.

Cutting diagram uses the standard length you defined in cutting diagram parameters (or the first default one if you never configure anything).

 ![Capture d’écran 2023-05-18 à 18.25.17](https://global.discourse-cdn.com/sketchup/original/3X/d/7/d7a9c4ffa5c8094e570657fef923e2f64bfa9179.png)

Estimate reuse those parameters.

Then in your case the default standard length is just **to small to contains your part**.

Standard lengths are configured on the material :

 ![Capture d’écran 2023-05-18 à 18.26.15](https://global.discourse-cdn.com/sketchup/original/3X/b/9/b9a5a989e0c117badfd7df600e10e763ced94f70.jpeg)

And prices could be set for each section / length

 ![Capture d’écran 2023-05-18 à 18.27.55](https://global.discourse-cdn.com/sketchup/original/3X/3/b/3b28ec576d146de02598f93522b25f924a8f651a.png)

---

<div class="post-metadata">

**Author:** ![3DxJFD](https://avatars.discourse-cdn.com/v4/letter/3/f07891/32.png) [@3DxJFD](https://forums.sketchup.com/u/3DxJFD)\
**Post date:** [May 18, 2023, 4:53pm UTC](https://forums.sketchup.com/t/open-cutlist-extension-using-ruby-code/230315/14 "2023-05-18T16:53:30Z")

</div>

\*I need to do a site visit to get measurements. The job will be a deck renovation. It should be a simple job and a good test case to get in and use SU and OCL. I’ve not been one to use a lot of (or any) materials in SU. I saw that the material I created in OCL was applied to the component in the model. Because it was easy 🙂 and I like the OCL user interface I might be able to improve in the materials department with OCL too.

Anyway, I’ll create proper project and get squared away with materials and sizes… it looks like it’s just a couple of button presses away :).

---

<div class="post-metadata">

**Author:** ![mattstrobel1](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/mattstrobel1/32/180238_2.png) [@mattstrobel1](https://forums.sketchup.com/u/mattstrobel1)\
**Post date:** [May 19, 2023, 4:22am UTC](https://forums.sketchup.com/t/open-cutlist-extension-using-ruby-code/230315/15 "2023-05-19T04:22:14Z")

</div>

Thanks for your detailed help! I have reconfigured things in a way that makes more sense for what I’m trying to do. And I’ve learned some ruby code along the way! Much appreciated!
