Python FreeCADGui.SendMsgToActiveView() Examples
The following are 13
code examples of FreeCADGui.SendMsgToActiveView().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
FreeCADGui
, or try the search function
.
Example #1
Source File: pasteSVG.py From CurvesWB with GNU Lesser General Public License v2.1 | 6 votes |
def Activated(self): cb = QtGui.QApplication.clipboard() t=cb.text() if t[0:5] == '<?xml': h = importSVG.svgHandler() doc = FreeCAD.ActiveDocument if not doc: doc = FreeCAD.newDocument("SvgImport") h.doc = doc xml.sax.parseString(t,h) doc.recompute() FreeCADGui.SendMsgToActiveView("ViewFit") else: FreeCAD.Console.PrintError('Invalid clipboard content.\n') #def IsActive(self): #return(True)
Example #2
Source File: gordon_profile_FP.py From CurvesWB with GNU Lesser General Public License v2.1 | 5 votes |
def makeFeature(self, sub, pts, typ): fp = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","Freehand BSpline") proxy = GordonProfileFP(fp,sub,pts,typ) GordonProfileVP(fp.ViewObject) FreeCAD.Console.PrintMessage(GordonProfileCommand.docu) FreeCAD.ActiveDocument.recompute() FreeCADGui.SendMsgToActiveView("ViewFit") fp.ViewObject.Document.setEdit(fp.ViewObject)
Example #3
Source File: commands.py From freecad.gears with GNU General Public License v3.0 | 5 votes |
def Activated(self): Gui.doCommandGui("import freecad.gears.commands") Gui.doCommandGui("freecad.gears.commands.{}.create()".format( self.__class__.__name__)) FreeCAD.ActiveDocument.recompute() Gui.SendMsgToActiveView("ViewFit")
Example #4
Source File: a2p_importpart.py From A2plus with GNU Lesser General Public License v2.1 | 5 votes |
def GuiViewFit(self): FreeCADGui.SendMsgToActiveView("ViewFit") self.timer.stop()
Example #5
Source File: a2p_importpart.py From A2plus with GNU Lesser General Public License v2.1 | 5 votes |
def GuiViewFit(self): FreeCADGui.SendMsgToActiveView("ViewFit") self.timer.stop()
Example #6
Source File: a2p_importpart.py From A2plus with GNU Lesser General Public License v2.1 | 5 votes |
def Activated(self): doc = FreeCAD.activeDocument() try: doc.save() FreeCAD.closeDocument(doc.Name) except: FreeCADGui.SendMsgToActiveView("Save") if not FreeCADGui.activeDocument().Modified: # user really saved the file FreeCAD.closeDocument(doc.Name) # mw = FreeCADGui.getMainWindow() mdi = mw.findChild(QtGui.QMdiArea) sub = mdi.activeSubWindow() if sub != None: sub.showMaximized()
Example #7
Source File: SheetMetalUnfolder.py From FreeCAD_SheetMetal with GNU General Public License v3.0 | 5 votes |
def makeSolidExpSTEP(): doc=FreeCAD.ActiveDocument docG = FreeCADGui.ActiveDocument if doc is not None: fname = doc.FileName if len(fname) == 0: fileNm='untitled' else: fileNm = os.path.basename(fname) fileNm = os.path.splitext(fileNm)[0] tempdir = tempfile.gettempdir() # get the current temporary directory #print(tempdir) #fileNm = os.path.basename(fname) # tempfilepath = os.path.join(tempdir,fname.rstrip(".fcstd").rstrip(".FCStd") + u'_cp.stp') tempfilepath = os.path.join(tempdir,fileNm + u'_cp.stp') print(tempfilepath) sel=FreeCADGui.Selection.getSelection() if len (sel) == 1: __objs__=[] __objs__.append(sel[0]) import ImportGui stop ImportGui.export(__objs__,tempfilepath) del __objs__ # docG.getObject(sel[0].Name).Visibility = False ImportGui.insert(tempfilepath,doc.Name) FreeCADGui.SendMsgToActiveView("ViewFit") else: FreeCAD.Console.PrintError('Select only one object') else: FreeCAD.Console.PrintError('Select only one object') ##
Example #8
Source File: Commands.py From NodeEditor with MIT License | 4 votes |
def refresh_gui(): store=saveGraph(False) # say(store) loadGraph(store) return sayl("REFRESH---------") hidePyFlow() # tempd=pfwrap.getInstance().getTempDirectory() instance=pfwrap.getInstance() saveData = instance.graphManager.get().serialize() gg=pfwrap.getGraphManager().getAllGraphs()[0] say(gg) #geaendert # saveData = pfwrap.getGraphManager().serialize() # saveData = pfwrap.getGraphManager().serialize() # json.dump(saveData, f, indent=4) #saveData = gg.serialize() sayl("naCH SE") import tempfile f = tempfile.NamedTemporaryFile(delete=False) fpath= f.name say("HUEW") say(saveData) say(f) say("---------------") json.dump(saveData, f, indent=4) f.close() say("fname",fpath) sayl("CCC") with open(fpath, 'r') as f: data = json.load(f) FreeCAD.data=data pfwrap.getInstance().loadFromData(data, fpath) sayl("huhu") pfwrap.getInstance().show() clearLogger() FreeCADGui.activeDocument().activeView().viewIsometric() FreeCADGui.SendMsgToActiveView("ViewFit")
Example #9
Source File: main_generator.py From kicad-3d-models-in-freecad with GNU General Public License v2.0 | 4 votes |
def make_3D_model(models_dir, model_class, modelID): LIST_license = ["",] CheckedmodelName = modelID.replace('.', '').replace('-', '_').replace('(', '').replace(')', '') Newdoc = App.newDocument(CheckedmodelName) App.setActiveDocument(CheckedmodelName) Gui.ActiveDocument=Gui.getDocument(CheckedmodelName) destination_dir = model_class.get_dest_3D_dir(modelID) material_substitutions = model_class.make_3D_model(modelID) modelName = model_class.get_model_name(modelID) doc = FreeCAD.ActiveDocument doc.Label = CheckedmodelName objs=GetListOfObjects(FreeCAD, doc) objs[0].Label = CheckedmodelName restore_Main_Tools() script_dir=os.path.dirname(os.path.realpath(__file__)) expVRML.say(models_dir) out_dir=models_dir+os.sep+destination_dir if not os.path.exists(out_dir): os.makedirs(out_dir) exportSTEP(doc, modelName, out_dir) if LIST_license[0]=="": LIST_license=Lic.LIST_int_license LIST_license.append("") Lic.addLicenseToStep(out_dir + os.sep, modelName+".step", LIST_license,\ STR_licAuthor, STR_licEmail, STR_licOrgSys, STR_licOrg, STR_licPreProc) # scale and export Vrml model scale=1/2.54 #exportVRML(doc,modelName,scale,out_dir) del objs objs=GetListOfObjects(FreeCAD, doc) expVRML.say("######################################################################") expVRML.say(objs) expVRML.say("######################################################################") export_objects, used_color_keys = expVRML.determineColors(Gui, objs, material_substitutions) export_file_name=out_dir+os.sep+modelName+'.wrl' colored_meshes = expVRML.getColoredMesh(Gui, export_objects , scale) #expVRML.writeVRMLFile(colored_meshes, export_file_name, used_color_keys)# , LIST_license expVRML.writeVRMLFile(colored_meshes, export_file_name, used_color_keys, LIST_license) #scale=0.3937001 #exportVRML(doc,modelName,scale,out_dir) # Save the doc in Native FC format saveFCdoc(App, Gui, doc, modelName,out_dir) #display BBox Gui.activateWorkbench("PartWorkbench") Gui.SendMsgToActiveView("ViewFit") Gui.activeDocument().activeView().viewAxometric() #FreeCADGui.ActiveDocument.activeObject.BoundingBox = True
Example #10
Source File: main_generator.py From kicad-3d-models-in-freecad with GNU General Public License v2.0 | 4 votes |
def make_3D_model(models_dir, model_class, modelID): LIST_license = ["",] CheckedmodelName = 'A_' + modelID.replace('.', '').replace('-', '_').replace('(', '').replace(')', '') CheckedmodelName = CheckedmodelName Newdoc = App.newDocument(CheckedmodelName) App.setActiveDocument(CheckedmodelName) Gui.ActiveDocument=Gui.getDocument(CheckedmodelName) destination_dir = model_class.get_dest_3D_dir(modelID) material_substitutions = model_class.make_3D_model(modelID) modelName = model_class.get_model_name(modelID) doc = FreeCAD.ActiveDocument doc.Label = CheckedmodelName objs=GetListOfObjects(FreeCAD, doc) objs[0].Label = CheckedmodelName restore_Main_Tools() script_dir=os.path.dirname(os.path.realpath(__file__)) expVRML.say(models_dir) out_dir=models_dir+os.sep+destination_dir if not os.path.exists(out_dir): os.makedirs(out_dir) exportSTEP(doc, modelName, out_dir) if LIST_license[0]=="": LIST_license=Lic.LIST_int_license LIST_license.append("") Lic.addLicenseToStep(out_dir + os.sep, modelName+".step", LIST_license,\ STR_licAuthor, STR_licEmail, STR_licOrgSys, STR_licOrg, STR_licPreProc) # scale and export Vrml model scale=1/2.54 #exportVRML(doc,modelName,scale,out_dir) del objs objs=GetListOfObjects(FreeCAD, doc) expVRML.say("######################################################################") expVRML.say(objs) expVRML.say("######################################################################") export_objects, used_color_keys = expVRML.determineColors(Gui, objs, material_substitutions) export_file_name=out_dir+os.sep+modelName+'.wrl' colored_meshes = expVRML.getColoredMesh(Gui, export_objects , scale) #expVRML.writeVRMLFile(colored_meshes, export_file_name, used_color_keys)# , LIST_license expVRML.writeVRMLFile(colored_meshes, export_file_name, used_color_keys, LIST_license) #scale=0.3937001 #exportVRML(doc,modelName,scale,out_dir) # Save the doc in Native FC format saveFCdoc(App, Gui, doc, modelName,out_dir) #display BBox Gui.activateWorkbench("PartWorkbench") Gui.SendMsgToActiveView("ViewFit") Gui.activeDocument().activeView().viewAxometric() #FreeCADGui.ActiveDocument.activeObject.BoundingBox = True
Example #11
Source File: main_generator.py From kicad-3d-models-in-freecad with GNU General Public License v2.0 | 4 votes |
def make_3D_model(models_dir, model_class, modelName): LIST_license = ["",] CheckedmodelName = modelName.replace('.', '').replace('-', '_').replace('(', '').replace(')', '') Newdoc = App.newDocument(CheckedmodelName) App.setActiveDocument(CheckedmodelName) Gui.ActiveDocument=Gui.getDocument(CheckedmodelName) destination_dir = model_class.get_dest_3D_dir() material_substitutions = model_class.make_3D_model(modelName) doc = FreeCAD.ActiveDocument doc.Label = CheckedmodelName objs=GetListOfObjects(FreeCAD, doc) objs[0].Label = CheckedmodelName restore_Main_Tools() script_dir=os.path.dirname(os.path.realpath(__file__)) expVRML.say(models_dir) out_dir=models_dir+os.sep+destination_dir if not os.path.exists(out_dir): os.makedirs(out_dir) exportSTEP(doc, modelName, out_dir) if LIST_license[0]=="": LIST_license=Lic.LIST_int_license LIST_license.append("") Lic.addLicenseToStep(out_dir+'/', modelName+".step", LIST_license,\ STR_licAuthor, STR_licEmail, STR_licOrgSys, STR_licOrg, STR_licPreProc) # scale and export Vrml model scale=1/2.54 #exportVRML(doc,modelName,scale,out_dir) del objs objs=GetListOfObjects(FreeCAD, doc) expVRML.say("######################################################################") expVRML.say(objs) expVRML.say("######################################################################") export_objects, used_color_keys = expVRML.determineColors(Gui, objs, material_substitutions) export_file_name=out_dir+os.sep+modelName+'.wrl' colored_meshes = expVRML.getColoredMesh(Gui, export_objects , scale) #expVRML.writeVRMLFile(colored_meshes, export_file_name, used_color_keys)# , LIST_license expVRML.writeVRMLFile(colored_meshes, export_file_name, used_color_keys, LIST_license) #scale=0.3937001 #exportVRML(doc,modelName,scale,out_dir) # Save the doc in Native FC format saveFCdoc(App, Gui, doc, modelName,out_dir) #display BBox Gui.activateWorkbench("PartWorkbench") Gui.SendMsgToActiveView("ViewFit") Gui.activeDocument().activeView().viewAxometric() #FreeCADGui.ActiveDocument.activeObject.BoundingBox = True
Example #12
Source File: main_generator.py From kicad-3d-models-in-freecad with GNU General Public License v2.0 | 4 votes |
def make_3D_model(models_dir, model_class, modelID): LIST_license = ["",] CheckedmodelName = 'A_' + modelID.replace('.', '').replace('-', '_').replace('(', '').replace(')', '') CheckedmodelName = CheckedmodelName Newdoc = App.newDocument(CheckedmodelName) App.setActiveDocument(CheckedmodelName) Gui.ActiveDocument=Gui.getDocument(CheckedmodelName) destination_dir = model_class.get_dest_3D_dir(modelID) material_substitutions = model_class.make_3D_model(modelID) modelName = model_class.get_model_name(modelID) doc = FreeCAD.ActiveDocument doc.Label = CheckedmodelName objs=GetListOfObjects(FreeCAD, doc) objs[0].Label = CheckedmodelName restore_Main_Tools() script_dir=os.path.dirname(os.path.realpath(__file__)) expVRML.say(models_dir) out_dir=models_dir+os.sep+destination_dir if not os.path.exists(out_dir): os.makedirs(out_dir) exportSTEP(doc, modelName, out_dir) if LIST_license[0]=="": LIST_license=Lic.LIST_int_license LIST_license.append("") Lic.addLicenseToStep(out_dir + os.sep, modelName+".step", LIST_license,\ STR_licAuthor, STR_licEmail, STR_licOrgSys, STR_licOrg, STR_licPreProc) # scale and export Vrml model scale=1/2.54 #exportVRML(doc,modelName,scale,out_dir) del objs objs=GetListOfObjects(FreeCAD, doc) expVRML.say("######################################################################") expVRML.say(objs) expVRML.say("######################################################################") export_objects, used_color_keys = expVRML.determineColors(Gui, objs, material_substitutions) export_file_name=out_dir+os.sep+modelName+'.wrl' colored_meshes = expVRML.getColoredMesh(Gui, export_objects , scale) #expVRML.writeVRMLFile(colored_meshes, export_file_name, used_color_keys)# , LIST_license expVRML.writeVRMLFile(colored_meshes, export_file_name, used_color_keys, LIST_license) #scale=0.3937001 #exportVRML(doc,modelName,scale,out_dir) # Save the doc in Native FC format saveFCdoc(App, Gui, doc, modelName,out_dir) #display BBox Gui.activateWorkbench("PartWorkbench") Gui.SendMsgToActiveView("ViewFit") Gui.activeDocument().activeView().viewAxometric() #FreeCADGui.ActiveDocument.activeObject.BoundingBox = True
Example #13
Source File: main_generator.py From kicad-3d-models-in-freecad with GNU General Public License v2.0 | 4 votes |
def make_3D_model(models_dir, model_class, modelID): LIST_license = ["",] CheckedmodelName = modelID.replace('.', '').replace('-', '_').replace('(', '').replace(')', '') Newdoc = App.newDocument(CheckedmodelName) App.setActiveDocument(CheckedmodelName) Gui.ActiveDocument=Gui.getDocument(CheckedmodelName) destination_dir = model_class.get_dest_3D_dir(modelID) material_substitutions = model_class.make_3D_model(modelID) modelName = model_class.get_model_name(modelID) doc = FreeCAD.ActiveDocument doc.Label = CheckedmodelName objs=GetListOfObjects(FreeCAD, doc) objs[0].Label = CheckedmodelName restore_Main_Tools() script_dir=os.path.dirname(os.path.realpath(__file__)) expVRML.say(models_dir) out_dir=models_dir+os.sep+destination_dir if not os.path.exists(out_dir): os.makedirs(out_dir) exportSTEP(doc, modelName, out_dir) if LIST_license[0]=="": LIST_license=Lic.LIST_int_license LIST_license.append("") Lic.addLicenseToStep(out_dir + os.sep, modelName+".step", LIST_license,\ STR_licAuthor, STR_licEmail, STR_licOrgSys, STR_licOrg, STR_licPreProc) # scale and export Vrml model scale=1/2.54 #exportVRML(doc,modelName,scale,out_dir) del objs objs=GetListOfObjects(FreeCAD, doc) expVRML.say("######################################################################") expVRML.say(objs) expVRML.say("######################################################################") export_objects, used_color_keys = expVRML.determineColors(Gui, objs, material_substitutions) export_file_name=out_dir+os.sep+modelName+'.wrl' colored_meshes = expVRML.getColoredMesh(Gui, export_objects , scale) #expVRML.writeVRMLFile(colored_meshes, export_file_name, used_color_keys)# , LIST_license expVRML.writeVRMLFile(colored_meshes, export_file_name, used_color_keys, LIST_license) #scale=0.3937001 #exportVRML(doc,modelName,scale,out_dir) # Save the doc in Native FC format saveFCdoc(App, Gui, doc, modelName,out_dir) #display BBox Gui.activateWorkbench("PartWorkbench") Gui.SendMsgToActiveView("ViewFit") Gui.activeDocument().activeView().viewAxometric() #FreeCADGui.ActiveDocument.activeObject.BoundingBox = True