Your code performs infinite recursions. For every call to moveObj you're creating a thread that in itself calls moveObj again. A solution for your goal is to use a modal operator in combination with a timer to execute a function every x seconds. An example for this can be found in operator_modal_timer.py
many thanks for your hints - this is my current solution.
It works but of course it's less then ideal (using global variables, ...)
Anyhow, maybe somebody can use parts of it - and also of course - comments are very welcome!
from bpy.utils import register_class, unregister_class
xTimer = None
enable = False
The good answer stays for hatinacat2000.
Though, the implementation could be optimized from the code given in the question, and stay in $O(n^3)$, but does not need to allocate combinations (and that can spare a lot of memory if there are many points).
It considers parallel planes as we progressively check best plane containing first point, then second ...
This can be solved by checking whether the timer has been set before. Unfortunately the example has a little confusing mistake. self._timer = wm.event_timer_add(0.1, window=context.window) does not assign a value to the class attribute _timer as declared at the beginning of the class. Instead it creates an instance attribute named _timer. You can see this by ...
The following example shows how to create multiple operators each with their specific function. It only shows three buttons, but the concept remains the same for an arbitrary number of buttons and their underlying operators. The panel is created in the sidebar of the 3D View which can be opened with N.
I hope I haven't misunderstood what you're trying to ...
You need to indent your call to bpy.ops.wm.modal_test_operator() so it will only be executed when the code as run as a script, which is the case when __name__ == "__main__". Otherwise you're trying to access blend data when the add-on isn't registered, which results in the exception you're seeing. For more information about this topic take a look at this ...
The script below retrieves the home directory and generates the path to the desktop. If the project has been saved before, it adds the name as prefix.
from pathlib import Path
from sys import platform
home_dir = str(Path.home())
if platform == 'linux' or platform == 'win32' or platform == 'darwin':
desktop_dir = os.path.join(...
In order to activate the selection of edge marks you first need to access the Freestyle settings. These settings can be found in the view layer in Blender 2.80. Assuming your view layer is called "View Layer" you can access the settings using the following code:
freestyle_settings = bpy.context.scene.view_layers["View Layer"]....
obj = bpy.context.active_object
for index in range(0, len(obj.material_slots.keys())):
obj.active_material_index = index
if "." in obj.active_material.name:
mat = obj.active_material.name[:-4]
obj.data.materials[index] = bpy.data.materials[mat]
This work, I kind of ...