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ā€¦

john

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

thnx


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 ?
[/quote]

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}
end
sel.add(common_edges.entries)

john

2 Likes

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.

thnx

NOā€¦
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ā€¦

john

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.