I'm writing a script to make a hole in a group with multiple subgroups.
I iterate through the group and subtract a box if they intersect.
The boxes are created correctly but it gives the following error:
#<Deleted Entity:0x65d174a8>
Error: #<TypeError: reference to deleted Group>
def addhole(beginx,beginz,breedte,hoogte)
#beginpunt x = afstand tot begincoordinaat muur; y = hoogte tov nulpas
dikte = @wandgroep.local_bounds.depth
openingbound = Geom;;BoundingBox.new
openingbound.add([beginx,0,beginz],[beginx + breedte,dikte,beginz + hoogte])
points = [
[beginx,0,beginz],
[beginx,0,beginz + hoogte],
[beginx + breedte,0,beginz + hoogte],
[beginx + breedte,0,beginz]
]
@wandgroep.entities.to_a.each do |element|
if not openingbound.intersect(element.bounds).valid?
if element.typename == 'Group'
if element.manifold?
opening = @wandgroep.entities.add_group
opening.entities.add_face(points).pushpull(dikte)
result = opening.subtract(element)
else
element.entities.to_a.each do |subelement|
opening = subelement.entities.add_group
opening.entities.add_face(points).pushpull(dikte)
result = opening.subtract(subelement)
end
end
end
end
end
end