added mortice along a curve

pull/197/head
palain 2021-12-08 10:43:17 -04:00
rodzic 44619cfafa
commit add09c0157
2 zmienionych plików z 49 dodań i 15 usunięć

Wyświetl plik

@ -216,6 +216,8 @@ class CamCurveMortise(bpy.types.Operator):
unit="LENGTH")
plate_thickness: bpy.props.FloatProperty(name="Drawer plate thickness", default=0.00477, min=0.001, max=3.0,unit="LENGTH")
side_height: bpy.props.FloatProperty(name="side height", default=0.05, min=0.001, max=3.0,unit="LENGTH")
flex_pocket: bpy.props.FloatProperty(name="Flex pocket", default=0.004, min=0.000, max=1.0,unit="LENGTH")
top_bottom: bpy.props.BoolProperty(name="Side Top & bottom fingers", default=True)
@classmethod
@ -227,7 +229,6 @@ class CamCurveMortise(bpy.types.Operator):
shapes = utils.curveToShapely(o1)
cp = (0, 0)
for s in shapes:
s = shapely.geometry.polygon.orient(s, 1)
if s.boundary.type == 'LineString':
loops = [s.boundary]
else:
@ -241,12 +242,19 @@ class CamCurveMortise(bpy.types.Operator):
coords = list(c.coords)
for i, p in enumerate(coords):
if i == 0:
p_start = p
if p != p_start:
not_start = True
else:
not_start = False
pd = c.project(Point(p))
if i > 0:
if not_start:
while distance <= pd:
mortise_point = c.interpolate(distance)
p_difference = (p[0]-oldp[0],p[1]-oldp[1])
print(distance, p_difference,math.degrees(math.atan2(p_difference[1], p_difference[0])))
joinery.mortise(self.finger_size,self.plate_thickness,self.finger_tolerence,mortise_point.x, mortise_point.y, math.atan2(p_difference[1], p_difference[0]))
bpy.context.active_object.name = "_mortise"
j += 1
@ -254,7 +262,7 @@ class CamCurveMortise(bpy.types.Operator):
oldp = p
simple.joinMultiple("_mort")
bpy.context.active_object.name = "mortise"
joinery.create_flex_side(loop_length, self.side_height, self.finger_size, self.plate_thickness, self.finger_tolerence)
joinery.create_flex_side(loop_length, self.side_height, self.finger_size, self.plate_thickness, self.finger_tolerence,self.top_bottom,self.flex_pocket)
return {'FINISHED'}

Wyświetl plik

@ -106,8 +106,8 @@ def vertical_finger(length, thickness, finger_play, amount):
def finger_pair(name, dx=0, dy=0):
simple.makeActive(name)
xpos = (dx / 2) * 1.00001
ypos = 1.00001 * dy / 2
xpos = (dx / 2) * 1.0005
ypos = 1.0005 * dy / 2
bpy.ops.object.duplicate_move(OBJECT_OT_duplicate={"linked": False, "mode": 'TRANSLATION'},
TRANSFORM_OT_translate={"value": (xpos, ypos, 0.0)})
@ -145,21 +145,47 @@ def create_base_plate(height, width, depth):
handleType='AUTO', edit_mode=False)
bpy.context.active_object.name = "_bottom"
def create_flex_side(length, height, finger_length, finger_thick, finger_tol):
bpy.ops.curve.simple(align='WORLD', location=(0, height/2, 0), rotation=(0, 0, 0), Simple_Type='Rectangle',
Simple_width=length, Simple_length=height, shape='3D', outputType='POLY',
use_cyclic_u=True,
handleType='AUTO', edit_mode=False)
bpy.context.active_object.name = "_side"
def make_flex_pocket(length, height, finger_thick, finger_width, pocket_width):
dist = 0
while dist < length / 2:
if dist == 0:
mortise
mortise(height-2*finger_thick, pocket_width, 0, dist, 0, math.pi/2)
bpy.context.active_object.name = "_flex_pocket"
else:
mortise(height-2*finger_thick, pocket_width, 0,dist, 0, math.pi/2)
bpy.context.active_object.name = "_flex_pocket"
mortise(height-2*finger_thick, pocket_width, 0, -dist, 0, math.pi/2)
bpy.context.active_object.name = "_flex_pocket"
dist += finger_width * 2
horizontal_finger(finger_length, finger_thick, finger_tol, round(length/(2*finger_length)))
simple.joinMultiple("_flex_pocket")
bpy.context.active_object.name = "flex_pocket"
def create_flex_side(length, height, finger_length, finger_thick, finger_tol, top_bottom=False, flex_pocket=0):
horizontal_finger(finger_length, finger_thick, finger_tol, round(length / (2 * finger_length)))
simple.makeActive('_wfa')
simple.selectMultiple("_wfa")
# bpy.ops.transform.transform(mode='TRANSLATION', value=(0, -height/2+finger_thick/2, 0.0))
fingers = bpy.context.active_object
side_height = height / 2
if top_bottom == True:
bpy.ops.object.duplicate_move(OBJECT_OT_duplicate={"linked": False, "mode": 'TRANSLATION'},
TRANSFORM_OT_translate={"value": (0, -finger_thick/2, 0.0)})
bpy.context.active_object.name = "_wfa0"
fingers = finger_pair("_wfa0", 0, height- finger_thick)
side_height = 0
else:
simple.makeActive('_wfa')
fingers = bpy.context.active_object
bpy.ops.curve.simple(align='WORLD', location=(0, side_height, 0), rotation=(0, 0, 0), Simple_Type='Rectangle', Simple_width=length, Simple_length=height, shape='3D', outputType='POLY', use_cyclic_u=True, handleType='AUTO', edit_mode=False)
bpy.context.active_object.name = "_side"
simple.makeActive('_side')
fingers.select_set(True)
bpy.ops.object.curve_boolean(boolean_type='DIFFERENCE')
bpy.context.active_object.name = "side"
simple.removeMultiple('_')
if flex_pocket > 0:
make_flex_pocket(length, height, finger_thick, finger_length, flex_pocket)