当前位置: 首页>>代码示例>>Python>>正文


Python Block.extend方法代码示例

本文整理汇总了Python中CNC.Block.extend方法的典型用法代码示例。如果您正苦于以下问题:Python Block.extend方法的具体用法?Python Block.extend怎么用?Python Block.extend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CNC.Block的用法示例。


在下文中一共展示了Block.extend方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: execute

# 需要导入模块: from CNC import Block [as 别名]
# 或者: from CNC.Block import extend [as 别名]
	def execute(self, app):
		#print("go!")
		blocks  = []

		paths_base = []
		paths_isl = []

		for bid in app.editor.getSelectedBlocks():
			if app.gcode[bid].operationTest('island'):
				paths_isl.extend(app.gcode.toPath(bid))
			else:
				paths_base.extend(app.gcode.toPath(bid))

		for island in paths_isl:
			paths_newbase = []
			while len(paths_base) > 0:
				base = paths_base.pop()

				base.intersectPath(island)
				island.intersectPath(base)

				newbase = Path("diff")

				#Add segments from outside of islands:
				for i,seg in enumerate(base):
					if not island.isInside(seg.midPoint()):
						newbase.append(seg)

				#Add segments from islands to base
				for i,seg in enumerate(island):
					if base.isInside(seg.midPoint()): #and base.isInside(seg.A) and base.isInside(seg.B):
						newbase.append(seg)

				#Eulerize
				paths_newbase.extend(newbase.eulerize())
				#paths_newbase.extend(newbase.split2contours())
			paths_base = paths_newbase

		for base in paths_base:
			print(base)
			#base = base.eulerize(True)
			block = Block("diff")
			block.extend(app.gcode.fromPath(base))
			blocks.append(block)

		#active = app.activeBlock()
		app.gcode.insBlocks(-1, blocks, "Diff") #<<< insert blocks over active block in the editor
		app.refresh()                                                                                           #<<< refresh editor
		app.setStatus(_("Generated: Diff"))                           #<<< feed back result
开发者ID:ThierryM,项目名称:bCNC,代码行数:51,代码来源:difference.py

示例2: execute

# 需要导入模块: from CNC import Block [as 别名]
# 或者: from CNC.Block import extend [as 别名]
	def execute(self, app):
		#print("go!")
		blocks  = []

		bid = app.editor.getSelectedBlocks()[0]
		xbasepath = app.gcode.toPath(bid)[0]

		bid = app.editor.getSelectedBlocks()[1]
		xislandpath = app.gcode.toPath(bid)[0]

		xbasepath.intersectPath(xislandpath)
		xislandpath.intersectPath(xbasepath)

		#xnewisland = self.pathBoolIntersection(xbasepath, xislandpath)
		xnewisland = self.pathBoolIntersection(xislandpath, xbasepath)

		#pth = Path("temp")
		#basepath.invert()
		#pth.extend(basepath)
		#pth.extend(basepath)
		##pth.invert()


		block = Block("intersect")
		block.extend(app.gcode.fromPath(xnewisland))
		blocks.append(block)

		#block = Block("diff")
		#block.extend(app.gcode.fromPath(pth))
		#blocks.append(block)


		active = app.activeBlock()
		app.gcode.insBlocks(active, blocks, "Intersect") #<<< insert blocks over active block in the editor
		app.refresh()                                                                                           #<<< refresh editor
		app.setStatus(_("Generated: Intersect"))                           #<<< feed back result
开发者ID:ThierryM,项目名称:bCNC,代码行数:38,代码来源:intersection.py

示例3: execute

# 需要导入模块: from CNC import Block [as 别名]
# 或者: from CNC.Block import extend [as 别名]
	def execute(self, app):
		feed = self["feed"]
		rdoc = self["rdoc"]
		radius = self["dia"]/2
		cw = self["cw"]
		circ = self["circ"]
		evenspacing = self["evenspacing"]

		if cw: cwtext = 'cw'
		else: cwtext = 'ccw'

		if cw: arcg = 'g2'
		else: arcg = 'g3'

		#print("go!")
		blocks  = []
		for bid in app.editor.getSelectedBlocks():
			#print(blocks[bid])
			path = app.gcode.toPath(bid)[0]
			#print(path)

			block = Block("trochoid "+cwtext+" "+str(radius*2)+"+"+str(rdoc))
			block.append("F"+str(feed))

			entry = self["entry"]

			A=path[0].A
			block.append("g0 x"+str(A[0])+" y"+str(A[1]))
			block.append("G1 Z0")
			for segment in path:
				#print(segment.A)
				#block.append("g0 x0 y0")
				#block.append("g1 x10 y10")
				#block.append("g1 x20 y10")
				#block.append("g0 x0 y0")
				if entry:
					eblock = Block("trochoid-in")
					eblock.append("G0 Z0")
					eblock.append("G0 x"+str(segment.A[0])+" y"+str(segment.A[1]-radius))
					eblock.append("G2 x"+str(segment.A[0])+" y"+str(segment.A[1]-radius)+" i"+str(0)+" j"+str(radius))
					blocks.append(eblock)
					entry = False

				#Continuity BEGINING
				block.append("g1 x"+str(segment.A[0])+" y"+str(segment.A[1]))
				#block.append(arcg+" x"+str(segment.A[0])+" y"+str(segment.A[1])+" r"+str(radius/2))

				phi = atan2(segment.B[1]-segment.A[1], segment.B[0]-segment.A[0])

				#TODO: handle arc segments
				#if segment.type == Segment.LINE:
				#if segment.type in (Segment.CW, Segment.CCW):

				#Compensate for uneven spacing
				srdoc = rdoc
				if evenspacing:
					subsegs = segment.length()//rdoc
					remainder = segment.length()%rdoc
					if remainder != 0:
						srdoc = segment.length()/(subsegs+1)

				#Loop over subsegmnents of segment
				i=0
				while i<(segment.length()+srdoc):
					pos=min(segment.length(), i)

					B = segment.distPoint(pos)
					block.extend(self.trochoid(A,B,radius,cw,circ))
					A = B

					i+=srdoc

				#Continuity END
				#block.append("g1 x"+str(segment.B[0])+" y"+str(segment.B[1]))
				block.append(arcg+" x"+str(segment.B[0])+" y"+str(segment.B[1])+" r"+str(radius/2))

			blocks.append(block)


		active = app.activeBlock()
		app.gcode.insBlocks(active, blocks, "Trochoidal created") #<<< insert blocks over active block in the editor
		app.refresh()                                                                                           #<<< refresh editor
		app.setStatus(_("Generated: Trochoidal"))                           #<<< feed back result
开发者ID:ThierryM,项目名称:bCNC,代码行数:85,代码来源:trochoidal.py

示例4: execute

# 需要导入模块: from CNC import Block [as 别名]
# 或者: from CNC.Block import extend [as 别名]

#.........这里部分代码省略.........
					else:
						tr_distance = self.center_distance(segm,atot)
						A = segm[0][0],segm[0][1],segm[0][2]
						d=segLength
						ae = tr_distance[4]
	#				////////////---------------------------------------------------------------------
	#				information: ---------------------------------------------------------------------
						adv = tr_distance[3] #<<< 
						ap = tr_distance[2] # << =zadd
	#			    ---------------------------------------------
						tr_block.append("(-----------------------------------------)")
						control_cameback = self.came_back(segm, oldsegm)
						if control_cameback:
							tr_block.append("(-------------> Came back !! <------------- )")#+str(control_cameback)+" )")
	#						tr_block.append("( old  Ax "+str(round(oldsegm[0][0],3))+" Ay "+str(round(oldsegm[0][1],3))+" Bx "+ str(round(oldsegm[1][0],3))+" By "+ str(round(oldsegm[1][1],3))+" )")
	#						tr_block.append("( curr Ax "+str(round(segm[0][0],3))+" Ay "+str(round(segm[0][1],3))+" Bx "+ str(round(segm[1][0],3))+" By "+ str(round(segm[1][1],3))+" )")
						if round(segLength,5) <= dtadaptative:
							adaptativepolice+=1.0
							tr_block.append("(Seg "+str(idx)+" adaptativepolice " +str(adaptativepolice)+" length "+str(round(segLength,5))+" )")
#	///////////	Trochoid method //////////////////////////////////////////////////////////////////////////////
						if adaptativepolice==0 or adaptativepolice >2.5:

							tr_block.append("( Seg: "+str(idx)+" phi "+str(round(degrees(phi),2))+ " oldphi "+str(round(degrees(oldphi),2))+" length "+str(round(segLength,5))+" )")
							tr_block.append("(ae: "+str(round(ae,5))+" dz: "+str(round(ap,4))+"adv: "+str(round(adv,4))+" )")
		#					tr_block.append("( Bx "+str(round(segm[1][0],2))+ " By "+ str(round(segm[1][1],2)))
		#					-----------------------------------------------------------------------------
		#					////////----------------------------------------------------------------------
							if control_cameback:
		#						adaptativepolice+=0.5
								B = segm[1][0],segm[1][1],segm[1][2]
		#								tr_block.append(CNC.gline(segm[1][0],segm[1][1],segm[1][2]))
								t_splice="came_back"
#								tr_block.extend(self.trochoid(t_splice,A,B,minimradius,radius,oldphi,phi,cw))
								tr_block.extend(self.trochoid(t_splice,A,B,0.0,radius,oldphi,phi,cw))
								tr_block.append("F "+ str(feed))
								t_splice = self["TypeSplice"]

							else:
								# from POINT A -- to ---> POINT B
								if segLength<=adv:
									tr_block.append("(Only one trochoid, oldphi "+str(round(degrees(oldphi),2))+" )")
									tr_block.extend(self.trochoid(t_splice,A,B,oldradius,radius,oldphi,phi,cw))
								while d >adv:
			#					first trochoid
			#						tr_block.append("d "+ str(d))
									B = A[0]+tr_distance[0], A[1]+tr_distance[1], A[2]+tr_distance[2]
								# intermediates points = trochoids points 
			#						tr_block.append(CNC.gline(B[0],B[1],B[2])) # <<< TROCHOID CENTER
		#							tr_block.extend(self.trochoid(A,B,radius,phi,oldphi,cw))

									tr_block.append("(distance to end segment "+str(round(d,4))+" )")
									tr_block.extend(self.trochoid(t_splice,A,B,oldradius,radius,oldphi,phi,cw))
									A=B
									d-=adv
									oldphi=phi
			#					last point
								if  B[0] != segm[1][0] or B[1] != segm[1][1] or B[2] != segm[1][2]:
									B = segm[1][0],segm[1][1],segm[1][2]
			#						tr_block.append(CNC.gline(B[0],B[1],B[2]))  # <<< TROCHOID CENTER
									tr_block.append("(---last trochoid, distance to end segment "+str(round(d,4))+" ---)")
									tr_block.extend(self.trochoid(t_splice,A,B,oldradius,radius,phi,phi,cw))
							adaptativepolice=0

		#	///////	Adapative method //////////////////////////////////////////////////////////////////////////////////////////////////////////
#						if oldphi==3600:
						else:
开发者ID:vlachoudis,项目名称:bCNC,代码行数:70,代码来源:trochoidal_3D.py


注:本文中的CNC.Block.extend方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。