Lines Matching refs:layer

31 10 Jun Put 3D into a separate layer called 3D, created unless it already exists
1697 def draw(self, group, style, layer, transform, num = 0, reverse_angle = 1):
1698 st = P(gcodetools.transform(self.st.to_list(), layer, True))
1699 c = P(gcodetools.transform(self.c.to_list(), layer, True))
1753 def draw(self, group, style, layer, transform, num = 0, reverse_angle = 1):
1754 st = gcodetools.transform(self.st.to_list(), layer, True)
1755 end = gcodetools.transform(self.end.to_list(), layer, True)
1837 def draw(self, layer, group=None, style=styles["biarc_style"]):
1849 gcodetools.preview_groups = { layer: inkex.etree.SubElement( gcodetools.layers[min(1,len(gcodetools.layers)-1)], inkex.addNS('g','svg'), {"gcodetools": "Preview group"} ) }
1850 elif layer not in gcodetools.preview_groups :
1851 gcodetools.preview_groups[layer] = inkex.etree.SubElement( gcodetools.layers[min(1,len(gcodetools.layers)-1)], inkex.addNS('g','svg'), {"gcodetools": "Preview group"} )
1852 group = gcodetools.preview_groups[layer]
1861 a,b,c = gcodetools.transform(a, layer, True), gcodetools.transform(b, layer, True), gcodetools.transform(c, layer, True)
1871 item.draw(group, style, layer, transform, num, reverse_angle)
3328 for layer in self.layers :
3329 if layer in self.selected_paths :
3330 max_dist = self.transform_scalar(self.options.in_out_path_point_max_dist, layer, reverse=True)
3331 l = self.transform_scalar(self.options.in_out_path_len, layer, reverse=True)
3332 plasma_l = self.transform_scalar(self.options.plasma_prepare_corners_distance, layer, reverse=True)
3333 r = self.transform_scalar(self.options.in_out_path_radius, layer, reverse=True)
3336 for path in self.selected_paths[layer]:
3430 for layer in self.layers :
3431 if layer in paths :
3432 for path in paths[layer] :
3577 self.OptionParser.add_option("", "--path-to-gcode-order", action="store", type="string", dest="path_to_gcode_order", default="path by path", help="Defines cutting order path by path or layer by layer.")
3710 def parse_curve(self, p, layer, w = None, f = None):
3714 p = self.transform_csp(p, layer)
3745 def draw_csp(self, csp, layer=None, group=None, fill='none', stroke='#178ade', width=0.354, style=None):
3746 if layer!=None :
3747 csp = self.transform_csp(csp,layer,reverse=True)
3748 if group==None and layer==None:
3750 elif group==None and layer!=None :
3751 group = layer
3761 def draw_curve(self, curve, layer, group=None, style=styles["biarc_style"]):
3772 self.preview_groups = { layer: inkex.etree.SubElement( self.layers[min(1,len(self.layers)-1)], inkex.addNS('g','svg'), {"gcodetools": "Preview group"} ) }
3773 elif layer not in self.preview_groups :
3774 self.preview_groups[layer] = inkex.etree.SubElement( self.layers[min(1,len(self.layers)-1)], inkex.addNS('g','svg'), {"gcodetools": "Preview group"} )
3775 group = self.preview_groups[layer]
3786 a,b,c = self.transform(a, layer, True), self.transform(b, layer, True), self.transform(c, layer, True)
3791 si[0], si[2] = self.transform(si[0], layer, True), (self.transform(si[2], layer, True) if type(si[2])==type([]) and len(si[2])==2 else si[2])
3908 def generate_gcode(self, curve, layer, depth):
3909 Zauto_scale = self.Zauto_scale[layer]
3910 tool = self.tools[layer][0]
4031 def transform_scalar(self,x,layer,reverse=False):
4032 return self.transform([x,0],layer,reverse)[0] - self.transform([0,0],layer,reverse)[0]
4034 def transform(self,source_point, layer, reverse=False):
4035 if layer not in self.transform_matrix:
4036 for i in range(self.layers.index(layer),-1,-1):
4040 self.error(_("Orientation points for '%s' layer have not been found! Please add orientation points using Orientation tab!") % layer.get(inkex.addNS('label','inkscape')),"no_orientation_points")
4042 self.transform_matrix[layer] = self.transform_matrix[self.layers[i]]
4043 self.Zcoordinates[layer] = self.Zcoordinates[self.layers[i]]
4047 self.error(_("There are more than one orientation point groups in '%s' layer") % orientation_layer.get(inkex.addNS('label','inkscape')),"more_than_one_orientation_point_groups")
4056 self.Zcoordinates[layer] = [max(points[0][1][2],points[1][1][2]), min(points[0][1][2],points[1][1][2])]
4075 self.transform_matrix[layer] = [[m[j*3+i][0] for i in range(3)] for j in range(3)]
4082 self.transform_matrix_reverse[layer] = numpy.linalg.inv(self.transform_matrix[layer]).tolist()
4083 print_("\n Layer '%s' transformation matrixes:" % layer.get(inkex.addNS('label','inkscape')) )
4087 ###self.Zauto_scale[layer] = math.sqrt( (self.transform_matrix[layer][0][0]**2 + self.transform_matrix[layer][1][1]**2)/2 )
4089 self.Zauto_scale[layer] = 1
4090 print_("Z automatic scale = %s (computed according orientation points)" % self.Zauto_scale[layer])
4094 t = self.transform_matrix[layer]
4096 t = self.transform_matrix_reverse[layer]
4100 def transform_csp(self, csp_, layer, reverse = False):
4105 csp[i][j][k] = self.transform(csp[i][j][k],layer, reverse)
4231 def recursive_search(g, layer, selected=False):
4237 if i.tag == inkex.addNS("g",'svg') and i.get(inkex.addNS('groupmode','inkscape')) == 'layer':
4247 self.orientation_points[layer] = self.orientation_points[layer]+[points[:]] if layer in self.orientation_points else [points[:]]
4248 print_("Found orientation points in '%s' layer: %s" % (layer.get(inkex.addNS('label','inkscape')), points))
4250 self.error(_("Warning! Found bad orientation points in '%s' layer. Resulting Gcode could be corrupt!") % layer.get(inkex.addNS('label','inkscape')), "bad_orientation_points_in_some_layers")
4255 self.tools[layer] = self.tools[layer] + [tool.copy()] if layer in self.tools else [tool.copy()]
4256 print_("Found tool in '%s' layer: %s" % (layer.get(inkex.addNS('label','inkscape')), tool))
4261 self.graffiti_reference_points[layer] = self.graffiti_reference_points[layer]+[point[:]] if layer in self.graffiti_reference_points else [point]
4263 self.error(_("Warning! Found bad graffiti reference point in '%s' layer. Resulting Gcode could be corrupt!") % layer.get(inkex.addNS('label','inkscape')), "bad_orientation_points_in_some_layers")
4267 self.paths[layer] = self.paths[layer] + [i] if layer in self.paths else [i]
4269 self.selected_paths[layer] = self.selected_paths[layer] + [i] if layer in self.selected_paths else [i]
4280 recursive_search(i,layer, (i.get("id") in self.selected) )
4290 self.error(_("Document has no layers! Add at least one layer using layers panel (Ctrl+Shift+L)"),"Error")
4294 self.error(_("Warning! There are some paths in the root of the document, but not in any layer! Using bottom-most layer for them."), "tools_warning" )
4378 def set_tool(self,layer):
4379 # print_(("index(layer)=",self.layers.index(layer),"set_tool():layer=",layer,"self.tools=",self.tools))
4382 for i in range(self.layers.index(layer),-1,-1):
4383 # print_(("processing layer",i))
4387 if self.layers[i] != layer : self.tools[layer] = self.tools[self.layers[i]]
4388 if len(self.tools[layer])>1 : self.error(_("Layer '%s' contains more than one tool!") % self.layers[i].get(inkex.addNS('label','inkscape')), "more_than_one_tool")
4389 return self.tools[layer]
4391 self.error(_("Can not find tool for '%s' layer! Please add one with Tools library tab!") % layer.get(inkex.addNS('label','inkscape')), "no_tool_error")
4508 gcode +="(drilling dxfpoint)\nG00 Z%f\nG00 X%f Y%f\nG01 Z%f F%f\nG04 P%f\nG00 Z%f\n" % (self.options.Zsafe,point[0],point[1],self.Zcoordinates[layer][1],self.tools[layer][0]["penetration feed"],0.2,self.options.Zsafe)
4536 for layer in self.layers :
4537 if layer in paths :
4538 print_(("layer",layer))
4540 self.transform_csp([ [ [[0,0],[0,0],[0,0]], [[0,0],[0,0],[0,0]] ] ], layer)
4542 self.set_tool(layer)
4551 for path in paths[layer] :
4578 tmp_curve=self.transform_csp(csp, layer)
4585 zd,zs = self.Zcoordinates[layer][1], self.Zcoordinates[layer][0]
4590 [ self.parse_curve([subpath], layer) for subpath in csp ]
4601 self.draw_curve(subcurve, layer)
4618 for step in range( 0, int(math.ceil( abs((zs-d)/self.tools[layer][0]["depth step"] )) ) ):
4619 z = max(d, zs - abs(self.tools[layer][0]["depth step"]*(step+1)))
4626 gcode += self.generate_gcode(curve, layer, z)
4632 for step in range( 0, int(math.ceil( abs((zs-mind)/self.tools[layer][0]["depth step"] )) ) ):
4633 z = zs - abs(self.tools[layer][0]["depth step"]*(step))
4639 z = zs - abs(self.tools[layer][0]["depth step"]*(step+1))
4653 gcode += self.generate_gcode(subcurve, layer, max(z,curves_[key][0][1]))
4668 for layer in self.layers :
4669 if layer in self.selected_paths :
4670 for path in self.selected_paths[layer]:
4702 for layer in paths :
4703 # paths[layer].reverse() # Reverse list of paths to leave their order
4704 for path in paths[layer] :
4752 for layer in self.layers :
4753 if layer in self.selected_paths :
4754 self.set_tool(layer)
4755 if self.tools[layer][0]['diameter']<=0 :
4756 self.error(_("Tool diameter must be > 0 but tool's diameter on '%s' layer is not!") % layer.get(inkex.addNS('label','inkscape')),"area_tools_diameter_error")
4758 for path in self.selected_paths[layer]:
4810 p0 = self.transform([0,0],layer)
4811 p1 = self.transform([0,1],layer)
4816 tool_d = self.tools[layer][0]['diameter']*scale
4950 for layer in self.layers :
4951 if layer in self.selected_paths :
4952 for path in self.selected_paths[layer]:
4960 csp = self.transform_csp(csp, layer)
4965 self.draw_csp([ [ [point,point,point] for point in subpoly] for subpoly in poly ],layer)
4998 for layer in self.layers :
4999 if layer in self.selected_paths :
5000 self.set_tool(layer)
5001 if self.tools[layer][0]['diameter']<=0 :
5002 self.error(_("Tool diameter must be > 0 but tool's diameter on '%s' layer is not!") % layer.get(inkex.addNS('label','inkscape')),"area_tools_diameter_error")
5003 tool = self.tools[layer][0]
5004 for path in self.selected_paths[layer]:
5016 csp = self.transform_csp(csp, layer)
5117 #p = self.transform(p,layer,True)
5147 csp_line = self.transform_csp(csp_line, layer, True)
5164 #layer number n appears in XML as <svg:g id="layern" inkscape:label="layername">
5169 #Mylayer.set(inkex.addNS('groupmode', 'inkscape'), 'layer') #Tells Inkscape it's a layer
5175 # where parent may be the layer or a parent group. To get the parent group, you can use
5176 #parent = self.selected_paths[layer][0].getparent()
5525 for layer in self.layers :
5526 if layer in self.selected_paths :
5528 p1=self.orientation_points[layer][0][0]
5529 p2=self.orientation_points[layer][0][1]
5535 self.set_tool(layer)
5536 shape = self.tools[layer][0]['shape']
5540 self.error(_("Tool '%s' has no shape. 45 degree cone assumed!") % self.tools[layer][0]['name'],"Continue")
5543 toolr=self.tools[layer][0]['diameter'] * orientation_scale/2
5546 max_distuu = min(self.tools[layer][0]['diameter']/2, self.options.engraving_max_dist)
5550 engraving_group = inkex.etree.SubElement( self.selected_paths[layer][0].getparent(), inkex.addNS('g','svg') )
5554 self.my3Dlayer.set(inkex.addNS('groupmode', 'inkscape'), 'layer') #Tells Inkscape it's a layer
5560 for node in self.selected_paths[layer] :
5575 #Create copies in 3D layer
5595 #Copy it to 3D layer objects
5655 #Copy complete paths to 3D layer
5790 #LT4 for each selected object in this layer - ends here
5793 curve = self.parse_curve(cspe, layer, we, toolshape) #convert to lines
5794 self.draw_curve(curve, layer, engraving_group)
5795 gcode += self.generate_gcode(curve, layer, self.options.Zsurface)
5800 self.header+="(Depth, as a function of radius w, must be "+ self.tools[layer][0]['shape']+ ")\n"
5812 def orientation(self, layer=None) :
5814 if layer == None :
5815 layer = self.current_layer if self.current_layer is not None else self.document.getroot()
5817 transform = self.get_transforms(layer)
5825 if layer in self.graffiti_reference_points: graffiti_reference_points_count = len(self.graffiti_reference_points[layer])
5831 g = inkex.etree.SubElement(layer, inkex.addNS('g','svg'), attr)
5847 if layer in self.orientation_points:
5848 self.error(_("Active layer already has orientation points! Remove them or select another layer!"),"active_layer_already_has_orientation_points")
5854 orientation_group = inkex.etree.SubElement(layer, inkex.addNS('g','svg'), attr)
5888 def tools_library(self, layer=None) :
5890 if layer == None :
5891 layer = self.current_layer if self.current_layer is not None else self.document.getroot()
5892 if layer in self.tools:
5893 self.error(_("Active layer already has a tool! Remove it or select another layer!"),"active_layer_already_has_tool")
5977 tools_group = inkex.etree.SubElement(layer, inkex.addNS('g','svg'), {'gcodetools': "Gcodetools tool definition"})
6020 for layer in self.layers :
6021 if layer in paths :
6022 self.set_tool(layer)
6023 tool = self.tools[layer][0]
6024 tools_bounds[layer] = tools_bounds[layer] if layer in tools_bounds else [float("inf"),float("-inf")]
6026 for path in paths[layer] :
6041 tools_bounds[layer] = [min(tools_bounds[layer][0], path_bounds[1]), max(tools_bounds[layer][1], path_bounds[3])]
6047 for layer in self.layers :
6048 if layer in self.tools :
6049 if layer in tools_bounds :
6050 tool = self.tools[layer][0]
6053 trans = [[1,0.3,bounds[2]],[0,0.5,tools_bounds[layer][0]]]
6069 def generate_lathe_gcode(self, subpath, layer, feed_type) :
6077 #draw_csp(self.transform_csp([subpath],layer,True), color = "Orange", width = .1)
6083 self.draw_curve(c, layer, style = styles["biarc_style_lathe_%s" % feed_type])
6120 for layer in self.layers :
6121 if layer in paths :
6122 self.set_tool(layer)
6123 if self.tool != self.tools[layer][0] :
6124 self.tool = self.tools[layer][0]
6130 for path in paths[layer]:
6131 csp = self.transform_csp(cubicsuperpath.parsePath(path.get("d")),layer)
6151 #draw_csp(self.transform_csp(offsetted_subpath,layer,True), color = "Green", width = 1)
6182 gcode += self.generate_lathe_gcode(part,layer,"passing feed")
6184 gcode += self.generate_lathe_gcode(part,layer,"feed")
6188 gcode += self.generate_lathe_gcode(part,layer,"feed")
6216 gcode += self.generate_lathe_gcode(current_pass,layer,"fine feed")
6236 for layer in self.layers :
6237 if layer in paths :
6239 #self.set_tool(layer)
6240 for path in paths[layer]:
6241 csp = self.transform_csp(cubicsuperpath.parsePath(path.get("d")),layer)
6286 self.draw_csp(new_csp,layer)
6329 def get_gcode_coordinates(point,layer):
6332 for ref_point in self.graffiti_reference_points[layer] :
6358 def draw_graffiti_segment(layer,start,end,feed,color=(0,255,0,40),emmit=1000):
6362 c1,c2 = self.graffiti_reference_points[layer][0][0],self.graffiti_reference_points[layer][1][0]
6411 #draw_csp(self.transform_csp([[ [[C1.x-r*sin,C1.y+r*cos]]*3,[[C2.x-r*sin,C2.y+r*cos]]*3 ]],layer,reverse=True), color = "#00ff00;" )
6412 #draw_pointer(self.transform(C1.to_list(),layer,reverse=True))
6413 #draw_pointer(self.transform(C2.to_list(),layer,reverse=True))
6440 for layer in self.layers :
6441 if layer in paths :
6443 if layer not in self.graffiti_reference_points:
6445 for i in range(self.layers.index(layer),-1,-1):
6448 self.graffiti_reference_points[layer] = self.graffiti_reference_points[self.layers[i]]
6451 self.error('There are no graffiti reference points for layer %s'%layer,"error")
6454 for i in range(len(self.graffiti_reference_points[layer])):
6455 self.graffiti_reference_points[layer][i][0] = self.transform(self.graffiti_reference_points[layer][i][0], layer)
6456 point = self.graffiti_reference_points[layer][i]
6460 for point in self.graffiti_reference_points[layer]:
6462 for path in paths[layer]:
6465 csp = self.transform_csp(csp, layer)
6473 for layer in self.layers :
6474 if layer in paths :
6484 self.set_tool(layer)
6485 self.tool = self.tools[layer][0]
6486 # Change tool every layer. (Probably layer = color so it'll be
6491 for path in paths[layer]:
6495 csp = self.transform_csp(csp, layer)
6579 draw_csp(self.transform_csp([csp],layer,reverse=True), color = "#00cc00;" if polyline_[0]=='draw' else "#ff5555;")
6587 last_real_pos, g = get_gcode_coordinates(polyline[0],layer)
6592 real_pos, g = get_gcode_coordinates(point,layer)
6599 draw_graffiti_segment(layer,real_pos,last_real_pos,feed,color=(0,0,255,200) if polyline_[0] == "draw" else (255,0,0,200),emmit=self.options.graffiti_preview_emmit)
6609 for layer in self.graffiti_reference_points:
6610 for point in self.graffiti_reference_points[layer] :
6705 for layer in self.selected_paths :
6706 if len(self.selected_paths[layer]) == 2 :
6707 csp1, csp2 = cubicsuperpath.parsePath(self.selected_paths[layer][0].get("d")), cubicsuperpath.parsePath(self.selected_paths[layer][1].get("d"))
6717 for layer in self.selected_paths :
6718 for path in self.selected_paths[layer] :