opened
jsanchez679
username_0
Dear Marco, 
Hope this message finds you well! 
I am currently trying to use the booleanOperation function to add a series of spheres and create a unique mesh from which I can get the volume. I tried the example boolean.py and it works, but when I try to add a  series of spheres the next error appears, and the kernel needs to be restarted. 
![boolOp_error](https://user-images.githubusercontent.com/10684503/96050940-6e07d600-0e72-11eb-8490-c2b9b93e7655.PNG)
The function I am trying to create goes like this: 

` def getBalloonedHeart(dictLayer):
    
    pts_cl = np.asarray(dictLayer['Points'])
    sphData_cl = np.asarray(dictLayer['PointData']['MaximumInscribedSphereRadius'])
    
    sph_all = []
    for n, pt_pos, radius in zip(count(), pts_cl, sphData_cl):
        sph2add = Sphere(pos=pt_pos, r=radius, c='red')
        sph_all.append(sph2add)
    
    sph_whole = sph_all[0]
    for sphere in sph_all:
        sph_whole = booleanOperation(sphere, "plus", sph_whole.clone())
    
    sph_whole = sph_whole.color('coral').legend('Filled')
    
    return sph_all, sph_whole`

where _pts_cl_ is an array of pos (x,y,z) coordinates, and _sphData_cl_ is an array of the same length with the radii of the spheres to create. The first **for** of the funcion runs smoothly, and creates a list of all the spheres. The problem arises when trying to create the volume of added spheres. 

Let me know if you have any questions. 
best wishes, 

Juliana
Error using booleanOperation
issue
created
marcomusy
username_1
Hi Juliana,
could it be that at some step any the two spheres are not intersecting?
the message seems to say that a tree-search object cannot be created.
What are you trying to achieve? maybe there are better ways than the boolean union (?)
cheers
M.
comment
closed
marcomusy
username_1
issue
created
Aniwax
username_2
It's a pity that this discussion didn't continue. I have a similar question: 
I want to create a grid of small mesh box/cubes, then intersect them as a whole with a huge cube beneath this grid plane.
Is there a way to generate a union of mesh objects from a list of mesh objects?
comment
created
marcomusy
username_1
Yes. You can use `mesh.boolean()` this way:
```python
from vedo import *

c1 = Cube().triangulate().clean().flat()
c2 = Cube().triangulate().clean().flat()
c2.pos(0.2,0.1,0.1).rotateX(10)

b = c1.boolean("+", c2).flat().addScalarBar()

show([(c1, c2.alpha(0.5)), b], N=2, axes=1)
```

![image](https://user-images.githubusercontent.com/32848391/101674018-3d01e700-3a58-11eb-8214-520ecfe582dc.png)


Note that if the 2 object do not touch then the operation fails. In this case you can use instead `merge()` to obtain the sum of the two.
comment
created
Aniwax
username_2
@username_1  Thanks for the reply and the nice example!  
But this didn't really solve my issue. I need to calculate a boolean operations on more than 2 not-touching-objects. 
Is there a way to do it?
comment
created
marcomusy
username_1
If the boolean operation is just summing non-touching meshes you can simply use `merge(mesh1,mesh2,mesh3,..)`.
comment