def insert(self, index=None): import FreeCADGui if not index: index = self.form.tree.selectedIndexes() if not index: return index = index[0] if self.modelmode == 1: path = self.dirmodel.filePath(index) else: path = self.filemodel.itemFromIndex(index).toolTip() if path.startswith(":github"): path = self.download( LIBRARYURL.replace("/tree", "/raw") + "/" + path[7:]) before = FreeCAD.ActiveDocument.Objects self.name = os.path.splitext(os.path.basename(path))[0] if path.lower().endswith(".stp") or path.lower().endswith( ".step") or path.lower().endswith( ".brp") or path.lower().endswith(".brep"): self.place(path) elif path.lower().endswith(".fcstd"): FreeCADGui.ActiveDocument.mergeProject(path) from DraftGui import todo todo.delay(self.reject, None) elif path.lower().endswith(".ifc"): import importIFC importIFC.ZOOMOUT = False importIFC.insert(path, FreeCAD.ActiveDocument.Name) from DraftGui import todo todo.delay(self.reject, None) elif path.lower().endswith(".sat") or path.lower().endswith(".sab"): try: # InventorLoader addon import importerIL except ImportError: try: # CADExchanger addon import CadExchangerIO except ImportError: FreeCAD.Console.PrintError( translate( "BIM", "Error: Unable to import SAT files - CadExchanger addon must be installed" )) else: path = CadExchangerIO.insert(path, FreeCAD.ActiveDocument.Name, returnpath=True) self.place(path) else: path = importerIL.insert(path, FreeCAD.ActiveDocument.Name) FreeCADGui.Selection.clearSelection() for o in FreeCAD.ActiveDocument.Objects: if not o in before: FreeCADGui.Selection.addSelection(o) FreeCADGui.SendMsgToActiveView("ViewSelection")
def insert(self): "inserts selected objects in the active document" doc = FreeCAD.ActiveDocument if doc and self.filename: item = self.tree.currentItem() if item: eid = item.data(0, QtCore.Qt.UserRole) if eid: import importIFC importIFC.insert(self.filename, doc.Name, only=[eid])
def makeReferenceFile(filename, settings): docname = os.path.splitext(os.path.basename(filename))[0] name = importIFCHelper.decode(docname, utf=True) + "_ref" doc = FreeCAD.newDocument(name) importIFC.insert(filename, doc.Name, preferences=settings) sname, sext = os.path.splitext(doc.FileName) if sname: doc.FileName = sname + "_ref" + sext else: doc.FileName = os.path.splitext(filename)[0] + "_ref.FCStd" addProperties(doc, os.path.basename(filename), settings) doc.recompute() doc.save()
def insert(self): "inserts selected objects in the active document" import importIFC from PySide import QtCore, QtGui doc = FreeCAD.ActiveDocument if doc and self.filename: item = self.tree.currentItem() if item: eid = item.data(0, QtCore.Qt.UserRole) if eid: importIFC.ZOOMOUT = False try: importIFC.insert(self.ifc, doc.Name, only=[eid]) except TypeError: importIFC.insert(self.filename, doc.Name, only=[eid]) if self.currentmesh: self.currentmesh.ViewObject.hide()
def Activated(self): refdoc = FreeCAD.ActiveDocument filename = os.path.join(os.path.dirname(refdoc.FileName), refdoc.IFCTestData.IFCFile) newdoc = importIFC.insert(filename, refdoc.IFCTestData.IFCFile, preferences=refdoc.IFCTestData.Proxy) checks = [ CheckBoundingBox(), CheckGeometryType(), CheckGeometryValues() ] compareByGuid(refdoc, newdoc, checks) print_report(checks)