Jan-Hendrik Müller
commited on
Commit
•
c49acc3
1
Parent(s):
abe3be2
add selection
Browse files
app.py
CHANGED
@@ -45,18 +45,43 @@ def __(tempfile, w):
|
|
45 |
|
46 |
|
47 |
@app.cell
|
48 |
-
def __(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
start_time = time.time()
|
50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
# Load the temporary .blend file into Blender
|
52 |
if file_content:
|
53 |
bpy.ops.wm.open_mainfile(filepath=temp_file_path)
|
54 |
|
55 |
# Set render engine and resolution
|
56 |
-
bpy.context.scene.render.engine =
|
57 |
bpy.context.scene.render.resolution_x = 500
|
58 |
-
bpy.context.scene.render.resolution_y =
|
59 |
-
|
60 |
# Render and save the image without any rotation
|
61 |
bpy.ops.render.render()
|
62 |
bpy.data.images["Render Result"].save_render(filepath="test.png")
|
@@ -64,9 +89,13 @@ def __(bpy, file_content, mo, temp_file_path, time):
|
|
64 |
end_time = time.time()
|
65 |
print(f"Script execution time: {end_time - start_time:.4f} seconds")
|
66 |
|
67 |
-
|
68 |
-
|
69 |
-
|
|
|
|
|
|
|
|
|
70 |
|
71 |
|
72 |
if __name__ == "__main__":
|
|
|
45 |
|
46 |
|
47 |
@app.cell
|
48 |
+
def __(mo):
|
49 |
+
dropdown = mo.ui.dropdown(
|
50 |
+
options={
|
51 |
+
"workbench": "BLENDER_WORKBENCH",
|
52 |
+
"eevee": "BLENDER_EEVEE_NEXT",
|
53 |
+
"cycles": "CYCLES"},
|
54 |
+
value="workbench",
|
55 |
+
label="choose renderer",
|
56 |
+
)
|
57 |
+
dropdown
|
58 |
+
return (dropdown,)
|
59 |
+
|
60 |
+
|
61 |
+
@app.cell
|
62 |
+
def __(bpy, dropdown, file_content, mo, temp_file_path, time):
|
63 |
start_time = time.time()
|
64 |
|
65 |
+
# Ensure Cycles is selected as the render engine for all view layers
|
66 |
+
for layer in bpy.context.scene.view_layers:
|
67 |
+
layer.cycles.use_denoising = False
|
68 |
+
|
69 |
+
# Set render samples to 10 for all view layers and the scene
|
70 |
+
bpy.context.scene.cycles.samples = 10
|
71 |
+
|
72 |
+
# Ensure to sync all settings
|
73 |
+
bpy.context.view_layer.update()
|
74 |
+
|
75 |
+
|
76 |
# Load the temporary .blend file into Blender
|
77 |
if file_content:
|
78 |
bpy.ops.wm.open_mainfile(filepath=temp_file_path)
|
79 |
|
80 |
# Set render engine and resolution
|
81 |
+
bpy.context.scene.render.engine = dropdown.value
|
82 |
bpy.context.scene.render.resolution_x = 500
|
83 |
+
bpy.context.scene.render.resolution_y = 400
|
84 |
+
bpy.context.scene.cycles.samples = 5
|
85 |
# Render and save the image without any rotation
|
86 |
bpy.ops.render.render()
|
87 |
bpy.data.images["Render Result"].save_render(filepath="test.png")
|
|
|
89 |
end_time = time.time()
|
90 |
print(f"Script execution time: {end_time - start_time:.4f} seconds")
|
91 |
|
92 |
+
mo.image(src="test.png")
|
93 |
+
return end_time, layer, start_time
|
94 |
+
|
95 |
+
|
96 |
+
@app.cell
|
97 |
+
def __():
|
98 |
+
return
|
99 |
|
100 |
|
101 |
if __name__ == "__main__":
|