first commit
This commit is contained in:
commit
33c82edd77
5
Dockerfile
Normal file
5
Dockerfile
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
FROM zocker160/blender-bpy:latest
|
||||||
|
WORKDIR /app
|
||||||
|
COPY ./src/app.py /app/app.py
|
||||||
|
CMD ["python3", "/app/app.py"]
|
||||||
|
|
12
docker-compose.yml
Normal file
12
docker-compose.yml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
version: '3'
|
||||||
|
services:
|
||||||
|
blender-bpy:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
image: blender-bpy-service
|
||||||
|
container_name: blender-bpy-api
|
||||||
|
ports:
|
||||||
|
- "5000:5000"
|
||||||
|
volumes:
|
||||||
|
- ./src:/app
|
5
readme.md
Normal file
5
readme.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# 生产镜像
|
||||||
|
docker build -t blender-bpy:1.0 .
|
||||||
|
|
||||||
|
# 宿主机执行这条命令
|
||||||
|
docker run --rm -it -v $(pwd)/src:/app blender-bpy:1.0
|
33
src/app.py
Normal file
33
src/app.py
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import bpy
|
||||||
|
|
||||||
|
def import_and_thicken_stl(input_filepath, output_filepath, thickness):
|
||||||
|
# 删除场景中所有对象(可选)
|
||||||
|
bpy.ops.object.select_all(action='SELECT')
|
||||||
|
bpy.ops.object.delete()
|
||||||
|
|
||||||
|
# 导入STL模型
|
||||||
|
bpy.ops.import_mesh.stl(filepath=input_filepath)
|
||||||
|
|
||||||
|
# 选择导入的模型
|
||||||
|
bpy.context.view_layer.objects.active = bpy.context.selected_objects[0]
|
||||||
|
bpy.ops.object.mode_set(mode='EDIT')
|
||||||
|
|
||||||
|
# 选择所有面
|
||||||
|
bpy.ops.mesh.select_all(action='SELECT')
|
||||||
|
|
||||||
|
# 添加厚度修饰器
|
||||||
|
bpy.ops.object.modifier_add(type='SOLIDIFY')
|
||||||
|
bpy.context.object.modifiers["Solidify"].thickness = thickness
|
||||||
|
|
||||||
|
# 返回对象模式
|
||||||
|
bpy.ops.object.mode_set(mode='OBJECT')
|
||||||
|
|
||||||
|
# 导出修改后的STL模型
|
||||||
|
bpy.ops.export_mesh.stl(filepath=output_filepath)
|
||||||
|
|
||||||
|
|
||||||
|
input_filepath = "1.stl"
|
||||||
|
output_filepath = "2.stl"
|
||||||
|
thickness = -0.3 # 挤压厚度
|
||||||
|
|
||||||
|
import_and_thicken_stl(input_filepath, output_filepath, thickness)
|
Loading…
Reference in New Issue
Block a user