diff options
author | Robert Reed <robert.mc.reed@gmail.com> | 2021-08-25 22:55:17 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-25 22:55:17 -0700 |
commit | 9741a5f4731dac2f4792a4b451d9a96dd1c2a381 (patch) | |
tree | cf9fba2dd539e6890899c9d1b33ebb81093cd4f2 /src/helpers_blender.py | |
parent | d937d7beb2d7d898dd937cd9e024952b56607403 (diff) | |
parent | 27f491bda62c18e314380ddc6456962a2417b84b (diff) |
Merge branch 'master' into feat/bash
Diffstat (limited to 'src/helpers_blender.py')
-rw-r--r-- | src/helpers_blender.py | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/src/helpers_blender.py b/src/helpers_blender.py index 470d5e8..9213488 100644 --- a/src/helpers_blender.py +++ b/src/helpers_blender.py @@ -1,4 +1,12 @@ -import solid as sl +import bpy +import bmesh +import os +import sys +import time +import mathutils +from math import pi, radians, sin, cos +from contextlib import contextmanager + debug_trace = False @@ -7,11 +15,14 @@ def debugprint(info): print(info) def box(width, height, depth): - return sl.cube([width, height, depth], center=True) + return bpy.ops.mesh.primitive_cube_add(size=1, location=(0, 0, 0), scale=(width, height, depth)) def cylinder(radius, height, segments=100): - return sl.cylinder(r=radius, h=height, segments=segments, center=True) + return bpy.ops.mesh.primitive_cylinder_add( + vertices=segments, radius=radius, depth=height, location=(0, 0, 0), rotation=(0, 0, 0) + ) + def sphere(radius): @@ -23,12 +34,15 @@ def cone(r1, r2, height): def rotate(shape, angle): - return sl.rotate(angle)(shape) - + bpy.ops.transform.rotate(value=-radians(angle[0]), orient_axis='X', center_override=(0.0, 0.0, 0.0)) + bpy.ops.transform.rotate(value=-radians(angle[1]), orient_axis='Y', center_override=(0.0, 0.0, 0.0)) + bpy.ops.transform.rotate(value=-radians(angle[2]), orient_axis='Z', center_override=(0.0, 0.0, 0.0)) + return def translate(shape, vector): - return sl.translate(tuple(vector))(shape) + bpy.ops.transform.translate(value=vector, orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', mirror=True, use_proportional_edit=False, proportional_edit_falloff='SMOOTH', proportional_size=1, use_proportional_connected=False, use_proportional_projected=False) + return def mirror(shape, plane=None): debugprint('mirror()') @@ -118,9 +132,9 @@ def extrude_poly(outer_poly, inner_polys=None, height=1): return sl.linear_extrude(height=height, twist=0, convexity=0, center=True)(outer_poly) -def import_file(fname): +def import_file(fname, convexity=5): print("IMPORTING FROM {}".format(fname)) - return sl.import_(fname + ".stl") + return sl.import_(fname + ".stl", convexity=convexity) def export_file(shape, fname): |