kopia lustrzana https://github.com/vilemduha/blendercam
				
				
				
			- started moving operations into seperate functions
							rodzic
							
								
									8e40df25cb
								
							
						
					
					
						commit
						09004a5fea
					
				|  | @ -2058,23 +2058,14 @@ def addBridges(ch,o): | ||||||
| 				ch.points[p[0]]=p[1] | 				ch.points[p[0]]=p[1] | ||||||
| 			for pi in range(len(insertpoints)-1,-1,-1): | 			for pi in range(len(insertpoints)-1,-1,-1): | ||||||
| 				ch.points.insert(insertpoints[pi][0],insertpoints[pi][1]) | 				ch.points.insert(insertpoints[pi][0],insertpoints[pi][1]) | ||||||
| #this is the main function. |  | ||||||
| #FIXME: split strategies into separate file! |  | ||||||
| #def cutoutStrategy(o): |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| def getPath3axis(context,operation): |  | ||||||
| 	s=bpy.context.scene |  | ||||||
| 	o=operation |  | ||||||
| 	getBounds(o) |  | ||||||
| 	 |  | ||||||
| 
 | 
 | ||||||
| ###########cutout strategy is completely here: | ###########cutout strategy is completely here: | ||||||
| 	if o.strategy=='CUTOUT': | def strategy_cutout( o ): | ||||||
| 	#ob=bpy.context.active_object | 	#ob=bpy.context.active_object | ||||||
|  | 	print('operation: cutout') | ||||||
| 	offset=True | 	offset=True | ||||||
| 	if o.cut_type=='ONLINE' and o.onlycurves==True:#is separate to allow open curves :) | 	if o.cut_type=='ONLINE' and o.onlycurves==True:#is separate to allow open curves :) | ||||||
| 			print('separe') | 		print('separate') | ||||||
| 		chunksFromCurve=[] | 		chunksFromCurve=[] | ||||||
| 		for ob in o.objects: | 		for ob in o.objects: | ||||||
| 			chunksFromCurve.extend(curveToChunks(ob)) | 			chunksFromCurve.extend(curveToChunks(ob)) | ||||||
|  | @ -2174,11 +2165,10 @@ def getPath3axis(context,operation): | ||||||
| 		for chl in extendorder: | 		for chl in extendorder: | ||||||
| 			chunks.append(chl[0]) | 			chunks.append(chl[0]) | ||||||
| 
 | 
 | ||||||
| 		 |  | ||||||
| 
 |  | ||||||
| 	chunksToMesh(chunks,o) | 	chunksToMesh(chunks,o) | ||||||
| 
 | 
 | ||||||
| 	elif o.strategy=='CURVE': | def strategy_curve( o ): | ||||||
|  | 	print('operation: curve') | ||||||
| 	pathSamples=[] | 	pathSamples=[] | ||||||
| 	getOperationSources(o) | 	getOperationSources(o) | ||||||
| 	if not o.onlycurves: | 	if not o.onlycurves: | ||||||
|  | @ -2196,9 +2186,8 @@ def getPath3axis(context,operation): | ||||||
| 			 | 			 | ||||||
| 	chunksToMesh(pathSamples,o) | 	chunksToMesh(pathSamples,o) | ||||||
| 	 | 	 | ||||||
| 		 | def strategy_proj_curve( s, o ): | ||||||
| 		 | 	print('operation: projected curve') | ||||||
| 	if o.strategy=='PROJECTED_CURVE': |  | ||||||
| 	pathSamples = [] | 	pathSamples = [] | ||||||
| 	chunks = [] | 	chunks = [] | ||||||
| 	ob = bpy.data.objects[o.curve_object] | 	ob = bpy.data.objects[o.curve_object] | ||||||
|  | @ -2251,7 +2240,6 @@ def getPath3axis(context,operation): | ||||||
| 				ep -= vece | 				ep -= vece | ||||||
| 				ch.endpoints.append(ep) | 				ch.endpoints.append(ep) | ||||||
| 						 | 						 | ||||||
| 					 |  | ||||||
| 				ch.rotations.append((0,0,0)) | 				ch.rotations.append((0,0,0)) | ||||||
| 				 | 				 | ||||||
| 				vec = sp - ep | 				vec = sp - ep | ||||||
|  | @ -2259,7 +2247,6 @@ def getPath3axis(context,operation): | ||||||
| 				ch.points[i] = sp.copy() | 				ch.points[i] = sp.copy() | ||||||
| 			 | 			 | ||||||
| 			 | 			 | ||||||
| 			 |  | ||||||
| 	if o.use_layers: | 	if o.use_layers: | ||||||
| 		n = math.ceil(-(ch.depth/o.stepdown)) | 		n = math.ceil(-(ch.depth/o.stepdown)) | ||||||
| 		layers = [] | 		layers = [] | ||||||
|  | @ -2278,8 +2265,28 @@ def getPath3axis(context,operation): | ||||||
| 	#	ch.points=ch.endpoints | 	#	ch.points=ch.endpoints | ||||||
| 	chunksToMesh(chunks,o) | 	chunksToMesh(chunks,o) | ||||||
| 
 | 
 | ||||||
|  | def strategy_pocket( o ): | ||||||
| 	 | 	 | ||||||
| 	if o.strategy=='POCKET':	 | 	 | ||||||
|  | #this is the main function. | ||||||
|  | #FIXME: split strategies into separate file! | ||||||
|  | #def cutoutStrategy(o): | ||||||
|  | def getPath3axis(context, operation): | ||||||
|  | 	s=bpy.context.scene | ||||||
|  | 	o=operation | ||||||
|  | 	getBounds(o) | ||||||
|  | 	 | ||||||
|  | 	 | ||||||
|  | 	if o.strategy=='CUTOUT': | ||||||
|  | 		strategy_cutout( o ) | ||||||
|  | 		 | ||||||
|  | 	elif o.strategy=='CURVE': | ||||||
|  | 		strategy_curve( o ) | ||||||
|  | 				 | ||||||
|  | 	elif o.strategy=='PROJECTED_CURVE': | ||||||
|  | 		strategy_proj_curve(s, o) | ||||||
|  | 		 | ||||||
|  | 	elif o.strategy=='POCKET':	 | ||||||
| 		p=getObjectOutline(o.cutter_diameter/2,o,False) | 		p=getObjectOutline(o.cutter_diameter/2,o,False) | ||||||
| 		all=Polygon.Polygon(p) | 		all=Polygon.Polygon(p) | ||||||
| 		approxn=(min(o.max.x-o.min.x,o.max.y-o.min.y)/o.dist_between_paths)/2 | 		approxn=(min(o.max.x-o.min.x,o.max.y-o.min.y)/o.dist_between_paths)/2 | ||||||
|  | @ -2834,6 +2841,7 @@ def getPath3axis(context,operation): | ||||||
| 		chunks=sortChunks(chunks,o) | 		chunks=sortChunks(chunks,o) | ||||||
| 		print(chunks) | 		print(chunks) | ||||||
| 		chunksToMesh(chunks,o) | 		chunksToMesh(chunks,o) | ||||||
|  | 		 | ||||||
| 	elif o.strategy=='MEDIAL_AXIS': | 	elif o.strategy=='MEDIAL_AXIS': | ||||||
| 		print('doing highly experimental stuff') | 		print('doing highly experimental stuff') | ||||||
| 		 | 		 | ||||||
|  |  | ||||||
		Ładowanie…
	
		Reference in New Issue
	
	 Jeff Doyle (nfz)
						Jeff Doyle (nfz)