コード例 #1
0
    def Activated(self):
        sel = FreeCADGui.Selection.getSelection()
        if (len(sel) == 1) and (sel[0].isDerivedFrom("Part::Feature")):
            # using existing part_feature, no need to import geometry, but get obj as link
            geo_file = sel[0]
        else:
            filters = u"BREP (*.brep *.brp);;STEP (*.step *.stp);;IGES (*.iges *.igs)"
            geo_file = QFileDialog.getOpenFileName(None,
                                                   u"Open geometry files",
                                                   u"./", filters)
        FreeCADGui.Selection.clearSelection()

        filters = u"IDES mesh (*.unv);;Med mesh(*.med);;VTK mesh (*.vtk *.vtu)"
        mesh_file = QFileDialog.getOpenFileName(None, u"Open mesh files",
                                                u"./", filters)
        # why return a tuple of filename and selectedfilter

        import CfdTools
        solver_name = 'OpenFOAM'
        CfdTools.createAnalysis(solver_name)

        FreeCADGui.addModule("CfdTools")
        FreeCADGui.doCommand(
            "CfdTools.importGeometryAndMesh(u'{}', u'{}')".format(
                geo_file[0], mesh_file[0]))
        #CfdTools.importGeometryAndMesh(geo_file[0], mesh_file[0])
        FreeCADGui.addModule("FemGui")
        if FemGui.getActiveAnalysis():
            FreeCADGui.doCommand(
                "FemGui.getActiveAnalysis().addObject(App.ActiveDocument.ActiveObject)"
            )
コード例 #2
0
    def Activated(self):
        filters = u"IDES mesh (*.unv);;Med mesh(*.med);;VTK mesh (*.vtk *.vtu)"
        mesh_file = QFileDialog.getOpenFileName(None, u"Open mesh files",
                                                u"./", filters)
        mesh_file = mesh_file[0]
        # why return a tuple of filename and selectedfilter

        import CfdTools
        if not CfdTools.getActiveAnalysis():
            CfdTools.createAnalysis()

        FreeCADGui.addModule("CfdTools")
        sel = FreeCADGui.Selection.getSelection()
        if (len(sel) == 1) and (sel[0].isDerivedFrom("Part::Feature")):
            # using existing part_feature, no need to import geometry, but get obj as link
            geo_obj = sel[0]
            CfdTools.importGeometryAndMesh(
                geo_obj, mesh_file)  #Todo: macro recording is yet support
        else:
            filters = u"BREP (*.brep *.brp);;STEP (*.step *.stp);;IGES (*.iges *.igs);; FcStd (*.fcstd)"
            geo_file = QFileDialog.getOpenFileName(None,
                                                   u"Open geometry files",
                                                   u"./", filters)
            geo_file = geo_file[0]
            FreeCADGui.doCommand(
                "CfdTools.importGeometryAndMesh(u'{}', u'{}')".format(
                    geo_file, mesh_file))
        FreeCADGui.Selection.clearSelection()

        FreeCADGui.addModule("FemGui")
        #if FemGui.getActiveAnalysis():  # besides addModule, FemGui need to be imported
        FreeCADGui.doCommand(
            "FemGui.getActiveAnalysis().addObject(App.ActiveDocument.ActiveObject)"
        )
コード例 #3
0
ファイル: _CommandCfdAnalysis.py プロジェクト: piteqiu/Cfd
 def Activated(self):
     import CfdTools
     CfdTools.createAnalysis()
     sel = FreeCADGui.Selection.getSelection()
     if (len(sel) == 1):
         if(sel[0].isDerivedFrom("Fem::FemMeshObject")):
             FreeCADGui.doCommand("FemGui.getActiveAnalysis().addObject(App.activeDocument()." + sel[0].Name + ")")
         if(sel[0].isDerivedFrom("Part::Feature")):
             CfdTools.createMesh(sel)  #code shared with mesh command
     FreeCADGui.Selection.clearSelection()
コード例 #4
0
    def Activated(self):
        # Todo: a dialog could be used to replace the content of this, adding length unit scaling
        if not CfdTools.getActiveAnalysis():
            CfdTools.createAnalysis()
        FreeCADGui.addModule("CfdTools")

        #self.select_without_widget()
        self.select_with_widget()

        FreeCADGui.addModule("FemGui")
        #if FemGui.getActiveAnalysis():  # besides addModule, FemGui need to be imported
        FreeCADGui.doCommand(
            "FemGui.getActiveAnalysis().addObject(App.ActiveDocument.ActiveObject)"
        )