def makeFaceDXF(): global copper_diffuse, silks_diffuse global use_LinkGroups, use_AppPart doc = FreeCAD.ActiveDocument if doc is None: FreeCAD.newDocument() doc = FreeCAD.ActiveDocument docG = FreeCADGui.ActiveDocument Filter = "" last_pcb_path = "" pg = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/kicadStepUp") last_pcb_path = pg.GetString("last_pcb_path") fn, Filter = PySide.QtGui.QFileDialog.getOpenFileNames( None, "Open File...", make_unicode(last_pcb_path), "*.dxf") for fname in fn: path, name = os.path.split(fname) filename = os.path.splitext(name)[0] #importDXF.open(os.path.join(dirname,filename)) if len(fname) > 0: #importDXF.open(fname) last_pcb_path = os.path.dirname(fname) pg = FreeCAD.ParamGet( "User parameter:BaseApp/Preferences/Mod/kicadStepUp") pg.SetString("last_pcb_path", make_string(last_pcb_path)) # py3 .decode("utf-8") pg = FreeCAD.ParamGet( "User parameter:BaseApp/Preferences/Mod/kicadStepUpGui") pcb_color_pos = pg.GetInt('pcb_color') #print(pcb_color_pos) if pcb_color_pos == 9: silks_diffuse = (0.18, 0.18, 0.18) #slick black else: silks_diffuse = ( 0.98, 0.92, 0.84 ) # #antique white # white (0.906,0.906,0.910) doc = FreeCAD.ActiveDocument objects = [] say("loading... ") t = time.time() if doc is not None: for o in doc.Objects: objects.append(o.Name) importDXF.insert(fname, doc.Name) else: importDXF.open(fname) FreeCADGui.SendMsgToActiveView("ViewFit") timeP = time.time() - t say("loading time = " + str(timeP) + "s") edges = [] sorted_edges = [] w = [] for o in doc.Objects: if o.Name not in str(objects): if hasattr(o, 'Shape'): w1 = Part.Wire(Part.__sortEdges__(o.Shape.Edges)) w.append(w1) #print (w) f = Part.makeFace(w, 'Part::FaceMakerBullseye') for o in doc.Objects: if o.Name not in str(objects): doc.removeObject(o.Name) if 'Silk' in filename: layerName = 'Silks' else: layerName = 'Tracks' if 'F.' in filename or 'F_' in filename: layerName = 'top' + layerName if 'B.' in filename or 'B_' in filename: layerName = 'bot' + layerName doc.addObject('Part::Feature', layerName).Shape = f newShape = doc.ActiveObject botOffset = 1.6 if 'Silk' in layerName: docG.getObject(newShape.Name).ShapeColor = silks_diffuse else: docG.getObject( newShape.Name ).ShapeColor = brass_diffuse #copper_diffuse #(0.78,0.56,0.11) if len(doc.getObjectsByLabel('Pcb')) > 0: newShape.Placement = doc.getObjectsByLabel('Pcb')[0].Placement #botTracks.Placement = doc.Pcb.Placement if len(doc.getObjectsByLabel('Board_Geoms')) > 0: if use_AppPart and not use_LinkGroups: doc.getObject('Board_Geoms').addObject(newShape) elif use_LinkGroups: doc.getObject('Board_Geoms').ViewObject.dropObject( newShape, None, '', []) if hasattr(doc.getObjectsByLabel('Pcb')[0], 'Shape'): botOffset = doc.getObjectsByLabel( 'Pcb')[0].Shape.BoundBox.ZLength else: botOffset = doc.getObjectsByLabel( 'Pcb')[0].OutList[1].Shape.BoundBox.ZLength #elif 'bot' in layerName: # newShape.Placement.Base.z-=1.6 if 'top' in layerName: newShape.Placement.Base.z += 0.07 if 'bot' in layerName: newShape.Placement.Base.z -= botOffset + 0.07 timeD = time.time() - t - timeP say("displaying time = " + str(timeD) + "s") FreeCADGui.SendMsgToActiveView("ViewFit") docG.activeView().viewAxonometric()
def addtracks(fname=None): global start_time, last_pcb_path, min_drill_size global use_LinkGroups, use_AppPart, tracks_version import sys # cfg_read_all() it doesn't work through different files # print (min_drill_size) FreeCAD.Console.PrintMessage('tracks version: ' + tracks_version + '\n') Filter = "" pg = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/kicadStepUp") if fname is None: last_pcb_path = pg.GetString("last_pcb_path") if len(last_pcb_path) == 0: last_pcb_path = "" fname, Filter = PySide.QtGui.QFileDialog.getOpenFileName( None, "Open File...", make_unicode(last_pcb_path), "*.kicad_pcb") path, name = os.path.split(fname) #filename=os.path.splitext(name)[0] filename = fname #importDXF.open(os.path.join(dirname,filename)) if len(fname) > 0: start_time = current_milli_time() last_pcb_path = os.path.dirname(fname) path, ftname = os.path.split(fname) ftname = os.path.splitext(ftname)[0] ftname_sfx = crc_gen_t(make_unicode_t(ftname)) pg = FreeCAD.ParamGet( "User parameter:BaseApp/Preferences/Mod/kicadStepUp") pg.SetString("last_pcb_path", make_string(last_pcb_path)) # py3 .decode("utf-8") prefs = FreeCAD.ParamGet( "User parameter:BaseApp/Preferences/Mod/kicadStepUpGui") pcb_color_pos = prefs.GetInt('pcb_color') #pcb_color_values = [light_green,blue,red,purple,darkgreen,darkblue,lightblue,yellow,black,white] assign_col = [ '#41c382', '#2474cf', '#ff4000', '#9a1a85', '#3c7f5d', '#426091', '#005fff', '#fff956', '#4d4d4d', '#f0f0f0' ] #print(pcb_color_pos) trk_col = (assign_col[pcb_color_pos]) if pcb_color_pos == 9: slk_col = '#2d2d2d' else: slk_col = '#f8f8f0' # mypcb = KicadPCB.load(filename) # pcbThickness = float(mypcb.general.thickness) #print (mypcb.general.thickness) #print(mypcb.layers) #if version>=4: Top_lvl = 0 Bot_lvl = 31 #for lynbr in mypcb.layers: #getting layers name # if float(lynbr) == Top_lvl: # LvlTopName=(mypcb.layers['{0}'.format(str(lynbr))][0]) # if float(lynbr) == Bot_lvl: # LvlBotName=(mypcb.layers['{0}'.format(str(lynbr))][0]) #print(LvlTopName,' ',LvlBotName) import kicad_parser # reload_lib(kicad_parser) pcb = kicad_parser.KicadFcad(filename) # pcbThickness = pcb.board_thickness ## this doesn't always give the full board thickness # print(pcbThickness,'pcbThickness') mypcb = KicadPCB.load(filename) pcbThickness = float(mypcb.general.thickness) # print(pcbThickness,'mypcb.pcbThickness') #pcbThickness = float(pcb.general.thickness) #pcb.setLayer(LvlTopName) minSizeDrill = 0.0 #0.8 #print(pcb.colors) # https://www.seeedstudio.com/blog/2017/07/23/why-are-printed-circuit-boards-are-usually-green-in-colour/ # <span style="color: #105e7d;">deep-sea blue</span></strong>, <strong><span style="color: #ff2f00;">Ferrari red</span></strong>, <strong><span style="color: #ffcc00;">sunshine yellow</span></strong>, <strong>slick black</strong>, <span style="color: #999999;"><strong>pure white</strong></span> and of course <strong><span style="color: #339966;">good</span></strong> <strong><span style="color: #339966;">ol’ green</span> # (r/255.0,g/255.0,b/255.0) pcb_col = pcb.colors #zone_col = pcb_col['zone'][0] #track_col = pcb_col['track'][0] pcb_col['track'][0] = mkColor(trk_col) pcb_col['zone'][0] = mkColor(trk_col) # print(pcb_col['track'][0]) # print(pcb_col['pad'][0]) # print(pcb_col) #pcb_col['track'][0] = mkColor('#147b9d') #pcb_col['zone'][0] = mkColor('#147b9d') #pcb.colors = { # 'board':mkColor("0x3A6629"), # 'pad':{0:mkColor(219,188,126)}, # 'zone':{0:mkColor('#147b9d')}, # 'track':{0:mkColor(26,157,204)}, # 'copper':{0:mkColor(200,117,51)}, #} #pcb.colors={'board':(1.,1.,1.),'pad':{0:(219/255,188/255,126/255)},'zone':{0:(0.,1.,0.)},'track':{0:(0.,1.,1.)},'copper':{0:(0.,1.,1.)},} pcb.setLayer(Top_lvl) #try: #doing top tracks layer ## pcb.makeCopper(holes=True, minSize=minSizeDrill) # pcb.make(copper_thickness=0.035, board_thickness=pcbThickness, combo=False, fuseCoppers=True ) # pcb.makeCopper(holes=True,fuse=False) # say_time() # stop topPads = None topTracks = None topZones = None deltaz = 0.01 #10 micron if FreeCAD.ActiveDocument is not None: objsNum = len(FreeCAD.ActiveDocument.Objects) else: objsNum = 0 pcb.makePads(shape_type='face', thickness=0.05, holes=True, fit_arcs=True) #,prefix='') if FreeCAD.ActiveDocument is not None: if objsNum < len(FreeCAD.ActiveDocument.Objects): pads = FreeCAD.ActiveDocument.ActiveObject pads.Placement.Base.z = pads.Placement.Base.z + 2 * deltaz new_obj = simple_cpy(pads, 'topPads' + ftname_sfx) say_time() removesubtree([pads]) topPads = new_obj if FreeCAD.ActiveDocument is not None: objsNum = len(FreeCAD.ActiveDocument.Objects) pcb.makeTracks(shape_type='face', fit_arcs=True, thickness=0.05, holes=True) #,prefix='') if FreeCAD.ActiveDocument is not None: if objsNum < len(FreeCAD.ActiveDocument.Objects): say_time() tracks = FreeCAD.ActiveDocument.ActiveObject tracks.Placement.Base.z += deltaz new_obj = simple_cpy(tracks, 'topTracks' + ftname_sfx) say_time() removesubtree([tracks]) topTracks = new_obj #stop if FreeCAD.ActiveDocument is not None: objsNum = len(FreeCAD.ActiveDocument.Objects) pcb.makeZones(shape_type='face', thickness=0.05, fit_arcs=True, holes=True) #,prefix='') if FreeCAD.ActiveDocument is not None: if objsNum < len(FreeCAD.ActiveDocument.Objects): say_time() zones = FreeCAD.ActiveDocument.ActiveObject zones.Placement.Base.z += deltaz new_obj = simple_cpy(zones, 'topZones' + ftname_sfx) say_time() removesubtree([zones]) topZones = new_obj if len(FreeCAD.ActiveDocument.getObjectsByLabel('Pcb' + ftname_sfx)) > 0: #PCB_Sketch_5737 pcb_sk = FreeCAD.ActiveDocument.getObject('PCB_Sketch' + ftname_sfx) ### check if BBOx pcb > BBOx tracks if topPads is not None: topPads.Placement = FreeCAD.ActiveDocument.getObject( 'Pcb' + ftname_sfx).Placement if (topPads.Shape.BoundBox.XLength > pcb_sk.Shape.BoundBox.XLength) or \ (topPads.Shape.BoundBox.YLength > pcb_sk.Shape.BoundBox.YLength): topPads_cut_Name = cut_out_tracks( pcb_sk, topPads, ftname_sfx) topPads = FreeCAD.ActiveDocument.getObject( topPads_cut_Name) topPads.Placement.Base.z += 2 * deltaz if topTracks is not None: topTracks.Placement = FreeCAD.ActiveDocument.getObject( 'Pcb' + ftname_sfx).Placement topTracks.Placement.Base.z += deltaz if topZones is not None: topZones.Placement = FreeCAD.ActiveDocument.getObject( 'Pcb' + ftname_sfx).Placement topZones.Placement.Base.z += deltaz if len( FreeCAD.ActiveDocument.getObjectsByLabel( 'Board_Geoms' + ftname_sfx)) > 0: if use_AppPart and not use_LinkGroups: if topPads is not None: FreeCAD.ActiveDocument.getObject( 'Board_Geoms' + ftname_sfx).addObject(topPads) if topTracks is not None: FreeCAD.ActiveDocument.getObject( 'Board_Geoms' + ftname_sfx).addObject(topTracks) if topZones is not None: FreeCAD.ActiveDocument.getObject( 'Board_Geoms' + ftname_sfx).addObject(topZones) elif use_LinkGroups: if topPads is not None: FreeCAD.ActiveDocument.getObject( 'Board_Geoms' + ftname_sfx).ViewObject.dropObject( topPads, None, '', []) if topTracks is not None: FreeCAD.ActiveDocument.getObject( 'Board_Geoms' + ftname_sfx).ViewObject.dropObject( topTracks, None, '', []) if topZones is not None: FreeCAD.ActiveDocument.getObject( 'Board_Geoms' + ftname_sfx).ViewObject.dropObject( topZones, None, '', []) #try: #doing bot tracks layer #pcb.setLayer(LvlBotName) pcb.setLayer(Bot_lvl) # pcb.makeCopper(holes=True, minSize=minSizeDrill) #pcb.makeCopper(holes=True) botPads = None botTracks = None botZones = None if FreeCAD.ActiveDocument is not None: objsNum = len(FreeCAD.ActiveDocument.Objects) else: objsNum = 0 pcb.makePads(shape_type='face', thickness=0.05, holes=True, fit_arcs=True, prefix='') if FreeCAD.ActiveDocument is not None: if objsNum < len(FreeCAD.ActiveDocument.Objects): doc = FreeCAD.ActiveDocument pads = FreeCAD.ActiveDocument.ActiveObject pads.Placement.Base.z = pads.Placement.Base.z - (pcbThickness + 2 * deltaz) new_obj = simple_cpy(pads, 'botPads' + ftname_sfx) say_time() removesubtree([pads]) botPads = new_obj if FreeCAD.ActiveDocument is not None: objsNum = len(FreeCAD.ActiveDocument.Objects) pcb.makeTracks(shape_type='face', fit_arcs=True, thickness=0.05, holes=True, prefix='') if FreeCAD.ActiveDocument is not None: if objsNum < len(FreeCAD.ActiveDocument.Objects): say_time() tracks = FreeCAD.ActiveDocument.ActiveObject tracks.Placement.Base.z = tracks.Placement.Base.z - ( pcbThickness + deltaz) new_obj = simple_cpy(tracks, 'botTracks' + ftname_sfx) say_time() removesubtree([tracks]) botTracks = new_obj #stop if FreeCAD.ActiveDocument is not None: objsNum = len(FreeCAD.ActiveDocument.Objects) pcb.makeZones(shape_type='face', thickness=0.05, fit_arcs=True, holes=True) # ,prefix='') if FreeCAD.ActiveDocument is not None: if objsNum < len(FreeCAD.ActiveDocument.Objects): say_time() zones = FreeCAD.ActiveDocument.ActiveObject zones.Placement.Base.z = zones.Placement.Base.z - ( pcbThickness + deltaz) new_obj = simple_cpy(zones, 'botZones' + ftname_sfx) say_time() removesubtree([zones]) botZones = new_obj if len(FreeCAD.ActiveDocument.getObjectsByLabel('Pcb' + ftname_sfx)) > 0: #PCB_Sketch_5737 pcb_sk = FreeCAD.ActiveDocument.getObject('PCB_Sketch' + ftname_sfx) ### check if BBOx pcb > BBOx tracks if botPads is not None: botPads.Placement = FreeCAD.ActiveDocument.getObject( 'Pcb' + ftname_sfx).Placement if (botPads.Shape.BoundBox.XLength > pcb_sk.Shape.BoundBox.XLength) or \ (botPads.Shape.BoundBox.YLength > pcb_sk.Shape.BoundBox.YLength): botPads_cut_Name = cut_out_tracks( pcb_sk, botPads, ftname_sfx) botPads = FreeCAD.ActiveDocument.getObject( botPads_cut_Name) botPads.Placement.Base.z -= pcbThickness + 2 * deltaz if botTracks is not None: botTracks.Placement = FreeCAD.ActiveDocument.getObject( 'Pcb' + ftname_sfx).Placement botTracks.Placement.Base.z -= pcbThickness + deltaz if botZones is not None: botZones.Placement = FreeCAD.ActiveDocument.getObject( 'Pcb' + ftname_sfx).Placement botZones.Placement.Base.z -= pcbThickness + deltaz if len( FreeCAD.ActiveDocument.getObjectsByLabel( 'Board_Geoms' + ftname_sfx)) > 0: if use_AppPart and not use_LinkGroups: if botPads is not None: FreeCAD.ActiveDocument.getObject( 'Board_Geoms' + ftname_sfx).addObject(botPads) if botTracks is not None: FreeCAD.ActiveDocument.getObject( 'Board_Geoms' + ftname_sfx).addObject(botTracks) if botZones is not None: FreeCAD.ActiveDocument.getObject( 'Board_Geoms' + ftname_sfx).addObject(botZones) elif use_LinkGroups: if botPads is not None: FreeCAD.ActiveDocument.getObject( 'Board_Geoms' + ftname_sfx).ViewObject.dropObject( botPads, None, '', []) if botTracks is not None: FreeCAD.ActiveDocument.getObject( 'Board_Geoms' + ftname_sfx).ViewObject.dropObject( botTracks, None, '', []) if botZones is not None: FreeCAD.ActiveDocument.getObject( 'Board_Geoms' + ftname_sfx).ViewObject.dropObject( botZones, None, '', []) say_time() if FreeCAD.ActiveDocument is not None: FreeCADGui.SendMsgToActiveView("ViewFit") FreeCADGui.ActiveDocument.activeView().viewAxonometric()
def addtracks(): global start_time, last_pcb_path, min_drill_size global use_LinkGroups, use_AppPart, tracks_version import sys # cfg_read_all() it doesn't work through different files # print (min_drill_size) FreeCAD.Console.PrintMessage('tracks version: ' + tracks_version + '\n') Filter = "" pg = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/kicadStepUp") last_pcb_path = pg.GetString("last_pcb_path") if len(last_pcb_path) == 0: last_pcb_path = "" fname, Filter = PySide.QtGui.QFileDialog.getOpenFileName( None, "Open File...", make_unicode(last_pcb_path), "*.kicad_pcb") path, name = os.path.split(fname) #filename=os.path.splitext(name)[0] filename = fname #importDXF.open(os.path.join(dirname,filename)) if len(fname) > 0: start_time = current_milli_time() last_pcb_path = os.path.dirname(fname) path, ftname = os.path.split(fname) ftname = os.path.splitext(ftname)[0] ftname_sfx = crc_gen_t(make_unicode_t(ftname)) pg = FreeCAD.ParamGet( "User parameter:BaseApp/Preferences/Mod/kicadStepUp") pg.SetString("last_pcb_path", make_string(last_pcb_path)) # py3 .decode("utf-8") prefs = FreeCAD.ParamGet( "User parameter:BaseApp/Preferences/Mod/kicadStepUpGui") pcb_color_pos = prefs.GetInt('pcb_color') #pcb_color_values = [light_green,blue,red,purple,darkgreen,darkblue,lightblue,yellow,black,white] assign_col = [ '#41c382', '#2474cf', '#ff4000', '#9a1a85', '#3c7f5d', '#426091', '#005fff', '#fff956', '#4d4d4d', '#f0f0f0' ] #print(pcb_color_pos) trk_col = (assign_col[pcb_color_pos]) if pcb_color_pos == 9: slk_col = '#2d2d2d' else: slk_col = '#f8f8f0' mypcb = KicadPCB.load(filename) pcbThickness = float(mypcb.general.thickness) #print (mypcb.general.thickness) #print(mypcb.layers) #if version>=4: Top_lvl = 0 Bot_lvl = 31 #for lynbr in mypcb.layers: #getting layers name # if float(lynbr) == Top_lvl: # LvlTopName=(mypcb.layers['{0}'.format(str(lynbr))][0]) # if float(lynbr) == Bot_lvl: # LvlBotName=(mypcb.layers['{0}'.format(str(lynbr))][0]) #print(LvlTopName,' ',LvlBotName) import kicad_parser reload_lib(kicad_parser) pcb = kicad_parser.KicadFcad(filename) #pcb.setLayer(LvlTopName) minSizeDrill = 0.0 #0.8 #print(pcb.colors) # https://www.seeedstudio.com/blog/2017/07/23/why-are-printed-circuit-boards-are-usually-green-in-colour/ # <span style="color: #105e7d;">deep-sea blue</span></strong>, <strong><span style="color: #ff2f00;">Ferrari red</span></strong>, <strong><span style="color: #ffcc00;">sunshine yellow</span></strong>, <strong>slick black</strong>, <span style="color: #999999;"><strong>pure white</strong></span> and of course <strong><span style="color: #339966;">good</span></strong> <strong><span style="color: #339966;">ol’ green</span> # (r/255.0,g/255.0,b/255.0) pcb_col = pcb.colors #zone_col = pcb_col['zone'][0] #track_col = pcb_col['track'][0] pcb_col['track'][0] = mkColor(trk_col) pcb_col['zone'][0] = mkColor(trk_col) #pcb_col['track'][0] = mkColor('#147b9d') #pcb_col['zone'][0] = mkColor('#147b9d') #pcb.colors = { # 'board':mkColor("0x3A6629"), # 'pad':{0:mkColor(219,188,126)}, # 'zone':{0:mkColor('#147b9d')}, # 'track':{0:mkColor(26,157,204)}, # 'copper':{0:mkColor(200,117,51)}, #} #pcb.colors={'board':(1.,1.,1.),'pad':{0:(219/255,188/255,126/255)},'zone':{0:(0.,1.,0.)},'track':{0:(0.,1.,1.)},'copper':{0:(0.,1.,1.)},} pcb.setLayer(Top_lvl) #try: #doing top tracks layer pcb.makeCopper(holes=True, minSize=minSizeDrill) doc = FreeCAD.ActiveDocument docG = FreeCADGui.ActiveDocument deltaz = 0.01 #10 micron composed = doc.ActiveObject s = composed.Shape doc.addObject('Part::Feature', 'topTracks' + ftname_sfx).Shape = composed.Shape topTracks = doc.ActiveObject #print (doc.ActiveObject.Label) #print (topTracks.Label) docG.ActiveObject.ShapeColor = docG.getObject(composed.Name).ShapeColor docG.ActiveObject.LineColor = docG.getObject(composed.Name).LineColor docG.ActiveObject.PointColor = docG.getObject(composed.Name).PointColor docG.ActiveObject.DiffuseColor = docG.getObject( composed.Name).DiffuseColor #doc.recompute() #doc.addObject('Part::Feature',"topTraks").Shape=s topTracks.Label = "topTracks" + ftname_sfx topTracks.Placement = FreeCAD.Placement( FreeCAD.Vector(0, 0, deltaz), FreeCAD.Rotation(FreeCAD.Vector(0, 0, 1), 0)) #if hasattr(doc.Pcb, 'Shape'): #if len (doc.getObjectsByLabel('Pcb')) >0: if len(doc.getObjectsByLabel('Pcb' + ftname_sfx)) > 0: topTracks.Placement = doc.getObject('Pcb' + ftname_sfx).Placement topTracks.Placement.Base.z += deltaz if len(doc.getObjectsByLabel('Board_Geoms' + ftname_sfx)) > 0: if use_AppPart and not use_LinkGroups: doc.getObject('Board_Geoms' + ftname_sfx).addObject(topTracks) elif use_LinkGroups: doc.getObject('Board_Geoms' + ftname_sfx).ViewObject.dropObject( topTracks, None, '', []) #topTracks.Placement = FreeCAD.Placement(FreeCAD.Vector(0,0,0.05),FreeCAD.Rotation(FreeCAD.Vector(0,0,1),0)) ##docG.getObject(topTracks.Name).Transparency=40 if 0: docG.getObject(topTracks.Name).ShapeColor = (0.78, 0.46, 0.20) FreeCADGui.Selection.clearSelection() FreeCADGui.Selection.addSelection(doc.getObject(composed.Name)) #stop removesubtree(FreeCADGui.Selection.getSelection()) say_time() #except Exception as e: # exc_type, exc_obj, exc_tb = sys.exc_info() # fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] # FreeCAD.Console.PrintError('error class: '+str(exc_type)+'\nfile name: '+str(fname)+'\nerror @line: '+str(exc_tb.tb_lineno)+'\nerror value: '+str(e.args[0])+'\n') #try: #doing bot tracks layer #pcb.setLayer(LvlBotName) pcb.setLayer(Bot_lvl) pcb.makeCopper(holes=True, minSize=minSizeDrill) composed = doc.ActiveObject s = composed.Shape doc.addObject('Part::Feature', 'botTracks' + ftname_sfx).Shape = composed.Shape botTracks = doc.ActiveObject #print (doc.ActiveObject.Label) #print (topTracks.Label) docG.ActiveObject.ShapeColor = docG.getObject(composed.Name).ShapeColor docG.ActiveObject.LineColor = docG.getObject(composed.Name).LineColor docG.ActiveObject.PointColor = docG.getObject(composed.Name).PointColor docG.ActiveObject.DiffuseColor = docG.getObject( composed.Name).DiffuseColor #doc.recompute() #doc.addObject('Part::Feature',"topTraks").Shape=s botTracks.Label = "botTracks" + ftname_sfx botTracks.Placement = FreeCAD.Placement( FreeCAD.Vector(0, 0, -1.6 - deltaz), FreeCAD.Rotation(FreeCAD.Vector(0, 0, 1), 0)) #if hasattr(doc.Pcb, 'Shape'): ##docG.getObject(botTracks.Name).Transparency=40 if 0: docG.getObject(botTracks.Name).ShapeColor = (0.78, 0.46, 0.20) FreeCADGui.Selection.clearSelection() FreeCADGui.Selection.addSelection(doc.getObject(composed.Name)) removesubtree(FreeCADGui.Selection.getSelection()) #if hasattr(doc.Pcb, 'Shape'): if len(doc.getObjectsByLabel('Pcb' + ftname_sfx)) > 0: botTracks.Placement = doc.getObject('Pcb' + ftname_sfx).Placement #botTracks.Placement = doc.Pcb.Placement botTracks.Placement.Base.z -= pcbThickness + deltaz if len(doc.getObjectsByLabel('Board_Geoms' + ftname_sfx)) > 0: if use_AppPart and not use_LinkGroups: doc.getObject('Board_Geoms' + ftname_sfx).addObject(botTracks) elif use_LinkGroups: doc.getObject('Board_Geoms' + ftname_sfx).ViewObject.dropObject( botTracks, None, '', []) #botTracks = FreeCAD.ActiveDocument.ActiveObject #botTracks.Label="botTracks" #botTracks.Placement = FreeCAD.Placement(FreeCAD.Vector(0,0,-1.6),FreeCAD.Rotation(FreeCAD.Vector(0,0,1),0)) #docG.ActiveObject.Transparency=40 #except Exception as e: # exc_type, exc_obj, exc_tb = sys.exc_info() # fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] # FreeCAD.Console.PrintError('error class: '+str(exc_type)+'\nfile name: '+str(fname)+'\nerror @line: '+str(exc_tb.tb_lineno)+'\nerror value: '+str(e.args[0])+'\n') say_time() FreeCADGui.SendMsgToActiveView("ViewFit") docG.activeView().viewAxonometric()