Exemplo n.º 1
0
def _update_parts(parts, name):
    App = FreeCAD
    for part in parts:
        was_open = False
        if part.sourceFile in [
                d.FileName for d in FreeCAD.listDocuments().values()
        ]:
            doc = [
                d for d in FreeCAD.listDocuments().values()
                if d.FileName == part.sourceFile
            ][0]
            App.setActiveDocument(doc.Label)
            was_open = True
        else:
            doc = App.openDocument(os.path.join([doc_dir, part.sourceFile]))
            App.setActiveDocument(doc.Label)
        App.ActiveDocument = App.getDocument(doc.Label)
        _update_parts(filter(_is_a_part, App.ActiveDocument.Objects),
                      doc.Label)
        App.ActiveDocument.save()
        if not was_open:
            App.closeDocument(doc.Label)
    App.setActiveDocument(name)
    App.ActiveDocument = App.getDocument(name)
    for obj in App.ActiveDocument.Objects:
        obj.touch()
    App.ActiveDocument.recompute()
Exemplo n.º 2
0
    def checkForSubAssembly(self, subFileName):
        filename = findSourceFileInProject(
            subFileName)  # path within subfile will be ignored..
        if filename == None:
            FreeCAD.Console.PrintMessage(
                "SubassemblyCheck failed for {} ".format(subFileName))
            return False

        doc_already_open = filename in [
            d.FileName for d in FreeCAD.listDocuments().values()
        ]
        if doc_already_open:
            doc = [
                d for d in FreeCAD.listDocuments().values()
                if d.FileName == filename
            ][0]
        else:
            doc = FreeCAD.openDocument(filename)

        for obj in doc.Objects:
            if hasattr(obj, 'sourceFile'):
                if not doc_already_open:
                    FreeCAD.closeDocument(doc.Name)
                return True

        if not doc_already_open:
            FreeCAD.closeDocument(doc.Name)
        return False
Exemplo n.º 3
0
    def Activated(self):
        selection = [s for s in FreeCADGui.Selection.getSelection() if s.Document == FreeCAD.ActiveDocument ]
        obj = selection[0]
        FreeCADGui.Selection.clearSelection() # very imporant! Avoid Editing the assembly the part was called from!
        fileNameWithinProjectFile = a2plib.findSourceFileInProject(obj.sourceFile)
        if fileNameWithinProjectFile == None:
            msg = \
'''
You want to edit a file which
is not found below your project-folder.
This is not allowed when using preference
"Use project Folder"
'''
            QtGui.QMessageBox.critical(
                QtGui.QApplication.activeWindow(),
                "File error ! ",
                msg
                )
            return
        docs = FreeCAD.listDocuments().values()
        docFilenames = [ d.FileName for d in docs ]
        if not fileNameWithinProjectFile in docFilenames :
            FreeCAD.open(fileNameWithinProjectFile)
        else:
            name = docs[docFilenames.index(fileNameWithinProjectFile)].Name
            FreeCAD.setActiveDocument( name )
            FreeCAD.ActiveDocument=FreeCAD.getDocument( name )
            FreeCADGui.ActiveDocument=FreeCADGui.getDocument( name )
Exemplo n.º 4
0
 def Activated(cls, checked):
     super(AsmCmdShowElementCS, cls).Activated(checked)
     from .assembly import isTypeOf, AsmElement
     for doc in FreeCAD.listDocuments().values():
         for obj in doc.Objects:
             if isTypeOf(obj, AsmElement):
                 obj.ViewObject.Proxy.setupAxis()
Exemplo n.º 5
0
 def openFile(self):
     filename = None
     importDoc = None
     importDocIsOpen = False
     dialog = QtGui.QFileDialog( QtGui.QApplication.activeWindow(),
                                 "Select FreeCAD document to import part from" )
     # set option "DontUseNativeDialog"=True, as native Filedialog shows
     # misbehavior on Unbuntu 18.04 LTS. It works case sensitively, what is not wanted...
     '''
     if a2plib.getNativeFileManagerUsage():
         dialog.setOption(QtGui.QFileDialog.DontUseNativeDialog, False)
     else:
         dialog.setOption(QtGui.QFileDialog.DontUseNativeDialog, True)
     '''
     dialog.setNameFilter("Supported Formats *.FCStd *.fcstd (*.FCStd *.fcstd);;All files (*.*)")
     if dialog.exec_():
         filename = str(dialog.selectedFiles()[0])
         # look only for filenames, not paths, as there are problems on WIN10 (Address-translation??)
         requestedFile = os.path.split(filename)[1]
         # see whether the file is already open
         for d in App.listDocuments().values():
             recentFile = os.path.split(d.FileName)[1]
             if requestedFile == recentFile:
                 importDoc = d # file is already open...
                 importDocIsOpen = True
                 break
         # if not, open it
         if not importDocIsOpen:
             if filename.lower().endswith('.fcstd'):
                 importDoc = App.openDocument(filename)
                 App.setActiveDocument( self.activeDoc.Name )
                 # update the part list
                 self.lookForParts(importDoc)
     return
Exemplo n.º 6
0
 def lookForParts( self, doc=None ):
     self.allParts = []
     self.partsDoc = []
     self.partList.clear()
     if doc is None:
         docList = App.listDocuments().values()
     else:
         docList = [doc]
     for doc in docList:
         # don't consider temporary documents
         if not doc.Temporary:
             for obj in doc.findObjects("App::Part"):
                 # we don't want to link to itself to the 'Model' object
                 # other App::Part in the same document are OK 
                 # but only those at top level (not nested inside other containers)
                 if obj != self.rootAssembly and obj.getParentGeoFeatureGroup() is None:
                     self.allParts.append( obj )
                     self.partsDoc.append( doc )
             for obj in doc.findObjects("PartDesign::Body"):
                 # but only those at top level (not nested inside other containers)
                 if obj.getParentGeoFeatureGroup() is None:
                     self.allParts.append( obj )
                     self.partsDoc.append( doc )
     # build the list
     for part in self.allParts:
         newItem = QtGui.QListWidgetItem()
         newItem.setText( part.Document.Name +"#"+ Asm4.labelName(part) )
         newItem.setIcon(part.ViewObject.Icon)
         self.partList.addItem(newItem)
Exemplo n.º 7
0
def GetDocumentsList(docObj=None):
    """This function gets a list of currently open FreeCAD documents.

    This function is to be called from another function or module for
    obtaining an updated list of currently open FreeCAD documents.
    This function is not meant to be called directly from the
    FreeCAD application.

    Parameters
    ----------
    docObj: (FreeCAD.Document)
            [Optional]
            The document to be placed at the start of the list.
            Default: None

    Return
    ----------
    (list): List of FreeCAD documents.
    """
    listArg = []
    if docObj:
        listArg.append(docObj.Name)
    for itemsSet in app.listDocuments().items():
        for itemElem in itemsSet:
            if (docObj and itemElem != listArg[0]) or not docObj:
                listArg.append(itemElem)
            break
    return listArg
Exemplo n.º 8
0
 def create_combo_box(self):
     combo_box = QtGui.QComboBox(self.form)
     documents = list(App.listDocuments().keys())
     combo_box.addItems(documents)
     combo_box.activated[str].connect(self.handle_combo_box_activated)
     index = documents.index(self.document)
     combo_box.setCurrentIndex(index)
     return combo_box
Exemplo n.º 9
0
 def getAllParts(self):
     # get all App::Part from all open documents
     self.allParts = []
     for doc in FreeCAD.listDocuments().values():
         if doc != self.activeDoc:
             parts = doc.findObjects("App::Part")
             # there might be more than 1 App::Part per document
             for obj in parts:
                 self.allParts.append(obj)
Exemplo n.º 10
0
    def updateDocList(self):
        docDocs = ['- Select Document -']
        # Collect all documents currently available
        for doc in App.listDocuments():
            docDocs.append(doc)

        # only update the gui-element if documents actually changed
        if self.knownDocumentList != docDocs:
            self.docList.clear()
            self.docList.addItems(docDocs)
            self.knownDocumentList = docDocs

        # set current active documents per default
        #if self.AnimatedDocument is None:
        activeDoc = App.ActiveDocument
        if activeDoc in App.listDocuments().values():
            docIndex = list(App.listDocuments().values()).index(activeDoc)
            self.docList.setCurrentIndex(docIndex + 1)
Exemplo n.º 11
0
def importPart(filename):
    doc_assembly = App.ActiveDocument
    App.Console.PrintMessage("importing part from %s\n" % filename)
    
    doc_already_open = filename in [ d.FileName for d in App.listDocuments().values() ]
    App.Console.PrintMessage("%s open already %s" % (filename, doc_already_open))
    
    if doc_already_open:
        doc = [ d for d in App.listDocuments().values() if d.FileName == filename][0]
    else:
        if filename.lower().endswith('.fcstd'):
            App.Console.PrintMessage('opening %s' % filename)
            doc = App.openDocument(filename)
            App.Console.PrintMessage('succesfully opened %s' % filename)
        else: #trying shaping import http://forum.freecadweb.org/viewtopic.php?f=22&t=12434&p=99772#p99772x
            import ImportGui
            doc = App.newDocument( os.path.basename(filename) )
            shapeobj=ImportGui.insert(filename,doc.Name)
    
    visibleObjects = [ obj for obj in doc.Objects
                       if hasattr(obj,'ViewObject') and obj.ViewObject.isVisible()
                       and hasattr(obj,'Shape') and len(obj.Shape.Faces) > 0 and 'Body' not in obj.Name] # len(obj.Shape.Faces) > 0 to avoid sketches, skip Body
    App.Console.PrintMessage('Visible objects %s' % visibleObjects)
    
    obj = doc_assembly.addObject("Part::FeaturePython", 'part123456')
    obj.addProperty("App::PropertyFile", "sourceFile", "D3D_ImportPart").sourceFile = filename
    obj.addProperty("App::PropertyFloat", "timeLastImport", "D3D_ImportPart")
    obj.setEditorMode("timeLastImport", 1)
    obj.addProperty("App::PropertyBool", "fixedPosition", "D3D_ImportPart")
    obj.fixedPosition = not any([i.fixedPosition for i in doc_assembly.Objects if hasattr(i, 'fixedPosition') ])
    #obj.addProperty("App::PropertyBool", "updateColors", "importPart").updateColors = True
    obj_to_copy  = visibleObjects[0]
    obj.Shape = obj_to_copy.Shape.copy()
    
    obj.Proxy = Proxy_importPart()
    obj.timeLastImport = os.path.getmtime( filename )
    #clean up
    #if subAssemblyImport:
    #    doc_assembly.removeObject(tempPartName)
    if not doc_already_open: #then close again
        App.closeDocument(doc.Name)
        App.setActiveDocument(doc_assembly.Name)
        App.ActiveDocument = doc_assembly
    return obj
Exemplo n.º 12
0
    def Activated(self):
        doc = FreeCAD.activeDocument()
        if doc == None:
            QtGui.QMessageBox.information(
                QtGui.QApplication.activeWindow(), "No active document found!",
                "Before editing a part, you have to open an assembly file.")
            return
        selection = [
            s for s in FreeCADGui.Selection.getSelection()
            if s.Document == FreeCAD.ActiveDocument
        ]
        if not selection:
            msg = \
'''
You must select a part to edit first.
'''
            QtGui.QMessageBox.information(QtGui.QApplication.activeWindow(),
                                          "Selection Error", msg)
            return
        obj = selection[0]
        FreeCADGui.Selection.clearSelection(
        )  # very important! Avoid Editing the assembly the part was called from!
        assemblyPath = os.path.normpath(os.path.split(doc.FileName)[0])
        fileNameWithinProjectFile = a2plib.findSourceFileInProject(
            obj.sourceFile, assemblyPath)
        if fileNameWithinProjectFile == None:
            msg = \
'''
You want to edit a file which
is not found below your project-folder.
This is not allowed when using preference
"Use project Folder"
'''
            QtGui.QMessageBox.critical(QtGui.QApplication.activeWindow(),
                                       "File error ! ", msg)
            return
        #TODO: WF fails if "use folder" = false here
        docs = []
        for d in FreeCAD.listDocuments().values(
        ):  #dict_values not indexable, docs now is...
            docs.append(d)
        #docs = FreeCAD.listDocuments().values()
        docFilenames = [d.FileName for d in docs]

        if not fileNameWithinProjectFile in docFilenames:
            FreeCAD.open(fileNameWithinProjectFile)
        else:
            idx = docFilenames.index(fileNameWithinProjectFile)
            name = docs[idx].Name
            # Search and activate the corresponding document window..
            mw = FreeCADGui.getMainWindow()
            mdi = mw.findChild(QtGui.QMdiArea)
            sub = mdi.subWindowList()
            for s in sub:
                mdi.setActiveSubWindow(s)
                if FreeCAD.activeDocument().Name == name: break
Exemplo n.º 13
0
def checkFile(fileName):
    if fileName.startswith('./'):
        fileName = os.path.join(os.path.dirname(FreeCAD.ActiveDocument.FileName), fileName)
    
    try:
        return [FreeCAD.open(fileName), True]
    except Exception, e: # file is already open
        for i in FreeCAD.listDocuments().values():
            if i.FileName == fileName:
                return [FreeCAD.getDocument(i.Label), False]
Exemplo n.º 14
0
 def getAllParts(self):
     # get all App::Part from all open documents
     self.allParts = []
     for doc in App.listDocuments().values():
         # except this document: we don't want to link to itself
         if doc != self.activeDoc:
             parts = doc.findObjects("App::Part")
             # there might be more than 1 App::Part per document
             for obj in parts:
                 self.allParts.append(obj)
Exemplo n.º 15
0
    def __getDocumentByFileName(self, fileName):
        docList = FreeCAD.listDocuments()
        for docName in docList:
            doc = FreeCAD.getDocument(docName)
            if doc.FileName == fileName:
                return doc

        doc = FreeCAD.openDocument(fileName)
        self.__tmpDocs.append(doc.Name)
        return doc
Exemplo n.º 16
0
def checkFile(fileName):
    if fileName.startswith('./'):
        fileName = os.path.join(os.path.dirname(FreeCAD.ActiveDocument.FileName), fileName)
    
    try:
        return [FreeCAD.open(fileName), True]
    except Exception, e: # file is already open
        for i in FreeCAD.listDocuments().values():
            if i.FileName == fileName:
                return [FreeCAD.getDocument(i.Label), False]
Exemplo n.º 17
0
def save_and_reopen_spreadsheet_document(spreadsheet_document_name: str,
                                         destination: Path) -> Document:
    spreadsheet_document = App.listDocuments()[spreadsheet_document_name]
    spreadsheet_document_filename = f'{spreadsheet_document_name}.FCStd'
    spreadsheet_document_path = destination.joinpath(
        spreadsheet_document_filename)
    spreadsheet_document.saveAs(str(spreadsheet_document_path))
    App.closeDocument(spreadsheet_document_name)
    spreadsheet_document = App.openDocument(str(spreadsheet_document_path))
    return spreadsheet_document
Exemplo n.º 18
0
    def Activated(self):
        checks = [
            CheckBoundingBox(),
            CheckGeometryType(),
            CheckGeometryValues()
        ]
        docs = [d for d in FreeCAD.listDocuments().values()]
        if hasattr(docs[1], "IFCTestData"):
            docs.reverse()

        compareByGuid(docs[0], docs[1], checks)
        print_report(checks)
Exemplo n.º 19
0
 def fill_comboBox_2(self):
     self.comboBox_2.clear()
     self.listWidget.clear()
     self.grader_messages = None
     self.grader_notes = None
     document_list = app.listDocuments()
     if len(document_list) > 0:
         n = 0
         for doc in document_list.items():
             self.comboBox_2.addItem(doc[1].Label)
             n += 1
     else:
         self.comboBox_2.addItem("Il n'y a pas de document à évaluer.")
Exemplo n.º 20
0
def createSrcDoc(fileName):
    import a
    import FreeCAD
    myname = "alib.createSrcDoc()"
    a.log(myname, "started")
    docList = FreeCAD.listDocuments()
    for doc in docList:
        if docList[doc].FileName == fileName:
            a.log(a.myname(), "doc allready open")
            return docList[doc]
    msg = "doc is not open. Opening the doc"
    a.log(a.myname(), msg)
    return FreeCAD.openDocument(fileName)
Exemplo n.º 21
0
def prompt_close_all_documents(prompt: bool = True) -> bool:
    """ Shows a dialog to close all the current documents.
        If accepted, close all the current documents and return True, else returns False. """
    if prompt:
        user_selection = ok_cancel_dialog(APP_NAME,
                                          "All documents will be closed")
    if not prompt or user_selection == QtGui.QMessageBox.Ok:
        # Close all current documents.
        log(__("Closing all current documents"))
        for doc in FreeCAD.listDocuments().keys():
            FreeCAD.closeDocument(doc)
        return True
    return False
Exemplo n.º 22
0
    def Activated(self):
        a2plib.setAutoSolve(True)  # makes no sense without autosolve = ON
        doc = FreeCAD.activeDocument()
        fileName = doc.FileName
        workingDir, basicFileName = os.path.split(fileName)

        filesToUpdate = []
        subAsmNeedsUpdate, filesToUpdate = createUpdateFileList(
            fileName, workingDir, filesToUpdate, True)

        for f in filesToUpdate:
            #-------------------------------------------
            # update necessary documents
            #-------------------------------------------

            # look only for filenames, not paths, as there are problems on WIN10 (Address-translation??)
            importDoc = None
            importDocIsOpen = False
            requestedFile = os.path.split(f)[1]
            for d in FreeCAD.listDocuments().values():
                recentFile = os.path.split(d.FileName)[1]
                if requestedFile == recentFile:
                    importDoc = d  # file is already open...
                    importDocIsOpen = True
                    break

            if not importDocIsOpen:
                if f.lower().endswith('.fcstd'):
                    importDoc = FreeCAD.openDocument(f)
                elif f.lower().endswith('.stp') or f.lower().endswith('.step'):
                    import ImportGui
                    fname = os.path.splitext(os.path.basename(f))[0]
                    FreeCAD.newDocument(fname)
                    newname = FreeCAD.ActiveDocument.Name
                    FreeCAD.setActiveDocument(newname)
                    ImportGui.insert(filename, newname)
                    importDoc = FreeCAD.ActiveDocument
                else:
                    msg = "A part can only be imported from a FreeCAD '*.fcstd' file"
                    QtGui.QMessageBox.information(
                        QtGui.QApplication.activeWindow(), "Value Error", msg)
                    return

            updateImportedParts(importDoc)
            FreeCADGui.updateGui()
            importDoc.save()
            print(u"==== Assembly '{}' has been updated! =====".format(
                importDoc.FileName))
            if importDoc != doc:
                FreeCAD.closeDocument(importDoc.Name)
Exemplo n.º 23
0
 def setup(cls):
     checked = AsmCmdManager.AutoElementVis
     from .assembly import isTypeOf,AsmConstraint,\
         AsmElement,AsmElementLink,AsmElementGroup
     for doc in FreeCAD.listDocuments().values():
         for obj in doc.Objects:
             if isTypeOf(obj, (AsmConstraint, AsmElementGroup)):
                 if isTypeOf(obj, AsmConstraint):
                     obj.ViewObject.OnTopWhenSelected = 2
             elif isTypeOf(obj, (AsmElementLink, AsmElement)):
                 if checked:
                     obj.Proxy.parent.Object.setElementVisible(
                         obj.Name, False)
                 obj.ViewObject.OnTopWhenSelected = 2
Exemplo n.º 24
0
    def updateJob(self):
        '''Download the g-code currently loaded into MK, check if it could be a FC Path.Job.
        If the Path.Job is currently loaded trigger an update to everyone caring about these
        things.'''
        job = None
        path = self['status.task.file']
        rpath = self.remoteFilePath()
        endpoint = self.instance.endpoint.get('file')
        PathLog.info("%s, %s, %s" % (path, rpath, endpoint))
        if path is None or rpath is None or endpoint is None:
            self.needUpdateJob = True
        else:
            self.needUpdateJob = False
            if rpath == path:
                buf = io.BytesIO()
                ftp = ftplib.FTP()
                ftp.connect(endpoint.address(), endpoint.port())
                ftp.login()
                ftp.retrbinary("RETR %s" % self.RemoteFilename, buf.write)
                ftp.quit()
                buf.seek(0)
                line1 = buf.readline().decode()
                line2 = buf.readline().decode()
                line3 = buf.readline().decode()
                if line1.startswith('(FreeCAD.Job: ') and line2.startswith(
                        '(FreeCAD.File: ') and line3.startswith(
                            '(FreeCAD.Signature: '):
                    title = line1[14:-2]
                    filename = line2[15:-2]
                    signature = line3[20:-2]
                    PathLog.debug("Loaded document: '%s' - '%s'" %
                                  (filename, title))
                    for docName, doc in FreeCAD.listDocuments().items():
                        PathLog.debug("Document: '%s' - '%s'" %
                                      (docName, doc.FileName))
                        if doc.FileName == filename:
                            job = doc.getObject(title)
                            if job:
                                sign = MKUtils.pathSignature(job.Path)
                                if str(sign) == signature:
                                    PathLog.info(
                                        "Job %s.%s loaded." %
                                        (job.Document.Label, job.Label))
                                else:
                                    PathLog.warning(
                                        "Job %s.%s is out of date!" %
                                        (job.Document.Label, job.Label))

        self.setJob(job)
Exemplo n.º 25
0
 def _loadBitBody(self, obj, path=None):
     p = path if path else obj.BitShape
     docOpened = False
     doc = None
     for d in FreeCAD.listDocuments():
         if FreeCAD.getDocument(d).FileName == p:
             doc = FreeCAD.getDocument(d)
             break
     if doc is None:
         p = findShape(p)
         if not path and p != obj.BitShape:
             obj.BitShape = p
         doc = FreeCAD.open(p)
         docOpened = True
     return (doc, docOpened)
Exemplo n.º 26
0
 def onSelectDoc(self):
     self.update(self.AnimationRequest.STOP)
     # the currently selected document
     selectedDoc = self.docList.currentText()
     # if it's indeed a document (one never knows)
     documents = App.listDocuments()
     if len(selectedDoc) > 0 and selectedDoc in documents:
         # update vars
         self.AnimatedDocument = documents[selectedDoc]
         self.Variables = self.AnimatedDocument.getObject('Variables')
         self.updateVarList()
     else:
         self.AnimatedDocument = None
         self.Variables = None
         self.updateVarList()
Exemplo n.º 27
0
 def getFastenersDoc(self):
     # list of all open documents in the sessions
     docList = App.listDocuments()
     for doc in docList:
         # if the Fastener's document is already open
         if doc == 'Fasteners':
             fastenersDoc = App.getDocument('Fasteners')
             return fastenersDoc
     # if the Fastner document isn't yet open:
     fastenersDocPath = os.path.join(libPath, 'Fasteners.FCStd')
     # The document is opened in the background:
     fastenersDoc = App.openDocument(fastenersDocPath, hidden='True')
     # and we reset the original document as active:
     App.setActiveDocument(self.asmDoc.Name)
     return fastenersDoc
Exemplo n.º 28
0
 def makeVarLink(self, obj):
     # create a new, empty, hidden, temporary document
     tmpDocName = 'varTmpDoc_'
     i = 1
     while i < 100 and tmpDocName + str(i) in App.listDocuments():
         i += 1
     if i < 100:
         tmpDocName = 'varTmpDoc_' + str(i)
         tmpDoc = App.newDocument(tmpDocName, hidden=True, temp=True)
         # deep-copy the source object and link it back
         obj.LinkedObject = tmpDoc.copyObject(obj.SourceObject, True)
     else:
         FCC.PrintWarning(
             '100 temporary variant documents are already in use, not creating a new one.\n'
         )
     return
Exemplo n.º 29
0
 def Activated(cls, checked):
     super(AsmCmdAutoElementVis, cls).Activated(checked)
     from .assembly import isTypeOf,AsmConstraint,\
         AsmElement,AsmElementLink,AsmElementGroup
     for doc in FreeCAD.listDocuments().values():
         for obj in doc.Objects:
             if isTypeOf(obj, (AsmConstraint, AsmElementGroup)):
                 if isTypeOf(obj, AsmConstraint):
                     obj.ViewObject.OnTopWhenSelected = 2
                 obj.setPropertyStatus(
                     'VisibilityList',
                     'NoModify' if checked else '-NoModify')
             elif isTypeOf(obj, (AsmElementLink, AsmElement)):
                 if checked:
                     obj.Proxy.parent.Object.setElementVisible(
                         obj.Name, False)
                 obj.ViewObject.OnTopWhenSelected = 2
Exemplo n.º 30
0
 def eval_button(self):
     print("Eval button clicked")
     doc_name = None
     document_list = app.listDocuments()
     for doc in document_list.items():
         if doc[1].Label == self.comboBox_2.currentText():
             doc_name = doc[1].Name
     if doc_name:
         self.grader_launch(doc_name)
     else:
         self.grader_notes = None
         self.listWidget.clear()
         msgBox = QtWidgets.QMessageBox()
         msgBox.setText("Il n'y aucun document à évaluer !")
         msgBox.setText(
             "Veuillez ouvrir un document et relancer FreeCAD Grader")
         msgBox.exec_()
Exemplo n.º 31
0
def run_FreeCAD_bakery(self):

    workspace=self.getData("Workspace")
    name=self.getData("name")
    shape=self.getPinObject('Shape_in')
    s=shape

    l=FreeCAD.listDocuments()
    if workspace=='' or workspace=='None':
        try:
            w=l['Unnamed']
        except:
            w=FreeCAD.newDocument("Unnamed")
            FreeCADGui.runCommand("Std_TileWindows")
    else:
        if workspace in l.keys():
            w=l[workspace]
        else:
            w=FreeCAD.newDocument(workspace)

            #Std_CascadeWindows
            FreeCADGui.runCommand("Std_ViewDimetric")
            FreeCADGui.runCommand("Std_ViewFitAll")
            FreeCADGui.runCommand("Std_TileWindows")

    #s=store.store().get(shape)

    f=w.getObject(name)
    #say("AB",time.time()-timeA)
    if 1 or f == None:
        f = w.addObject('Part::Feature', name)
    if s  !=  None:
    #    say("AC",time.time()-timeA)
        f.Shape=s
    #    say("AD",time.time()-timeA)
    #say("shape",s);say("name",name)
    #say("A",time.time()-timeA)
    w.recompute()
    #say("B",time.time()-timeA)
    if 1:
        color=(random.random(),random.random(),1.)
        f.ViewObject.ShapeColor = color
        f.ViewObject.LineColor = color
        f.ViewObject.PointColor = color
Exemplo n.º 32
0
sys.path.insert(0,os.environ["FEMProjScripts"]+"sourcesfc/")
import pointtopost
from pointtopost import *

del sys.modules["pointtopost"]
import pointtopost
from pointtopost import *
# reload everything
#
Pieces=[]
i=0
Pieces.append(Piece)
Pi=Pieces[i]
pointtopost.testinit151024(Pi)
if len(set(FreeCAD.listDocuments())&set([Pi.fc_docname]))==0:
    FreeCAD.newDocument(Pi.fc_docname)

pointtopost.cleandocobjs(Pi.fc_docname)


	       
Pi.occpointsL=pointtopost.dinDINENISO10211_1topoints()
print "draw faces"
Pi.compound0=makefacefrompointsL(Pi.occpointsL)
Pi.compound0.Label=Pi.compound0name+"Pi"+str(Pieces.index(Pi))

#adding point in new compound
Pi.compound1=pointtopost.addpointstoface(Pi.compound0)
Pi.compound1.Label=Pi.compound1name+"Pi"+str(Pieces.index(Pi))
Exemplo n.º 33
0
 def __init__(self):
     self._saved = {}
     for doc in App.listDocuments().itervalues():
         for obj in doc.Objects:
             if obj.isDerivedFrom("Fem::FemAnalysis"):
                 self._saved[obj] = obj.Group