These tutorial links are very helpful and the Tutor explains it really well.
As for example in the tutorial you can get the idea. However if you have 20 variables you don’t have to lock everything one by one, that would be really troublesome. You can create a context class (pure data class) and lock this instead all at once.
I never used classes and tried to avoid it (its the tomorrow i will learn it mentallity) but i know exactly what you mean by your statement and i have to learn classes.
At the moment looks my code like this.
HOST = "localhost"
PORT = 5057
s = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
Col = bpy.data.collections['Collection 1']
data = s.recv(100)
D = pickle.loads(data)
for name,loc in D.items():
# change object location
if str(name) in Col.objects.keys():
loc = loc+(0,)
bpy.data.objects[str(name)].location = loc
# add object
empty = bpy.data.objects.new(str(name),None)
loc = loc+(0,)
empty.location = loc
# remove objects
obj_to_remove = set(Col.objects.keys()).difference(str(D.keys()))
for name in obj_to_remove:
ob = bpy.data.objects.get(str(name))
if ob is not None:
The return value is 0.05 because i have only 15 fps which seams enought.(1/15).
The data is a OrderedDict udp stream and look like this
OrderedDict([(0, (598, 29))])
The dictionary increace and decrease depending how many objects in the view of the realsense depth camera are.
The blender script adds, removes or update position depending on the stream.
I use this collection info in animation node for further calculation.
I am really curious how this will look like on the led wall when everything fits together and the light react to my movements.
My first threats experiments showed me that i can run a threat multiple time if i dont close it.
Changed a cube location with thread in a while looop… ah cool it works…added some more code and hit ctrl + p again and one more time and saw funky cube movments because they all run in the backround together…boom blender crashes… You know i am a noob and noobs do what no professional expect .