How to break faces?

sketchup

#1

I write code to create two faces(copy & run in the builtin ruby console):

entities = Sketchup.active_model.entities

# create a red face
red_face = entities.add_face [
  [0,0,0],
  [0,10,0],
  [10,10,0],
  [10,0,0]
]
red_face.back_material = 'red'

# create a blue face
blue_face = entities.add_face([
  [5,5,0],
  [5,15,0],
  [15,15,0],
  [15,5,0]
])
blue_face.back_material = 'blue'
# TODO: break the intersection face

then the view is:

How to break the intersection face?


#2

You can try:
group = entities.add_group(blue_face)
group.explode


#3

Use Entities.intersect_with: http://ruby.sketchup.com/Sketchup/Entities.html#intersect_with-instance_method

If you create a group with entities, its much more efficient to create the group first and then add the geometry into it. Optimal way of creating groups via the API is different than from the UI.


#4

Also note that add_group with parameters can produce crashes and other unexpected behavior if those entities aren’t in the active drawing context. I would advise to only use add_group with parameters when there is no other way.


#5

I second that.