Notifications
Clear all

[Closed] Deleting overlaping meshes

Akram2601’s script is the easiest, but the intersect function uses bounding boxes, so there will be spheres deleted that don’t actually penetrate a big sphere. And it needs the Big Spheres as separate Meshes,too.

Also in that script I would change the order of the loops. First loop through the big spheres and then through the small ones. That way you don’t run into problems when deleting the small sphere (which here is prevented by ‘where not isDeleted s’. I guess that is causing an error, since it is in a new line without brackets. Should be in the same line as the for loop, that is ‘for b in big where not isDeleted s do’).

Akram2601’s script is the easiest, but the intersect function uses bounding boxes, so there will be spheres deleted that don’t actually penetrate a big sphere. And it needs the Big Spheres as separate Meshes,too.

Exaclty, the problem here is the bounding box. Therefore not exact enough for
my purpose, also the big spheres as you mentioned have to be separated too.

hmm, seems to be more complicated as i though as the beginning…

@Piflik – Mate, does your script work on your scene?

regards

NAIK

Yes, the code is using bounding box for the check as i said in the post is inaccurate.
Try this, its very accurate but the only requirement is that all the spheres need to be separated…(Detach To Element )


 small = $Sphere_Small_* as array
 big = $Sphere_Big_* as array
 for b in big do
 (
 	bigRad = (b.max.x-b.min.x)/2
 	for s in small where not isdeleted s do
 		(
 			smallrad= (s.max.x-s.min.x)/2
 			dist = distance b s
 			if dist < (bigRad +smallrad) then
 				delete s
 		) 	
 )
 

@Piflik thanks for the loop correction…
@Drea I thought of the distance method first, but could not get the radius of the sphere. Thanks for the (max-min) code. This is the same as of yours(more readable). Thanks once again.

Yeah it works. Just tried it with Shell Modifiers and it did work. It took more time and memory than with Normal Modifiers (in fact I had memory issues after 5 spheres!!!), because every object has now the double polycount…

Best to use Normal Modifiers for the small spheres and a Shell Modifier for the big spheres Mesh ;).

Also the only time I got the .pos error was with a small sphere without Shell/Normal Modifier. Every other error I got (due to wrong Pivots or Names or missing Modifier on the big spheres) was ‘no < function for undefined’.

Do you possible have some hidden objects that have the same name like the small spheres and don’t have a normal modifier? Or are some of your ‘spheres’ open? (the radius calculation shoots a ray from the pivot straight up. If there is no face , it will return ‘undefined’ and cause that ‘no pos property for undefined’ error.)

@akram

Mate, i got this one

– Syntax error: at where, expected <factor>
– In line: for s in small do where n

Akram: With that order of loops I think you wouldn’t actually need the isDeleted. It loops through the small spheres and deletes one at the end of each iteration. If you pull the sphere out of the array after deleting it, it shouldn’t be referenced in the next cycle of the big spheres loop. The best way to do that would be to build the small spheres array in the big spheres loop.

Like this:

big = $Sphere_Big_* as array
for b in big do
(
	bigRad = (b.max.x-b.min.x)/2
	small = $Sphere_Small_* as array
	for s in small do
	(
		smallrad= (s.max.x-s.min.x)/2
		dist = distance b s
		if dist < (bigRad +smallrad) do delete s
	) 	
)

The error in the script comes, because he has two ‘do’s in the loop…should be ‘for s in small where not isdeleted s do’…

@Piflik

Okay now its working.

Right now i have to test which one is better for my purpose.

Imagine i got perhaps 100 big spheres ( in fact it is a water drop mesh)
and perhaps 10000 small meshes ( blobmesh object )
So both are not spheres when you get what i mean.

I will test if that situation fit to both scripts…

Anyway, thanks a bunch for the big help!

best regards

sorry dude my mistake forgot to remove do in the above script…corrected it now. try it…

@Piflik thanks for pointing it out. I add the isDeleted condition to check for the object, i could have put the small object loop inside but i din’t want to create a new array everytime i the big sphere loop. Thank for the suggestion.

If the blobs are close enough to spheres, it still should work…not perfectly of course…

Some drops (to be precise those which penetrate a big sphere, but the hight of the drop is to small and the calculated radius is smaller than the distance to the sphere, if you get my drift…it’s hard to word…;)). The big sphere’s shape doesn’t matter in my script. The distance script might in fact work better, since it uses the X-Direction rather than the Z-Direction. (I’ll see if I can write a script that actually works exactly ;))

@Piflik

Thanks mate, i really appreciate your help!

I will test your and Akrams Script with my scene and give you both feedback.
Actually the small drops are quite similar to spheres, excepüt for the bigger drops.

But i will post the results after i have run both scripts in my scene.

Thanks so far guys!!

NAIK

Page 2 / 3