0
$\begingroup$

I'm creating and applying a boolean modifier between two complicated objects, like this:

    bool_one = complicated_object_1.modifiers.new(type="BOOLEAN", name="bool 1")
    bool_one.object = complicated_object_2
    bool_one.operation = "DIFFERENCE"
    bpy.ops.object.modifier_apply(modifier=bool_one.name)

Creating the modifier takes a little over 14 second, and applying the modifier also takes a little over 14 seconds. Presumably this is because creating the modifier has to calculate the new geometry to display and applying it creates the geometry again to create the new mesh object.

Is there any way I can create and apply the modifier in one step, disable the calculation while creating it or in some other way prevent it from doing the calculation twice?

$\endgroup$

1 Answer 1

0
$\begingroup$

Using the built-in BoolTool add-on (in your case use the Ctrl Shift Num- shortcut) should eliminate the first 14 seconds.

$\endgroup$
5
  • $\begingroup$ Sounds interesting, I'll try it and see how it goes $\endgroup$
    – TheGribble
    Commented Mar 5 at 20:54
  • 1
    $\begingroup$ You can have a look at the add-on's code. It does the same, but disables viewport visibility of the newly added modifier: ... md = obj.modifiers.new("Auto Boolean", "BOOLEAN") md.show_viewport = False ... If it's any faster, maybe that is the reason for it. $\endgroup$ Commented Mar 5 at 21:02
  • 1
    $\begingroup$ @Zyzio, have you actually tested if the addon is faster than the code shared in the question? $\endgroup$ Commented Mar 5 at 21:05
  • $\begingroup$ Using booltool with bpy.ops.object.booltool_auto_difference() takes about 15 seconds, so I think that's the answer. I'll try setting the md.show_viewport=false as Martynas said to see if I can eliminate the need for the add-on and get that last second back too $\endgroup$
    – TheGribble
    Commented Mar 5 at 23:22
  • 1
    $\begingroup$ Can confirm that show_viewport=false is the answer, complete time reduced to 14 seconds $\endgroup$
    – TheGribble
    Commented Mar 6 at 12:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .