How to get face which is belong to two group
-
there are two groups .i wanna to get the face ,which is belong to two groups.just like two walls,there is a face which can be think to belong any wall.
as the picture.
how can i can get the face?
thanks
![[7DSPY@EF_WPWXB8)3XSO8.jpg
-
If there is one face (in one of the groups) or if there are two faces (one in each group) depends on the way you created the groups. You can always enter one group, copy the face to the clipboard and paste (in place) it outside those groups to get a single face independent of the groups.
-
Almost the same answer as Cotty above (posted while I was typing):
Think of a group as a container or a room in a house. An object can't be in two containers / rooms at the same time - it can only be in one container / room / group at the same time.
So, you have several options:
- make a copy of 'the face' and put them in both groups
- make an extra third group and put 'the face' in it. Now it doesn't belong to either groups but is a unique group itself.
3)...
The best choice depends on what you're trying to achieve.
-
@cotty said:
If there is one face (in one of the groups) or if there are two faces (one in each group) depends on the way you created the groups. You can always enter one group, copy the face to the clipboard and paste (in place) it outside those groups to get a single face independent of the groups.
i think i don't explain it clearly. there are two faces (one in each group),as you say. and when i explode two groups,i can get 11 faces which 1 face is delete.
i wanna use api to get this face in groupA which in groupB also has this face .i mean they are occupy same region.but they are different.
can i do it by judge face's vertices position or some other ways? -
@youngosg said:
i wanna use api to get this face
So this is a ruby question? I've moved this topic...
-
Get
tr1=group1.transformation tr2=group2.transformation
You need those th apply to things later...
The two 'coincident' faces in question will have some similar properties [when adjusted for their container's transformation].
You need to iterate the faces in group1 to get a suitable in group2faces1=group1.entities.grep(Sketchup;;Face) faces2=group2.entities.grep(Sketchup;;Face) face2=nil face1=nil faces1.each{|face| min=face.bounds.min.transform(tr1) max=face.bounds.max.transform(tr1) norm=face.normal.max.transform(tr1) faces2.each{|f| if f.bounds.min.transform(tr2)==min && f.bounds.max.transform(tr2)==max && f.normal.transform(tr2)==norm.reverse face2=f face1=face break end } break if face2 } ### face2 is the matching face in group2, if not nil ! Delete it ! ### face1 is the matching face in group1
This is NOT foolproof.
BUT you can add extra tests...
For example... collect the loops of face2, collect their vertices as points and transform them, then compare with the loop-vertices-points-transformed of face1, if there are any mismatches then the two faces are NOT completely coincident - e.g. one of the otherwise coincident could have a side-notch or a hole in it, but still have the same normal and bounds !
You need to make these decisions... Simple boxes ? -
@tig said:
Get
tr1=group1.transformation > tr2=group2.transformation
You need those th apply to things later...
The two 'coincident' faces in question will have some similar properties [when adjusted for their container's transformation].
You need to iterate the faces in group1 to get a suitable in group2faces1=group1.entities.grep(Sketchup;;Face) > faces2=group2.entities.grep(Sketchup;;Face) > face2=nil > face1=nil > faces1.each{|face| > min=face.bounds.min.transform(tr1) > max=face.bounds.max.transform(tr1) > norm=face.normal.max.transform(tr1) > faces2.each{|f| > if f.bounds.min.transform(tr2)==min && f.bounds.max.transform(tr2)==max && f.normal.transform(tr2)==norm.reverse > face2=f > face1=face > break > end > } > break if face2 > } > ### face2 is the matching face in group2, if not nil ! Delete it ! > ### face1 is the matching face in group1
This is NOT foolproof.
BUT you can add extra tests...
For example... collect the loops of face2, collect their vertices as points and transform them, then compare with the loop-vertices-points-transformed of face1, if there are any mismatches then the two faces are NOT completely coincident - e.g. one of the otherwise coincident could have a side-notch or a hole in it, but still have the same normal and bounds !
You need to make these decisions... Simple boxes ?thanks! you always be the super star
-
@tig said:
Get
tr1=group1.transformation > tr2=group2.transformation
You need those th apply to things later...
The two 'coincident' faces in question will have some similar properties [when adjusted for their container's transformation].
You need to iterate the faces in group1 to get a suitable in group2faces1=group1.entities.grep(Sketchup;;Face) > faces2=group2.entities.grep(Sketchup;;Face) > face2=nil > face1=nil > faces1.each{|face| > min=face.bounds.min.transform(tr1) > max=face.bounds.max.transform(tr1) > norm=face.normal.max.transform(tr1) > faces2.each{|f| > if f.bounds.min.transform(tr2)==min && f.bounds.max.transform(tr2)==max && f.normal.transform(tr2)==norm.reverse > face2=f > face1=face > break > end > } > break if face2 > } > ### face2 is the matching face in group2, if not nil ! Delete it ! > ### face1 is the matching face in group1
This is NOT foolproof.
BUT you can add extra tests...
For example... collect the loops of face2, collect their vertices as points and transform them, then compare with the loop-vertices-points-transformed of face1, if there are any mismatches then the two faces are NOT completely coincident - e.g. one of the otherwise coincident could have a side-notch or a hole in it, but still have the same normal and bounds !
You need to make these decisions... Simple boxes ?one more question.if there are many groups,how can i get the groupA which is adjacent with groupB.
i intend to judge by distance.is there any easy way to do this? -
Try the groups' .bounds if they 'touch', then some_group.bounds.max.x OR .y OR .z and some_other_group.bounds.min.x OR .y OR .z might be coincident ??
Especially if the are simple boxes...
Advertisement