kopia lustrzana https://github.com/vilemduha/blendercam
multiple changes
merge distance parameter for path merging tuning move parallell steb back work on manual bridges placementpull/4/head^2
rodzic
6abe0c2727
commit
e23b7e7b3a
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
|
|
@ -453,6 +453,7 @@ class camOperation(bpy.types.PropertyGroup):
|
||||||
movement_insideout = EnumProperty(name='Direction', items=(('INSIDEOUT','Inside out', 'a'),('OUTSIDEIN', 'Outside in', 'a')),description='approach to the piece',default='INSIDEOUT', update = updateRest)
|
movement_insideout = EnumProperty(name='Direction', items=(('INSIDEOUT','Inside out', 'a'),('OUTSIDEIN', 'Outside in', 'a')),description='approach to the piece',default='INSIDEOUT', update = updateRest)
|
||||||
parallel_step_back = bpy.props.BoolProperty(name="Parallel step back", description='For roughing and finishing in one pass: mills material in climb mode, then steps back and goes between 2 last chunks back', default=False, update = updateRest)
|
parallel_step_back = bpy.props.BoolProperty(name="Parallel step back", description='For roughing and finishing in one pass: mills material in climb mode, then steps back and goes between 2 last chunks back', default=False, update = updateRest)
|
||||||
stay_low = bpy.props.BoolProperty(name="Stay low if possible", default=True, update = updateRest)
|
stay_low = bpy.props.BoolProperty(name="Stay low if possible", default=True, update = updateRest)
|
||||||
|
merge_dist = bpy.props.FloatProperty(name="Merge distance - EXPERIMENTAL", default=0.0, min=0.0000, max=0.1,precision=PRECISION, unit="LENGTH", update = updateRest)
|
||||||
#optimization and performance
|
#optimization and performance
|
||||||
circle_detail = bpy.props.IntProperty(name="Detail of circles used for curve offsets", default=64, min=12, max=512, update = updateRest)
|
circle_detail = bpy.props.IntProperty(name="Detail of circles used for curve offsets", default=64, min=12, max=512, update = updateRest)
|
||||||
use_exact = bpy.props.BoolProperty(name="Use exact mode",description="Exact mode allows greater precision, but is slower with complex meshes", default=True, update = updateExact)
|
use_exact = bpy.props.BoolProperty(name="Use exact mode",description="Exact mode allows greater precision, but is slower with complex meshes", default=True, update = updateExact)
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
import subprocess,os, sys, threading
|
import subprocess,os, sys, threading
|
||||||
from cam import utils, pack,polygon_utils_cam,chunk
|
from cam import utils, pack,polygon_utils_cam,chunk,simple
|
||||||
from bpy.props import *
|
from bpy.props import *
|
||||||
import Polygon
|
import Polygon
|
||||||
|
|
||||||
|
|
@ -652,13 +652,9 @@ class CamOrientationAdd(bpy.types.Operator):
|
||||||
oriob=bpy.context.active_object
|
oriob=bpy.context.active_object
|
||||||
oriob.empty_draw_size=0.02 # 2 cm
|
oriob.empty_draw_size=0.02 # 2 cm
|
||||||
|
|
||||||
|
simple.addToGroup(oriob,gname)
|
||||||
if not gname in bpy.data.groups:
|
|
||||||
bpy.ops.group.create(name=gname)
|
|
||||||
else:
|
|
||||||
bpy.data.groups[gname].objects.link(oriob)
|
|
||||||
oriob.name='ori_'+o.name+'.'+str(len(bpy.data.groups[gname].objects)).zfill(3)
|
oriob.name='ori_'+o.name+'.'+str(len(bpy.data.groups[gname].objects)).zfill(3)
|
||||||
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -444,8 +444,7 @@ class CAM_OPERATION_PROPERTIES_Panel(CAMButtonsPanel, bpy.types.Panel):
|
||||||
layout.prop(ao,'dist_along_paths')
|
layout.prop(ao,'dist_along_paths')
|
||||||
if ao.strategy=='PARALLEL' or ao.strategy=='CROSS':
|
if ao.strategy=='PARALLEL' or ao.strategy=='CROSS':
|
||||||
layout.prop(ao,'parallel_angle')
|
layout.prop(ao,'parallel_angle')
|
||||||
if not ao.ramp:
|
|
||||||
layout.prop(ao,'parallel_step_back')
|
|
||||||
|
|
||||||
layout.prop(ao,'skin')
|
layout.prop(ao,'skin')
|
||||||
layout.prop(ao,'inverse')
|
layout.prop(ao,'inverse')
|
||||||
|
|
@ -487,11 +486,15 @@ class CAM_MOVEMENT_Panel(CAMButtonsPanel, bpy.types.Panel):
|
||||||
ao=scene.cam_operations[scene.cam_active_operation]
|
ao=scene.cam_operations[scene.cam_active_operation]
|
||||||
if ao.valid:
|
if ao.valid:
|
||||||
layout.prop(ao,'movement_type')
|
layout.prop(ao,'movement_type')
|
||||||
|
|
||||||
if ao.movement_type=='BLOCK' or ao.movement_type=='SPIRAL' or ao.movement_type=='CIRCLES':
|
if ao.movement_type=='BLOCK' or ao.movement_type=='SPIRAL' or ao.movement_type=='CIRCLES':
|
||||||
layout.prop(ao,'movement_insideout')
|
layout.prop(ao,'movement_insideout')
|
||||||
|
|
||||||
layout.prop(ao,'spindle_rotation_direction')
|
layout.prop(ao,'spindle_rotation_direction')
|
||||||
layout.prop(ao,'free_movement_height')
|
layout.prop(ao,'free_movement_height')
|
||||||
|
if ao.strategy=='PARALLEL' or ao.strategy=='CROSS':
|
||||||
|
if not ao.ramp:
|
||||||
|
layout.prop(ao,'parallel_step_back')
|
||||||
if ao.strategy=='CUTOUT':
|
if ao.strategy=='CUTOUT':
|
||||||
layout.prop(ao,'first_down')
|
layout.prop(ao,'first_down')
|
||||||
#if ao.first_down:
|
#if ao.first_down:
|
||||||
|
|
@ -515,6 +518,8 @@ class CAM_MOVEMENT_Panel(CAMButtonsPanel, bpy.types.Panel):
|
||||||
layout.prop(ao,'ramp_out_angle')
|
layout.prop(ao,'ramp_out_angle')
|
||||||
|
|
||||||
layout.prop(ao,'stay_low')
|
layout.prop(ao,'stay_low')
|
||||||
|
if ao.stay_low:
|
||||||
|
layout.prop(ao,'merge_dist')
|
||||||
layout.prop(ao,'protect_vertical')
|
layout.prop(ao,'protect_vertical')
|
||||||
if ao.protect_vertical:
|
if ao.protect_vertical:
|
||||||
layout.prop(ao,'protect_vertical_limit')
|
layout.prop(ao,'protect_vertical_limit')
|
||||||
|
|
|
||||||
|
|
@ -1423,7 +1423,9 @@ def connectChunksLow(chunks,o):
|
||||||
|
|
||||||
if o.parallel_step_back:
|
if o.parallel_step_back:
|
||||||
mergedist*=2
|
mergedist*=2
|
||||||
|
if o.merge_dist>0:
|
||||||
|
mergedist=o.merge_dist
|
||||||
|
#mergedist=10
|
||||||
lastch=None
|
lastch=None
|
||||||
i=len(chunks)
|
i=len(chunks)
|
||||||
pos=(0,0,0)
|
pos=(0,0,0)
|
||||||
|
|
@ -1927,7 +1929,8 @@ def getSnappingObject(o):
|
||||||
if s.objects.get(bproj_name)!=None:
|
if s.objects.get(bproj_name)!=None:
|
||||||
ob=s.objects[bproj_name]
|
ob=s.objects[bproj_name]
|
||||||
else:
|
else:
|
||||||
ob=s.objects['BezierCircle.003']
|
getOperationSources(o)
|
||||||
|
ob=o.objects[0]
|
||||||
activate(ob)
|
activate(ob)
|
||||||
bpy.ops.object.duplicate()
|
bpy.ops.object.duplicate()
|
||||||
ob=bpy.context.active_object
|
ob=bpy.context.active_object
|
||||||
|
|
@ -1962,88 +1965,96 @@ def addBridge(o):
|
||||||
|
|
||||||
def getBridges(p,o):
|
def getBridges(p,o):
|
||||||
# this function finds positions of the bridges, and returns these.
|
# this function finds positions of the bridges, and returns these.
|
||||||
pass;
|
g=bpy.data.groups.get('cam_bridges_'+o.name)
|
||||||
|
bridges=[]
|
||||||
|
if g!=None:
|
||||||
|
for o in g.objects:
|
||||||
|
pos=o.matrix_world.to_translation()
|
||||||
|
pos=pos[0],pos[1]
|
||||||
|
bridges.append(pos)
|
||||||
|
return bridges
|
||||||
|
|
||||||
|
|
||||||
def addBridges(ch,o,z):
|
def addBridges(ch,o):
|
||||||
#this functions adds Bridges to the finished chunks.
|
#this functions adds Bridges to the finished chunks. AUTOMATIC ONLY NOW!
|
||||||
ch.getLength()
|
if o.bridges_placement == 'AUTO':
|
||||||
n=int(ch.length/o.bridges_max_distance)
|
ch.getLength()
|
||||||
bpc=o.bridges_per_curve
|
n=int(ch.length/o.bridges_max_distance)
|
||||||
if o.bridges_width*bpc>ch.length/2:
|
bpc=o.bridges_per_curve
|
||||||
bpc=math.floor(ch.length/(2*o.bridges_width))
|
if o.bridges_width*bpc>ch.length/2:
|
||||||
n = max(n,bpc)
|
bpc=math.floor(ch.length/(2*o.bridges_width))
|
||||||
if n>0:
|
n = max(n,bpc)
|
||||||
dist=ch.length/n
|
if n>0:
|
||||||
pos=[]
|
dist=ch.length/n
|
||||||
for i in range(0,n):
|
pos=[]
|
||||||
pos.append([i*dist+0.00001+dist/2.0,i*dist+0.00001+dist/2.0+o.bridges_width+o.cutter_diameter])
|
for i in range(0,n):
|
||||||
dist=0
|
pos.append([i*dist+0.00001+dist/2.0,i*dist+0.00001+dist/2.0+o.bridges_width+o.cutter_diameter])
|
||||||
bridgeheight=min(0,o.min.z+o.bridges_height)
|
dist=0
|
||||||
inbridge=False
|
bridgeheight=min(0,o.min.z+o.bridges_height)
|
||||||
posi=0
|
inbridge=False
|
||||||
insertpoints=[]
|
posi=0
|
||||||
changepoints=[]
|
insertpoints=[]
|
||||||
vi=0
|
changepoints=[]
|
||||||
while vi<len(ch.points):
|
vi=0
|
||||||
v1=ch.points[vi]
|
while vi<len(ch.points):
|
||||||
v2=Vector(v1)#this is for case of last point and not closed chunk..
|
v1=ch.points[vi]
|
||||||
if ch.closed and vi==len(ch.points)-1:
|
v2=Vector(v1)#this is for case of last point and not closed chunk..
|
||||||
v2=Vector(ch.points[0])
|
if ch.closed and vi==len(ch.points)-1:
|
||||||
elif vi+1<len(ch.points):
|
v2=Vector(ch.points[0])
|
||||||
v2=Vector(ch.points[vi+1])
|
elif vi+1<len(ch.points):
|
||||||
v1=Vector(v1)
|
v2=Vector(ch.points[vi+1])
|
||||||
#if v1.z<bridgeheight or v2.z<bridgeheight:
|
v1=Vector(v1)
|
||||||
v=v2-v1
|
#if v1.z<bridgeheight or v2.z<bridgeheight:
|
||||||
dist+=v.length
|
v=v2-v1
|
||||||
|
dist+=v.length
|
||||||
wasinbridge=inbridge
|
|
||||||
if not inbridge and posi<len(pos) and pos[posi][0]<dist:#detect start of bridge
|
|
||||||
|
|
||||||
ratio=(dist-pos[posi][0])/v.length
|
wasinbridge=inbridge
|
||||||
point1=v2-v*ratio#TODO: optimize this : how? what was meant by the initial comment?
|
if not inbridge and posi<len(pos) and pos[posi][0]<dist:#detect start of bridge
|
||||||
point2=v2-v*ratio
|
|
||||||
if bridgeheight>point1.z:
|
ratio=(dist-pos[posi][0])/v.length
|
||||||
point1.z=min(point1.z,bridgeheight)
|
point1=v2-v*ratio
|
||||||
point2.z=max(point2.z,bridgeheight)
|
point2=point1.copy()
|
||||||
#ch.points.insert(vi-1,point1)
|
if bridgeheight>point1.z:
|
||||||
#ch.points.insert(vi,point2)
|
point1.z=min(point1.z,bridgeheight)
|
||||||
insertpoints.append([vi+1,point1.to_tuple()])
|
point2.z=max(point2.z,bridgeheight)
|
||||||
insertpoints.append([vi+1,point2.to_tuple()])
|
#ch.points.insert(vi-1,point1)
|
||||||
inbridge=True
|
#ch.points.insert(vi,point2)
|
||||||
|
insertpoints.append([vi+1,point1.to_tuple()])
|
||||||
|
insertpoints.append([vi+1,point2.to_tuple()])
|
||||||
|
inbridge=True
|
||||||
|
|
||||||
|
if wasinbridge and inbridge:#still in bridge, raise the point up.#
|
||||||
|
changepoints.append([vi,(v1.x,v1.y,max(v1.z,bridgeheight))])
|
||||||
|
#ch.points[vi]=(v1.x,v1.y,max(v1.z,bridgeheight))
|
||||||
|
|
||||||
|
if inbridge and pos[posi][1]<dist:#detect end of bridge
|
||||||
|
ratio=(dist-pos[posi][1])/v.length
|
||||||
|
point1=v2-v*ratio
|
||||||
|
point2=v2-v*ratio
|
||||||
|
if bridgeheight>point1.z:
|
||||||
|
point1.z=max(point1.z,bridgeheight)
|
||||||
|
point2.z=min(point2.z,bridgeheight)
|
||||||
|
#ch.points.insert(vi,point1)
|
||||||
|
#ch.points.insert(vi+1,point2)
|
||||||
|
#vi+=2
|
||||||
|
insertpoints.append([vi+1,point1.to_tuple()])
|
||||||
|
insertpoints.append([vi+1,point2.to_tuple()])
|
||||||
|
inbridge=False
|
||||||
|
posi+=1
|
||||||
|
vi-=1
|
||||||
|
dist-=v.length
|
||||||
|
vi+=1
|
||||||
|
|
||||||
|
|
||||||
if wasinbridge and inbridge:#still in bridge, raise the point up.#
|
|
||||||
changepoints.append([vi,(v1.x,v1.y,max(v1.z,bridgeheight))])
|
|
||||||
#ch.points[vi]=(v1.x,v1.y,max(v1.z,bridgeheight))
|
|
||||||
|
|
||||||
if inbridge and pos[posi][1]<dist:#detect end of bridge
|
|
||||||
ratio=(dist-pos[posi][1])/v.length
|
|
||||||
point1=v2-v*ratio
|
|
||||||
point2=v2-v*ratio
|
|
||||||
if bridgeheight>point1.z:
|
|
||||||
point1.z=max(point1.z,bridgeheight)
|
|
||||||
point2.z=min(point2.z,bridgeheight)
|
|
||||||
#ch.points.insert(vi,point1)
|
|
||||||
#ch.points.insert(vi+1,point2)
|
|
||||||
#vi+=2
|
|
||||||
insertpoints.append([vi+1,point1.to_tuple()])
|
|
||||||
insertpoints.append([vi+1,point2.to_tuple()])
|
|
||||||
inbridge=False
|
|
||||||
posi+=1
|
|
||||||
vi-=1
|
|
||||||
dist-=v.length
|
|
||||||
vi+=1
|
|
||||||
|
|
||||||
|
if posi>=len(pos):
|
||||||
|
#print('added bridges')
|
||||||
|
break;
|
||||||
if posi>=len(pos):
|
for p in changepoints:
|
||||||
#print('added bridges')
|
ch.points[p[0]]=p[1]
|
||||||
break;
|
for pi in range(len(insertpoints)-1,-1,-1):
|
||||||
for p in changepoints:
|
ch.points.insert(insertpoints[pi][0],insertpoints[pi][1])
|
||||||
ch.points[p[0]]=p[1]
|
|
||||||
for pi in range(len(insertpoints)-1,-1,-1):
|
|
||||||
ch.points.insert(insertpoints[pi][0],insertpoints[pi][1])
|
|
||||||
#this is the main function.
|
#this is the main function.
|
||||||
#FIXME: split strategies into separate file!
|
#FIXME: split strategies into separate file!
|
||||||
#def cutoutStrategy(o):
|
#def cutoutStrategy(o):
|
||||||
|
|
@ -2146,7 +2157,7 @@ def getPath3axis(context,operation):
|
||||||
chunk=chl[0]
|
chunk=chl[0]
|
||||||
layer=chl[1]
|
layer=chl[1]
|
||||||
if layer[1]<bridgeheight:
|
if layer[1]<bridgeheight:
|
||||||
addBridges(chunk,o,0)
|
addBridges(chunk,o)
|
||||||
|
|
||||||
if o.ramp:#add ramps or simply add chunks
|
if o.ramp:#add ramps or simply add chunks
|
||||||
for chl in extendorder:
|
for chl in extendorder:
|
||||||
|
|
|
||||||
Ładowanie…
Reference in New Issue