I am trying to create Conway's game of life in blender, but every time I am getting the error
Info: Deleted 13 object(s)
Info: Saved "untitled2.blend"
Info: Deleted 12 object(s)
Info: Saved "untitled2.blend"
add_operation: Operation already exists - 4)Parameters Component : LSLineStyle( affects_directly_visible: false) has PARAMETERS_ENTRY() at 0000015542C29588
add_operation: Operation already exists - 4)Parameters Component : LSLineStyle( affects_directly_visible: true) has PARAMETERS_EVAL() at 0000015542C29448
add_operation: Operation already exists - 4)Parameters Component : LSLineStyle( affects_directly_visible: true) has PARAMETERS_EXIT() at 0000015542C29308
add_operation: Operation already exists - 13)Audio Component : SCScene( affects_directly_visible: true) has AUDIO_ENTRY() at 0000015542C28E08
add_operation: Operation already exists - 13)Audio Component : SCScene( affects_directly_visible: false) has SOUND_EVAL() at 000001551D479A88
add_operation: Operation already exists - 13)Audio Component : SCScene( affects_directly_visible: true) has AUDIO_VOLUME() at 000001551D479D08
add_operation: Operation already exists - 9)Sequencer Component : SCScene( affects_directly_visible: true) has SEQUENCES_EVAL() at 000001551D479948
add_operation: Operation already exists - 10)LayerCollections Component : SCScene( affects_directly_visible: true) has VIEW_LAYER_EVAL() at 000001551D478B88
add_operation: Operation already exists - 4)Parameters Component : SCScene( affects_directly_visible: true) has PARAMETERS_ENTRY() at 000001551D479088
add_operation: Operation already exists - 4)Parameters Component : SCScene( affects_directly_visible: true) has PARAMETERS_EVAL() at 000001551D4791C8
add_operation: Operation already exists - 4)Parameters Component : SCScene( affects_directly_visible: true) has PARAMETERS_EXIT() at 000001551D4787C8
add_operation: Operation already exists - 4)Parameters Component : SCScene( affects_directly_visible: true) has SCENE_EVAL() at 000001551D478188
Error : EXCEPTION_ACCESS_VIOLATION
Address : 0x00007FF60DEB1C59
Module : blender.exe
Thread : 00002cf4
Writing: C:\Users****\AppData\Local\Temp\untitled2.crash.txt
Here is the code
# adding system packages
import sys
sys.path.append("C:\Users\***\AppData\Roaming\Python\Python39\site-packages")
import bpy
import numpy as np
import random
from scipy import signal
import time
import threading
remove exixting objects
bpy.ops.object.select_all(action='DESELECT')
bpy.ops.object.delete()
set of active objects
active_objects = set()
#set the grid size
grid_size = 20
grid = np.zeros((grid_size,)*3, dtype=int)
randomly place some 'n' 1s
#n = 10
#for i in range(n):
grid[random.randint(0, grid_size-1),
random.randint(0, grid_size-1),
random.randint(0, grid_size-1)] = 1
grid[10, 10, 10] = 1
grid[10, 10, 8] = 1
grid[10, 10, 12] = 1
grid[10, 8, 10] = 1
grid[10,12, 10] = 1
grid[12, 10, 10] = 1
grid[8,10,10] = 1
now place the cubes
for cor in zip(*np.where(grid == 1)):
bpy.ops.mesh.primitive_cube_add(size=1,
calc_uvs=False,
location=cor)
obj = bpy.context.object
obj.name = str(cor)
active_objects.add(cor)
now in next step we will calculate Conway's conditions
kernel = np.ones((3,3,3), dtype=int)
kernel[1,1,1] = 0
def loop_generation(generation = 10, delay = 1):
global active_objects
for _ in range(generation):
time.sleep(delay)
convolution = signal.convolve(grid, kernel, mode='same')
# extract the living cells
new_living = set()
for cord in zip(*np.where((convolution == 2) | (convolution == 3))):
new_living.add(cord)
to_kill = active_objects.difference(new_living)
add_new = new_living.difference(active_objects)
print(convolution)
for del_cor in to_kill:
bpy.data.objects.remove(bpy.data.objects[str(del_cor)])
for new_cor in add_new:
bpy.ops.mesh.primitive_cube_add(size=1,
calc_uvs=False,
location=new_cor)
obj = bpy.context.view_layer.objects.active
print(obj)
#obj = bpy.context.object
obj.name = str(new_cor)
active_objects = new_living
if name == 'main':
threading.Thread(target=loop_generation).start()
Text Editor > Templates > Python > Modal Timer OperatorObjects can be added removed based on its elapsed time. – batFINGER Sep 11 '21 at 13:49