Spaces:
Sleeping
Sleeping
File size: 2,345 Bytes
91e132c c49acc3 91e132c c49acc3 91e132c c49acc3 91e132c c49acc3 91e132c c49acc3 91e132c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# /// script
# dependencies = [
# "bpy==4.2.0",
# "marimo",
# "numpy==2.1.2",
# ]
# ///
import marimo
__generated_with = "0.9.9"
app = marimo.App(width="medium")
@app.cell
def __():
import numpy
import bpy
import time
import random
import marimo as mo
import sys
import tempfile
print(sys.version)
return bpy, mo, numpy, random, sys, tempfile, time
@app.cell
def __(mo):
w = mo.ui.file(kind="area")
w
return (w,)
@app.cell
def __(tempfile, w):
file_content = w.contents()
# Create a temporary file to save the content
if file_content:
with tempfile.NamedTemporaryFile(suffix=".blend", delete=False) as temp_file:
temp_file.write(file_content)
temp_file_path = temp_file.name
return file_content, temp_file, temp_file_path
@app.cell
def __(mo):
dropdown = mo.ui.dropdown(
options={
"workbench": "BLENDER_WORKBENCH",
"eevee": "BLENDER_EEVEE_NEXT",
"cycles": "CYCLES"},
value="workbench",
label="choose renderer",
)
dropdown
return (dropdown,)
@app.cell
def __(bpy, dropdown, file_content, mo, temp_file_path, time):
start_time = time.time()
# Ensure Cycles is selected as the render engine for all view layers
for layer in bpy.context.scene.view_layers:
layer.cycles.use_denoising = False
# Set render samples to 10 for all view layers and the scene
bpy.context.scene.cycles.samples = 10
# Ensure to sync all settings
bpy.context.view_layer.update()
# Load the temporary .blend file into Blender
if file_content:
bpy.ops.wm.open_mainfile(filepath=temp_file_path)
# Set render engine and resolution
bpy.context.scene.render.engine = dropdown.value
bpy.context.scene.render.resolution_x = 500
bpy.context.scene.render.resolution_y = 400
bpy.context.scene.cycles.samples = 5
# Render and save the image without any rotation
bpy.ops.render.render()
bpy.data.images["Render Result"].save_render(filepath="test.png")
end_time = time.time()
print(f"Script execution time: {end_time - start_time:.4f} seconds")
mo.image(src="test.png")
return end_time, layer, start_time
@app.cell
def __():
return
if __name__ == "__main__":
app.run()
|