#*************************************************************************** #* * #* Copyright (c) 2012 * #* Yorik van Havre <*****@*****.**> * #* * #* This program is free software; you can redistribute it and/or modify * #* it under the terms of the GNU Lesser General Public License (LGPL) * #* as published by the Free Software Foundation; either version 2 of * #* the License, or (at your option) any later version. * #* for detail see the LICENCE text file. * #* * #* This program is distributed in the hope that it will be useful, * #* but WITHOUT ANY WARRANTY; without even the implied warranty of * #* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * #* GNU Library General Public License for more details. * #* * #* You should have received a copy of the GNU Library General Public * #* License along with this program; if not, write to the Free Software * #* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * #* USA * #* * #*************************************************************************** import FreeCAD, FreeCADGui, sys rf = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/RecentFiles") FreeCAD.loadFile(rf.GetString("MRU2"))
import FreeCADGui import Part #import PySide2 import Draft import Import if len(sys.argv)<3: print ("Usage: sys.argv[0] <in_file> <out_file>") sys.exit(1) iname=sys.argv[1] oname=sys.argv[2] print('Importing : '+iname) FreeCAD.loadFile(iname) # iterate through all objects for o in App.ActiveDocument.Objects: # find root object and export the shape #print(dir(o)) #print(o.Name) if o.TypeId == 'App::Part' : #print(o.TypeId) print('Exporting STEP file : '+oname) print('This can be a very slow process') print('for large files Please be patient') #Import.export([o],"/tmp/test4.step") Import.export([o],oname) sys.exit(0)
#* License along with this program; if not, write to the Free Software * #* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * #* USA * #* * #*************************************************************************** import os import FreeCAD import FreeCADGui from urllib.parse import unquote # filename will be given before this script is run cfolders = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Start").GetString("ShowCustomFolder","") if cfolders: dirnumber = int(filename[0]) filename = filename[2:] cfolder = cfolders.split(";;")[dirnumber] if not os.path.isdir(cfolder): cfolder = os.path.dirname(cfolder) f = unquote(filename).replace("+", " ") if f.lower().endswith(".fcstd"): FreeCAD.open(os.path.join(cfolder, f)) else: FreeCAD.loadFile(os.path.join(cfolder, f)) FreeCADGui.activeDocument().sendMsgToViews("ViewFit") from StartPage import StartPage StartPage.postStart()
#*************************************************************************** #* * #* Copyright (c) 2012 * #* Yorik van Havre <*****@*****.**> * #* * #* This program is free software; you can redistribute it and/or modify * #* it under the terms of the GNU Lesser General Public License (LGPL) * #* as published by the Free Software Foundation; either version 2 of * #* the License, or (at your option) any later version. * #* for detail see the LICENCE text file. * #* * #* This program is distributed in the hope that it will be useful, * #* but WITHOUT ANY WARRANTY; without even the implied warranty of * #* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * #* GNU Library General Public License for more details. * #* * #* You should have received a copy of the GNU Library General Public * #* License along with this program; if not, write to the Free Software * #* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * #* USA * #* * #*************************************************************************** import FreeCAD,FreeCADGui,sys rf=FreeCAD.ParamGet("User parameter:BaseApp/Preferences/RecentFiles") FreeCAD.loadFile(rf.GetString("MRU2"))
#*************************************************************************** #* * #* Copyright (c) 2016 * #* Bernd Hahnebach <*****@*****.**> * #* * #* This program is free software; you can redistribute it and/or modify * #* it under the terms of the GNU Lesser General Public License (LGPL) * #* as published by the Free Software Foundation; either version 2 of * #* the License, or (at your option) any later version. * #* for detail see the LICENCE text file. * #* * #* This program is distributed in the hope that it will be useful, * #* but WITHOUT ANY WARRANTY; without even the implied warranty of * #* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * #* GNU Library General Public License for more details. * #* * #* You should have received a copy of the GNU Library General Public * #* License along with this program; if not, write to the Free Software * #* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * #* USA * #* * #*************************************************************************** import FreeCAD,FreeCADGui,os # filename will be given before this script is run FreeCAD.loadFile(os.path.join(FreeCAD.getResourceDir()+"examples",filename)) FreeCADGui.activeDocument().sendMsgToViews("ViewFit") from StartPage import StartPage StartPage.postStart()
def open_file(self, path): """ Open the path as a separate file in FC """ App.loadFile(path)
#* Copyright (c) 2016 Bernd Hahnebach <*****@*****.**> * #* * #* This program is free software; you can redistribute it and/or modify * #* it under the terms of the GNU Lesser General Public License (LGPL) * #* as published by the Free Software Foundation; either version 2 of * #* the License, or (at your option) any later version. * #* for detail see the LICENCE text file. * #* * #* This program is distributed in the hope that it will be useful, * #* but WITHOUT ANY WARRANTY; without even the implied warranty of * #* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * #* GNU Library General Public License for more details. * #* * #* You should have received a copy of the GNU Library General Public * #* License along with this program; if not, write to the Free Software * #* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * #* USA * #* * #*************************************************************************** import os import FreeCAD import FreeCADGui # filename will be given before this script is run FreeCAD.loadFile(os.path.join(FreeCAD.getResourceDir() + "examples", filename)) FreeCADGui.activeDocument().sendMsgToViews("ViewFit") from StartPage import StartPage StartPage.postStart()
import FreeCAD import FreeCADGui from xml.dom import minidom import inspect import Mesh import sys import os FreeCADGui.setupWithoutGUI() path = os.getcwd + "/" + sys.argv[1] print(path) FreeCAD.loadFile(path) documents = FreeCAD.activeDocument() members = inspect.getmembers(documents) doc = minidom.parseString(members[3][1]) parts = doc.getElementsByTagName("Object") __objs__ = [] typelist = ["Part::Feature", "App::Part"] for p in parts: if p.attributes['type'].value in typelist: __objs__.append(documents.getObject(p.attributes['name'].value)) print("exporting")
def open_file(self, path): ''' Open the path as a separate file in FC ''' App.loadFile(path)
# ----------------------------------------------------------------------------- # # Private license: 2020, EnVis # # ----------------------------------------------------------------------------- """Tests for the workbench.""" import FreeCAD import EnVisBruttoFaces FreeCAD.loadFile('BruttoFl_2.FCStd') layer = FreeCAD.ActiveDocument.getObjectsByLabel("IfcSpaceBoundaries")[0] EnVisBruttoFaces.createModel(layer)
#*************************************************************************** #* * #* Copyright (c) 2018 Yorik van Havre <*****@*****.**> * #* * #* This program is free software; you can redistribute it and/or modify * #* it under the terms of the GNU Lesser General Public License (LGPL) * #* as published by the Free Software Foundation; either version 2 of * #* the License, or (at your option) any later version. * #* for detail see the LICENCE text file. * #* * #* This program is distributed in the hope that it will be useful, * #* but WITHOUT ANY WARRANTY; without even the implied warranty of * #* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * #* GNU Library General Public License for more details. * #* * #* You should have received a copy of the GNU Library General Public * #* License along with this program; if not, write to the Free Software * #* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * #* USA * #* * #*************************************************************************** import FreeCAD,sys # MRU will be given before this script is run rf=FreeCAD.ParamGet("User parameter:BaseApp/Preferences/RecentFiles") FreeCAD.loadFile(rf.GetString("MRU"+str(MRU))) from StartPage import StartPage StartPage.postStart()