Skip to content

Commit

Permalink
rework docker image to run blender headless
Browse files Browse the repository at this point in the history
  • Loading branch information
gjedlicska committed Oct 13, 2023
1 parent 98860ec commit a2f5a9c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
17 changes: 10 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
FROM linuxserver/blender
FROM ubuntu:22.04

RUN apt update && \
apt install python3-pip && \
apt install unzip && \
pip install poetry
ENV DEBIAN_FRONTEND=noninteractive

RUN apt update
RUN apt install -y tar wget blender python3-pip

RUN pip3 install poetry

COPY . .
RUN poetry export -f requirements.txt --output requirements.txt && pip install -r requirements.txt

RUN curl -o blender-connector.zip https://github.com/specklesystems/speckle-blender/archive/refs/tags/2.16.0-rc1.zip && \
unzip blender-connector.zip -d "$HOME/.config/blender/3.3/"
# RUN mkdir -p $HOME/.config/blender/3.0/scripts/addons
RUN wget -O blender-connector.zip https://releases.speckle.dev/installers/blender/bpy_speckle-2.17.0-alpha2.zip
RUN blender --background --python installation/connector.py
7 changes: 7 additions & 0 deletions installation/connector.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import os

import bpy

bpy.ops.preferences.addon_install(filepath="/blender-connector.zip")
bpy.ops.preferences.addon_enable(module="bpy_speckle")
bpy.ops.wm.save_userpref()
21 changes: 5 additions & 16 deletions speckle_import.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
import bpy
import os

bpy.ops.preferences.addon_install(filepath='/blender-connector.zip')
bpy.ops.preferences.addon_enable(module='bpy_speckle')

from bpy_speckle.convert.to_native import _deep_conversion

from specklepy.api import operations
Expand All @@ -30,23 +24,18 @@ def set_filename(fileName):
_deep_conversion(commit_object, converted_objects, True)




all_cameras = [o for o in bpy.context.scene.objects if o.type == 'CAMERA']
all_cameras = [o for o in bpy.context.scene.objects if o.type == "CAMERA"]
total = len(all_cameras)

print(f"Starting rendering cameras... 0/{total}")

for (i, ob) in enumerate(all_cameras):
#Set as active render cam
for i, ob in enumerate(all_cameras):
# Set as active render cam
bpy.context.scene.camera = ob

#Render camera to output directory
# Render camera to output directory
set_filename(f"{ob.name}")
bpy.ops.render.render(write_still = True)
bpy.ops.render.render(write_still=True)
print(f"Render {i}/{total} complete! saved at {bpy.context.scene.render.filepath}")

print(f"All Done!")



0 comments on commit a2f5a9c

Please sign in to comment.