.. include:: ../../../substitutions .. _blender_crashing: Preventing Blender from crashing ================================ This guide explains what precautions can be taken to prevent Blender from crashing. Blender's docs also provide a useful page, that in particular includes a section on **Help! My script crashes Blender**: `Gotchas`_ . .. contents:: Table of contents :local: :backlinks: none Executing Python Scripts via Command Line ----------------------------------------- Blender is usually (and best) started from a console, see :ref:`blender_getting_started`. Executing a python script in Blenders GUI over and over again may lead to unwanted leakage, caching and unintentionally influencing Blender's state. Therefore it is recommended to always execute a python script with a new instance of Blender. This can be done by using the `--pyhton` flag. .. code-block:: bash blender --python /path-to-python-file/file.py For Windows and Mac change the `blender` call to the corresponding call listed in :ref:`blender_getting_started`. Executing Blender in the background ----------------------------------- If you don't need Blender's GUI, for example when directly rendering from a Python script, you may want to run Blender in the background to save extra memory. .. code-block:: bash blender --background --python /path-to-python-file/file.py For Windows and Mac change the `blender` call to the corresponding call listed in :ref:`blender_getting_started`. Reducing the number of Blender objects -------------------------------------- In our experience Blender is better at handling fewer objects with dense meshes compared to many objects with coarse meshes. Therefore it might make sense to join multiple objects into one object. Nets can be joined in :py:class:`~ddg.datastructures.nets.net.NetCollection` s. Halfedge objects can be joined by using the function :py:func:`~ddg.datastructures.halfedge.copy.union`. You can manually join objects in Blender by selecting them and pressing `Ctrl + J`. Alternatively you do this via script using the function :py:func:`~ddg.visualization.blender.mesh.join` that joins meshes or objects with mesh data. Preventing Animations to Crash during Rendering ----------------------------------------------- In addition to the tips and tricks above you can find more hints for more stable rendering of animations in the :ref:`blender_rendering` guide under **Animation**. Debugging when Blender crashed ------------------------------ If Blender still crashes, Blender's command line tool offers a lot of options for debugging and getting more informative debugging messages. Run .. code-block:: bash blender --help to get an overview. For Windows and Mac change the `blender` call to the corresponding call listed in :ref:`blender_getting_started`.