From d24e5b2847300e24149156146c7212ca9aebee2d Mon Sep 17 00:00:00 2001 From: Joshua Shreve Date: Fri, 13 Aug 2021 17:11:44 -0400 Subject: very interim commit to check tbiw issues. --- src/helpers_blender.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/helpers_blender.py') diff --git a/src/helpers_blender.py b/src/helpers_blender.py index 470d5e8..86857a3 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,7 +15,7 @@ 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): @@ -27,7 +35,7 @@ def rotate(shape, angle): def translate(shape, vector): - return sl.translate(tuple(vector))(shape) + return bpy.ops.transform.translate( def mirror(shape, plane=None): -- cgit v1.2.3 From 29a89e462800f26f70f22cbe05211e153339e928 Mon Sep 17 00:00:00 2001 From: Joshua Shreve Date: Tue, 17 Aug 2021 20:39:54 -0400 Subject: File cleanup. --- src/helpers_blender.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/helpers_blender.py') diff --git a/src/helpers_blender.py b/src/helpers_blender.py index 86857a3..f3bbef2 100644 --- a/src/helpers_blender.py +++ b/src/helpers_blender.py @@ -126,9 +126,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): -- cgit v1.2.3 From 1f6206c9fe3bc7b85dd624550020452567921400 Mon Sep 17 00:00:00 2001 From: Joshua Shreve Date: Sat, 21 Aug 2021 15:54:11 -0400 Subject: moved file and slow progress to blender engine. --- src/helpers_blender.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/helpers_blender.py') diff --git a/src/helpers_blender.py b/src/helpers_blender.py index f3bbef2..9213488 100644 --- a/src/helpers_blender.py +++ b/src/helpers_blender.py @@ -19,7 +19,10 @@ def box(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): @@ -31,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 bpy.ops.transform.translate( + 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()') -- cgit v1.2.3