Divide a 3D model into sub models

Hello everyone,

How can i divide this model into multiple sub-models so that i can calculate the volume of each sub-model and calculate the total volume of the entire 3D model ?

Does anyone have an idea how can i do it ?

thnx in advance

No one can answer this question without the model. We do not know what are made of primitives and what are groups. Or what are nested groups.

1 Like

the entire model is directly drawn there is no groups nor nested group i just draw cubes using the rectangular tool of sketchup

something like that:
tst faces and baies.skp (180.4 KB)

You need to generate 3 different solids (groups or components ) to have the volume.If you have a lot of those boxes than you can do it with the plugin that has the tool to divide them with one click and make them solid with volume.

1 Like

I need to do it automatically without clicking on the model, which mean i need to have a sub-menu in the extensions menu of sketchup and when i click on it it should show the entire model’s volume.

so dividing the model into manifold groups should happen automatically.

how can i do that i mean detect that there is 3 or 4 or… manifold groups in the model and divide it into 3 or 4 or… sub-groups and get the volume of each one of them ?

You can do it automatically with susolid plugin without clicking the model. Then the number of manifold groups will be in counter.Then you can assign the density 1 to all groups.Then you can see all the volumens (or weight) at once.

1 Like

this susolid plugin is not free right ? i found a purchase button ? because unfortunately i don’t have the possibility to buy a plugin

it will be great if you can give me a code example on how to use this susolid in a ruby api code.

and thank you sooo much for your answers.

Susolid plugin is free for checking the model,but not for other functions.And it is not possible to use it from ruby api code.
Good luck :slight_smile:

1 Like

how can i use it then ? as i’m creating a Sketchup extension using Ruby Sketchup API ?

You have to loop every entity in the model,detect the common faces,loop every entity attached to the common face,copy the common face,create new groups for every group of attached entities to common face,paste the common face to every new created group.This is the first part.Other is easy,just read the volume property and wright it on the corner of the group bounding box.You should do it in a custom tool.
Hope this helps.

1 Like

oky thnx i’ll try this method

what do you mean by “detect the common faces” is it detect what are the entities that represents a face ? like :

entities.each do |e|
if e.is_a? Sketchup::Face

and how can i loop every entity attached to the common face ?
i’m still a beginner in Ruby API programing .
thnx a lot

what your trying to do requires very advanced ruby methods, which is why plugins like @malnardavid’s cost money…

If you think of how you would split your example model manually, you can then try to replicate that using ruby…

the key is finding how many Faces each Edge has, if it’s more than two, you need to deal with that…

manually, can can use a Left to Right selection that includes the ‘shared edge’ to group the 3 individual cubes, in ruby it’s far more complex…

learning how to create your object as 3 separate groups using ruby would give you a better understanding of how to fix these issues…


thnx for your answer.

i didn’t realy understand this part :

can use a Left to Right selection that includes the ‘shared edge’ to
group the 3 individual cubes, in ruby it’s far more complex…

do you have an idea how to divide this model using only ruby ? is it possible to explain it ? as i’ve been trying the common faces thing but it’s not working


when doing this manually SU provides some ‘extra tricks’ that allows you to use the ‘common’ edge in two different groups…

in ruby you need to find all those ‘common/shared’ edges + workout which of the edge.faces should belong to each of the potentially solid ‘new’ groups…

Ruby doesn’t have a Left to Right selection method, so you need to write code that figures that out for you…[quote=“MR_ME, post:15, topic:22876”]
do you have an idea how to divide this model using only ruby ?

Yes, but this is a very simple model and the simple code needed for it would most likely fail in other models …

I’ve been trying to, but I’m not going to write all the code for you…
as a starting point on my simple example this finds the shared edges…

model = Sketchup.active_model
ents = model.entities
sel = model.selection
common_edges = Set.new()
faces = ents.grep(Sketchup::Face) do |f|
f.edges.each{|e| common_edges.add(e) if e.faces.length > 2}



thank you for your answer.

Do you mean by manually selecting cubes from Sketchup model ? as i need to divide the model into manifold sub-models automatically using ruby api without clicking on the model.


the code will run even on your posted model without any pre-selection in SU viewport…

but, it is only one small part of a potential solution…

if you don’t understand the relationship of faces, edges, groups, component instances, you will never achieve your goal…

I think you need to try some really basic plugin writing, before moving forward…

finding intersections using ruby is very advanced and most of it is beyond my natural comprehension…

by comparison, this one that I’m writing is easy…

I am only adding it because it shows how ruby needs to check everything, every time…


1 Like

You may regard this reply as unhelpful, but I feel compelled to write because I think you have set yourself an unnecessarily difficult challenge.

I have to ask why you lumped all the raw geometry into one tangle that you now have to sort out, instead of creating it as discrete groups or components in the first place? Unless the model was created outside SketchUp and imported, there is no reason to generate it that way, even from Ruby code. With only a small amount of extra effort you can create groups or components via Ruby code.

As John has already illustrated, it is fairly easy for a human to apply judgement and select a bunch of geometry in the GUI that in their mind constitutes a single “object”. However, the frequent topics here about difficulties getting models to 3D print shows that even humans struggle with the concepts involved with creating valid “manifold solids” in SketchUp.

It is much harder for software to automate this task, especially since SketchUp inherently shares vertices, edges, and faces wherever two sets touch. I fear you will enter a rat’s nest of special cases and exceptions, and it will be very hard to get it to work reliably.

1 Like

Yes i agree with you but the project i’m working on is like this, getting the volume is only a small part of it so i’m not the one creating the models, that’s why i’m kinda forced to work with what i have wich is those kind of models without groups and components, and i need to get the volume of any model even ones like the one i shared and it should all be automatically without clicking on the model…

That’s why i’m asking you guys as you are more experienced than i am as it’s my first time using sketchup API and i don’t have that much time to start from simple scripting … as i already managed to get faces’ orientations, tilt, areas … i still need only the volume but i got stuck in the case of the model that i shared.

So even if there is some plugins for that plz feel free to share it with, as any help/advice will be highly appreciated.
thanks for all your answers.