Hello, I need to perform trimming operation only on groups which are intersecting with a specific group. But for that, first, I need to detect those groups.
I tried to do something like this:
external_group_bounds = external_group.bounds
It did not work, I guess why, because group boxes is fully contained in another
So, I want to trim only groups which are touching the object itself.
In my case groups which touching the object will be those:
I also thought to detect these faces from middle and to check if a certain group is intersecting with one of them. If so, it should be trimmed.
Selected faces to detect which are intersected with groups:
Could you help me with an approach to deal with that problem?
Thank you in advance for your help!
Why would you want to do this ? It will create a huge model file with little benefit.
As said before, it is recommended to use a material texture to represent roof tiling.
The SketchUp API has no “collision detection” feature.
I know, roof tiling wilth 3d objects will create bigger model file, but in team where I am now, sketchup desigers for some projects use this type of roofing.But the group objects for roofing are not unique, I mean if I change one, it will change others, and so they don’t use so much system resources, and they are trimming just roof tiles that are on edges of roof. And I was searching for a method to trim just tiles on edges.
Each tile instance “on an edge” must be trimmed uniquely, and that means it must be made unique, which means it will bloat the file with a unique definition (that has an unique geometric entities collection.)
AGAIN … you are not answering the question:
WHY do you think that you must model each and every roof tile ?
I guess it’s far from perfect, but this solution resolved my problem, and I hope it could be like an idea for someone with similar problem. What I did I just made a group with a face shaped like the hole and put it above and with raytest method I detected tiles on the edges and tiles outside of the edges and trimmed just them, and if tile is outside the edges I also delete it. A screen of what I did:
was_deleted = false
bounds = group.bounds
points = [bounds.corner(4),bounds.corner(5),bounds.corner(6),bounds.corner(7)]
corners_count = 0
for i in 0..points.length() - 1
virtual_line = Z_AXIS
points[i].z = points[i].z + 120.mm
ray = [ points[i], virtual_line ]
item = model.raytest(ray, true)
temp = nil
if check_if_has_group(above_group, item)
corners_count += 1
if corners_count != 4 && !was_deleted
temp = external_group.trim(group)
if corners_count == 0 && temp.volume > 226 #this is the volume for non-trimmed object just for this particular tile
def check_if_has_group(group, item)
item.each do |i|
founded = check_if_has_group(group, i)
elsif item == group
And that are the results:
I’m sorry, I don’t know if I understood completly the question. I’m trying to trim just tiles on edges, like it do sketchup designers manually, i’m trying to reproduce what they do. If I trim all tiles, the result will be okay, but all tiles will be unique and that will bloat the file very hard, like you said.
The point is, that other designers do not do this. They do not use components for many little things like roof tiles.
They just use a material texture and “paint” roof surfaces with images that “look” like tiles.
Anyway … I believe this is a waste time and diskspace. (I’ve muted this topic.)
Oh, I get what you say and I understood why it’s uncommon to use this type of roofing. Anyway, thanks for your replies!
Maybe following code can help you for better solution.
tr_tail = tail_grp.transformation
tail_ents = tail_grp.entites
int_arr = tail_ents.intersect_with(false, tr_tail, tail_ents, tr_tail, false, [main_grp])
int_arr.size can show you how two groups have intersection. I hope it can help you…