BIM: Fixed IsActive of BIM commands (#14384)

This commit is contained in:
Yorik van Havre
2024-05-30 22:33:43 +02:00
committed by GitHub
parent ed36928ff9
commit 7a8a25a5b3
16 changed files with 62 additions and 3 deletions

View File

@@ -197,7 +197,8 @@ class CommandStructuresFromSelection:
'ToolTip': QT_TRANSLATE_NOOP("Arch_StructuresFromSelection", "Create multiple Arch Structures from a selected base, using each selected edge as an extrusion path")}
def IsActive(self):
return not FreeCAD.ActiveDocument is None
v = hasattr(FreeCADGui.getMainWindow().getActiveWindow(), "getSceneGraph")
return v
def Activated(self):
selex = FreeCADGui.Selection.getSelectionEx()

View File

@@ -246,7 +246,8 @@ class BIMWorkbench(Workbench):
t = QT_TRANSLATE_NOOP("BIM_GenericTools", "Generic 3D tools")
return { "MenuText": t, "ToolTip": t, "Icon": "BIM_Box"}
def IsActive(self):
return not FreeCAD.ActiveDocument is None
v = hasattr(FreeCADGui.getMainWindow().getActiveWindow(), "getSceneGraph")
return v
FreeCADGui.addCommand("BIM_GenericTools", BIM_GenericTools(self.generictools))
self.bimtools.append("BIM_GenericTools")
@@ -274,7 +275,8 @@ class BIMWorkbench(Workbench):
}
def IsActive(self):
return not FreeCAD.ActiveDocument is None
v = hasattr(FreeCADGui.getMainWindow().getActiveWindow(), "getSceneGraph")
return v
FreeCADGui.addCommand("Arch_RebarTools", RebarGroupCommand())
self.bimtools[self.bimtools.index("Arch_Rebar")] = "Arch_RebarTools"

View File

@@ -37,6 +37,10 @@ class BIM_Beam(ArchStructure._CommandStructure):
super().__init__()
self.beammode = True
def IsActive(self):
v = hasattr(FreeCADGui.getMainWindow().getActiveWindow(), "getSceneGraph")
return v
def GetResources(self):
return {
"Pixmap": "BIM_Beam",

View File

@@ -37,6 +37,10 @@ class BIM_Column(ArchStructure._CommandStructure):
super().__init__()
self.beammode = False
def IsActive(self):
v = hasattr(FreeCADGui.getMainWindow().getActiveWindow(), "getSceneGraph")
return v
def GetResources(self):
return {
"Pixmap": "BIM_Column",

View File

@@ -42,6 +42,10 @@ class BIM_Common:
),
}
def IsActive(self):
v = hasattr(FreeCADGui.getMainWindow().getActiveWindow(), "getSceneGraph")
return v
def Activated(self):
import PartGui
FreeCADGui.runCommand("Part_Common")

View File

@@ -42,6 +42,10 @@ class BIM_Compound:
),
}
def IsActive(self):
v = hasattr(FreeCADGui.getMainWindow().getActiveWindow(), "getSceneGraph")
return v
def Activated(self):
import PartGui
FreeCADGui.runCommand("Part_Compound")

View File

@@ -41,6 +41,10 @@ class BIM_Cut:
),
}
def IsActive(self):
v = hasattr(FreeCADGui.getMainWindow().getActiveWindow(), "getSceneGraph")
return v
def Activated(self):
import PartGui
FreeCADGui.runCommand("Part_Cut")

View File

@@ -40,6 +40,10 @@ class BIM_Extrude:
"ToolTip": QT_TRANSLATE_NOOP("BIM_Extrude", "Extrudes a selected 2D shape"),
}
def IsActive(self):
v = hasattr(FreeCADGui.getMainWindow().getActiveWindow(), "getSceneGraph")
return v
def Activated(self):
import PartGui
FreeCADGui.runCommand("Part_Extrude")

View File

@@ -39,6 +39,10 @@ class BIM_Fuse:
"ToolTip": QT_TRANSLATE_NOOP("Part_Fuse", "Make a union of several shapes"),
}
def IsActive(self):
v = hasattr(FreeCADGui.getMainWindow().getActiveWindow(), "getSceneGraph")
return v
def Activated(self):
import PartGui
FreeCADGui.runCommand("Part_Fuse")

View File

@@ -58,6 +58,10 @@ class BIM_Layers:
),
}
def IsActive(self):
v = hasattr(FreeCADGui.getMainWindow().getActiveWindow(), "getSceneGraph")
return v
def Activated(self):
from PySide import QtCore, QtGui

View File

@@ -60,6 +60,10 @@ class BIM_Material:
),
}
def IsActive(self):
v = hasattr(FreeCADGui.getMainWindow().getActiveWindow(), "getSceneGraph")
return v
def Activated(self):
self.dlg = None

View File

@@ -41,6 +41,10 @@ class BIM_Offset2D:
),
}
def IsActive(self):
v = hasattr(FreeCADGui.getMainWindow().getActiveWindow(), "getSceneGraph")
return v
def Activated(self):
import PartGui
FreeCADGui.runCommand("Part_Offset2D")

View File

@@ -68,6 +68,10 @@ class BIM_Preflight:
),
}
def IsActive(self):
v = hasattr(FreeCADGui.getMainWindow().getActiveWindow(), "getSceneGraph")
return v
def Activated(self):
FreeCADGui.BIMPreflightDone = False
FreeCADGui.Control.showDialog(BIM_Preflight_TaskPanel())

View File

@@ -44,6 +44,10 @@ class BIM_Rewire:
"Accel": "R,W",
}
def IsActive(self):
v = hasattr(FreeCADGui.getMainWindow().getActiveWindow(), "getSceneGraph")
return v
def Activated(self):
import Part
import Draft

View File

@@ -42,6 +42,10 @@ class BIM_SimpleCopy:
),
}
def IsActive(self):
v = hasattr(FreeCADGui.getMainWindow().getActiveWindow(), "getSceneGraph")
return v
def Activated(self):
import PartGui
FreeCADGui.runCommand("Part_SimpleCopy")

View File

@@ -41,6 +41,10 @@ class BIM_Windows:
),
}
def IsActive(self):
v = hasattr(FreeCADGui.getMainWindow().getActiveWindow(), "getSceneGraph")
return v
def Activated(self):
FreeCADGui.Control.showDialog(BIM_Windows_TaskPanel())