FEM: command modules, get rid of duplicate selection code
This commit is contained in:
@@ -46,11 +46,8 @@ class _CommandFemMeshBoundaryLayer(FemCommands):
|
||||
def Activated(self):
|
||||
FreeCAD.ActiveDocument.openTransaction("Create FemMeshBoundaryLayer")
|
||||
FreeCADGui.addModule("ObjectsFem")
|
||||
sel = FreeCADGui.Selection.getSelection()
|
||||
if (len(sel) == 1):
|
||||
sobj = sel[0]
|
||||
if len(sel) == 1 and hasattr(sobj, "Proxy") and sobj.Proxy.Type == "FemMeshGmsh":
|
||||
FreeCADGui.doCommand("ObjectsFem.makeMeshBoundaryLayer(FreeCAD.ActiveDocument, FreeCAD.ActiveDocument." + sobj.Name + ")")
|
||||
self.mesh = FreeCADGui.Selection.getSelection()[0] # see 'with_gmsh_femmesh' in FemCommands for selection check
|
||||
FreeCADGui.doCommand("ObjectsFem.makeMeshBoundaryLayer(FreeCAD.ActiveDocument, FreeCAD.ActiveDocument." + self.mesh.Name + ")")
|
||||
|
||||
FreeCADGui.Selection.clearSelection()
|
||||
|
||||
|
||||
@@ -46,11 +46,8 @@ class _CommandFemMeshGroup(FemCommands):
|
||||
def Activated(self):
|
||||
FreeCAD.ActiveDocument.openTransaction("Create FemMeshGroup")
|
||||
FreeCADGui.addModule("ObjectsFem")
|
||||
sel = FreeCADGui.Selection.getSelection()
|
||||
if (len(sel) == 1):
|
||||
sobj = sel[0]
|
||||
if len(sel) == 1 and hasattr(sobj, "Proxy") and sobj.Proxy.Type == "FemMeshGmsh":
|
||||
FreeCADGui.doCommand("ObjectsFem.makeMeshGroup(FreeCAD.ActiveDocument, FreeCAD.ActiveDocument." + sobj.Name + ")")
|
||||
self.mesh = FreeCADGui.Selection.getSelection()[0] # see 'with_gmsh_femmesh' in FemCommands for selection check
|
||||
FreeCADGui.doCommand("ObjectsFem.makeMeshGroup(FreeCAD.ActiveDocument, FreeCAD.ActiveDocument." + self.mesh.Name + ")")
|
||||
|
||||
FreeCADGui.Selection.clearSelection()
|
||||
|
||||
|
||||
@@ -46,11 +46,8 @@ class _CommandFemMeshRegion(FemCommands):
|
||||
def Activated(self):
|
||||
FreeCAD.ActiveDocument.openTransaction("Create FemMeshRegion")
|
||||
FreeCADGui.addModule("ObjectsFem")
|
||||
sel = FreeCADGui.Selection.getSelection()
|
||||
if (len(sel) == 1):
|
||||
sobj = sel[0]
|
||||
if len(sel) == 1 and hasattr(sobj, "Proxy") and sobj.Proxy.Type == "FemMeshGmsh":
|
||||
FreeCADGui.doCommand("ObjectsFem.makeMeshRegion(FreeCAD.ActiveDocument, FreeCAD.ActiveDocument." + sobj.Name + ")")
|
||||
self.mesh = FreeCADGui.Selection.getSelection()[0] # see 'with_gmsh_femmesh' in FemCommands for selection check
|
||||
FreeCADGui.doCommand("ObjectsFem.makeMeshRegion(FreeCAD.ActiveDocument, FreeCAD.ActiveDocument." + self.mesh.Name + ")")
|
||||
|
||||
FreeCADGui.Selection.clearSelection()
|
||||
|
||||
|
||||
@@ -49,9 +49,7 @@ class _CommandFemSolverRun(FemCommands):
|
||||
else:
|
||||
print ("CalculiX failed ccx finished with error {}".format(ret_code))
|
||||
|
||||
sel = FreeCADGui.Selection.getSelection()
|
||||
if len(sel) == 1 and sel[0].isDerivedFrom("Fem::FemSolverObjectPython"):
|
||||
self.solver = sel[0]
|
||||
self.solver = FreeCADGui.Selection.getSelection()[0] # see 'with_solver' in FemCommands for selection check
|
||||
if self.solver.SolverType == "FemSolverCalculix":
|
||||
import FemToolsCcx
|
||||
self.fea = FemToolsCcx.FemToolsCcx(None, self.solver)
|
||||
|
||||
Reference in New Issue
Block a user