What I’m trying to do:
Trying to call some anvil.server.callable functions from the browser in blender
What I’ve tried and what’s not working:
While calling simple functions like printing a message inside the blender console works fine, when doing more complex operations like opening a file, or appending data from other files, blender will just crash, without any message, even if I start blender through the cmd line, I still don’t get any crash messages.
It’s strange because very rarely the code sometimes runs till the end, but sometimes it just crashes.
If I run the code directly from blender, it always works.
So I am wondering if anyone has experience setting anvil up with blender, if you encountered these problems?
Bellow is a simplified version of the function in am trying to run inside blender
Code Sample:
@ anvil.server.callable("load_shot_" + ID)
def load_shot(shotInfo):
layers = ['Int_Rearliner_STD', 'INT_Roof_Std', 'INT_Trunk_Std', 'INT_DashboardButtons_2', 'INT_Floor_Std', 'INT_Doors_1', 'INT_Mirror_1',
'INT_Seats_2nd_2', 'INT_Seats_2nd_Headrests_1', 'INT_Seats_3rd_Std', 'INT_Seats_3rd_Headrests_1_Std', 'INT_Seats_1st_2', 'INT_Dashboard_2']
path = "Z:\\01_Production_MB\\01_Library\\01_Products\\V260\\MY2022\\BLEND\\V260_MY2022.blend"
with bpy.data.libraries.load(path) as (data_from, data_to):
data_to.collections = [
name for name in data_from.collections if name in layers]
for collection in data_to.collections:
try:
bpy.context.scene.collection.children.link(collection)
except:
print(collection)
zsu.link_collection_to_collection("Collection", collection)