Looking for a plugin to break apart all components from wooden structure and place them side by side

I did it the old fashion way. If you’d have named your components with lengths too, you could have gotten all your information from the generate report function. Woodshed.skp (2.0 MB)

Woodshed

This is great - really useful, thanks to all involved.
I’ve been trying to edit this code to copy all the components, so I’ve still got the original model available. Can anyone point me in the right direction?

This looks great, it seems to solve a problem I also have, but how is this code used. Where do I copy it to and how ? Could someone kindly explain this to me. Thanks in advanced.

Cut and Paste code into Ruby Console. Enter.

Or copy the code into a text editor and save it to a file with the extension .rb, in a subfolder in the SketchUp Plugins folder.

Then in the Ruby Console, type

load “file subfolder/filename.rb”

to run the code.

Replace subfolder and filename by what you named the subfolder and file.

1 Like

you can attach code snippets to a button with an icon of your choice or making

Toolbar Editor | SketchUp Extension Warehouse

1 Like

Here is how I followed the suggestion by @john_mcclenahan:

Here is how I followed the @pcmoor suggestion.

You need to get Toolbar Editor from the Extension Warehouse. It’s shown open in the video. The toolbar is created. SU is re-opened.

1 Like

Wow, this is brilliant !. I have used sketchup for over 10 years, but never done anything to do with coding. very clever. I also wonder if there is anyway to amend the coding to only break apart selected components or to not break apart locked components.

Find the line
cdn = ent.grep(Sketchup::ComponentInstance).map{|ci|ci.definition.name}.uniq.sort

change it to
cdn = sel.grep(Sketchup::ComponentInstance).map{|ci|ci.definition.name}.uniq.sort
to process the selected instances only, instead of the active entities

or change it to
cdn = sel.grep(Sketchup::ComponentInstance).map{|ci|ci.definition.name unless ci.locked?}.uniq.sort
to skip processing any locked instances…

2 Likes

@david_hashimoto

Here is an example of @TIG’s code used in Toolbar Editor.

The setup was to create icons and put them into an icons folder inside of the Toolbar Editor folder. These will show in the Take Apart Toolbar.

Then each of TIG’s examples was cut ‘n’ pasted into Notepad++. A “#” was used to comment on each additional line of code, and also to comment out the unused code (only one was used at a time).

Each button was created before the video and an icon added to it. The buttons are each edited with the desired code being cut ‘n’ pasted into the code field and then saved there.

Hi sdmitch,
I’ve been using this code snippet for a 18 months now with great success. Firstly, can I thank you for coming up with this, it’s been extremely useful and has shaved a great deal of time off my work method.

I’ve a question, In addition to what is intended (flattening, arranging etc), this code appears to reset the scale of any component(s) it encounters. So for example, often I will have two identical parts but I have mirror scaled one of them, ie pulled it through itself by a factor of -1 using the scale tool. As you would know this creates an exact mirrored copy of the part. When I select both parts and apply your script, the mirrored part reverts to the original state, ie not mirrored.

I’ve inspected and removed particular lines of the script to see if this is an actual executed action. No success so far.

Any insights? Many thanks again.

1 Like

@Early_Hominid have you found any solution?
I’ve got same results - mirrored parts become identical.
@sdmitch can you please elaborate on the topic? In particular what code command leads to component axes change?

Continuing the discussion from Looking for a plugin to break apart all components from wooden structure and place them side by side:

In short, I believe something in the Ruby Class: Geom ‘transformations’ resets the scale. That is my reading of the literature anyway.

…this script reached a dead end, unfortunately.

I was primarily using it to lay out parts with a common orientation for CNC cutting birch plywood. I could then do a basic nest etc. Vectric CAM software’s SKP import feature used to be ‘buggy’ and if there were any parts in the SketchUp model set ‘off axis’ then the resulting imported part would be distorted in Vectric and would show incorrect dimensions. When I say ‘off axis’ I mean any part which is not set perpendicular to either the X,Y or Z axis. ie; set 30 degrees etc. The solution was to lay out all the parts flat and it would import correctly. Hence, the script.

The other requirement for this script is the component axis for each part needs to be set correctly. That is, the Z axis of the part is set perpendicular to the face to be cut. For this I use Thom Thom’s Axes Tools and set set a keyboard shortcut to execute quickly.

These days, as of Vectric v 11.55, I can keep the all the parts in their assembled positions within the 3D model regardless of orientation and they will import correctly into the Vectric CAM software. Hooray!

I still use this script to flatten and then explode all the parts so I can get a rough perimeter CNC cutting estimation (metres cut) using @thomthom’s selection toys. Namely, the ‘select only edges’ tool. For this purpose, reversed or reset scale parts don’t matter for obvious reasons.

If you tell me a bit about why you need to layout a whole lot of components flat in a row, there may be another solution…cheers.

1 Like

Thank you for such a thorough reply! I am outsourcing CNC cutting of birch ply, the guys need DXF or CDR files. The model is made with the help of OpenCutList, plugin devs are going to implement DXF export in next version, but I can’t wait for the release. So my aim was to lay all the parts flat an then export them, I was rather surprised that there’s no ready solution for that and now it seems that making that manually is the only reasonable solution.

Enroth’s new Laser Tool Extension seems very promising for this type of work maybe?

There are already similar topics here on the forum. Maybe you will be interested. Here is an example @ DanRathbun: [Example] Lay a set of Selected Instances In a Row Along X axis

You can also take a look at the ABF plugin (it’s free). It has direct good export to dxf. https://www.getabf.net/

There are already similar topics here on the forum. Maybe you will be interested. Here is an example @ DanRathbun: [Example] Lay a set of Selected Instances In a Row Along X axis

Actually, I prompted @DanRathbun to revise this script (or come up with his own) for the sole reason that it resets the scale of all components to which it is applied. Dan was kind enough to have a good go at revising the code and the result is linked above. Alas, his version doesn’t resolve the issue either.

Here is the original thread which Dan responded to.

Enroth’s new Laser Tool Extension seems very promising for this type of work maybe?

I’ve just done some testing using the ‘unfold components’ command in @eneroth3’s Laser Tools plug in. While it does a great job laying components out flat in a nice neat row, It too will reset the scale of any selected components! Perhaps Christina could chime in on this. I’m sure there is a solution.

Just to reiterate here: Any component which has an inverse scale, ie; scale tool applied by a factor of -1, the scale will be reset either by Laser Tools ‘unfold components’ or the code snippet contained in this thread.

Yes. I see your problem. The first thing I would do is ask your CNC workshop if they use any of the CAM software from the Vectric Suite (Cut 2D Pro/VCarve/Aspire).

If the answer is yes, then you can utilise Vectric’s very powerful vector import function which will directly import SketchUp files. In other words, you would simply provide the CNC workshop with a SketchUp file.
You have to structure your SketchUp models in an unorthodox manner and there is a bit of a learning curve associated. Dig into this thread and it should get you going.

If not, then, short of manually arranging your parts in a nice row, you are stuck using this script in order to create your DWG/DXF output file. You might like to try the following tip though:

  1. Go through your assembled model and locate any inverted components.
  2. Paint just the inverted ones a wild colour like bright orange.
  3. Execute your script to layout the components. (noting all the components scales have been reset).
  4. Simply go through and re-invert the bright orange ones.

Crude, I know, but this should only take a minute or two and is preferable to the manual layout method!

1 Like

Regarding the -1 scaling issue - I overcame this with timber components (valley, hips, jack rafters) by mirroring the components instead of -1 scale. -1 scale (or any scaling at all) was throwing off the estimating lists and eventually the export for some forms used by clients with CNC.