|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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() |
|
|
|
|
|
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 __(bpy, file_content, mo, temp_file_path, time): |
|
start_time = time.time() |
|
|
|
|
|
if file_content: |
|
bpy.ops.wm.open_mainfile(filepath=temp_file_path) |
|
|
|
|
|
bpy.context.scene.render.engine = 'BLENDER_WORKBENCH' |
|
bpy.context.scene.render.resolution_x = 500 |
|
bpy.context.scene.render.resolution_y = 200 |
|
|
|
|
|
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, start_time |
|
|
|
|
|
if __name__ == "__main__": |
|
app.run() |
|
|