-
Notifications
You must be signed in to change notification settings - Fork 580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
difference operation returns random results #1096
Comments
I made a workaround in my code for now: It just makes a couple of itterations and saves the result with highest mass. |
I'm having the same problem, I tried different blender versions, but the results of the difference operation is always random. |
I also noticed that sometimes even with the correct A-B result returned there are some holes missing in my parts. |
I'm having the same issue, I think that problem is that the objects order in Blender is random. My guess is that the objects are alphabetically ordered, and their names are the random temporary stl files generated by trimesh. I haven't found an elegant way to reference imported stls in Blender, without having to select "blindly" the object. I've tested it minimally with Blender 2.91 and Blender 2.79 with the code below import sys
import time
from pathlib import Path
import trimesh
from trimesh.interfaces.blender import _blender_executable
from trimesh.util import log
blenders_dir = Path(_blender_executable).parent.parent
def test(iterations=10):
for blender_exe in blenders_dir.rglob("blender.exe"):
blender_version = next(blender_exe.parent.glob("*2.*")).name
log.warning("Testing Blender {}".format(blender_version))
_blender_executable = str(blender_exe)
good_bools = 0
start = time.time()
for _ in range(iterations): # Montecarlito
flat_box = trimesh.primitives.creation.box((50, 50, 10))
tall_box = trimesh.primitives.creation.box((15, 15, 20))
donut = flat_box.difference(tall_box, engine="blender")
# donut should be a doughnut, but it can be two boxes
if donut.extents[0] < 49:
log.info("Bad boolean")
else:
log.info("Good boolean")
good_bools += 1
log.warning("Blender {} succes rate {:0.2f}%. {:0.2f} seconds".format(blender_version, good_bools * 100.0 / iterations, time.time() - start))
def change_bool_script(script_path):
from trimesh.resources import _cache
log.warning("Changing script to {}".format(script_path))
with open(script_path, "r") as f:
_cache[('blender_boolean.py.template', True, False)] = f.read()
if __name__ == "__main__":
import logging
logging.basicConfig(level=logging.WARNING, stream=sys.stdout, format="%(message)s")
test()
change_bool_script(r"modified_blender_boolean.txt")
test() |
I believe this was fixed by #1177 so closing for now. |
@mikedh what version will this fix be included in? |
It's in the latest release, if you do a |
So I have 2 objects. Object A and B which represents holes I want to cut out of A.
When I run difference like below it gives me random results. Sometimes the result is A-B like expected, but sometimes it returns B-A as the result. Is this expected behaviour?
Engine in this case is blender
So this is what I expect always to get back:
But like I said sometimes it returns this:
It cuts A from B and returns B-A as result:
The text was updated successfully, but these errors were encountered: