Individual group individual faces

Hi Everyone,
I’m fairly new to Sketchup, and am trying to help some Interior Design Students export from Sketchup as a FBX and then open the files in Unreal Engine.
I need to be able to batch select all individual faces in a model, and make them into individual groups: 1 face=1group.

I have been selecting each face, and making it a group by hand; but this takes ages!

Is there an easy way/script to do this?
Thanks in advance!
Regards
Aidan

Select all of the geometry [faces] you want processing.
Anything that’s not a face is ignored, so you don’t need to be too careful.
Copy+paste all of this code into the Ruby Console + enter.
Each face is made into a group.
It’s one-step undo-able.

m=Sketchup.active_model;a=m.active_entities;m.start_operation('f2g',true);c=0;m.selection.grep(Sketchup::Face).each{|f|a.add_group(f);c+=1};m.commit_operation;puts "Made #{c} face groups";

1 Like

Thankyou very much Tig, I will give this a try now :slight_smile:

Hi Tig,
It worked perfectly! Thankyou very much!
Is there a way to turn that code into a button that I can use from within sketchup?
I can imagine that they would miss parts of the code etc if I just gave them a copy and paste solution!

Thankyou

Step 1 is to run the code in the Console as you have already done.

Step 2 could be saving the snippet in a text file with the extension being .rb (ruby) and load it by entering “load ‘the path to the file’” in the console.

Step 3 is to create a plugin. For this the functionality of the code needs to be wrapped in a method that can be run at any given time, not just immediately when the script is loaded. Then you can create a button using the Toolbar class (Class: UI::Toolbar — SketchUp Ruby API Documentation) to run the method once the button is being pressed. Place this text file in the plugin directory for it to be loaded when SketchUp starts.

Step 4 is to wrap the plugin into an Extension (Class: SketchupExtension — SketchUp Ruby API Documentation).

When finishing step 4 you have become a SketchUp extension developer!

1 Like

Thanks Eneroth3,
I didn’t realise I could just change the extension to make the .rb file.
I used the toolbar editor plugin to make a button, but I will follow your guide, as I think that it makes more sense.

I like the idea of being a sketchup extension developer, but without people like yourself, and TIG, I doubt I would stand a chance!
I’ll give it a go over the next few days, and report back.
Thankyou

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.