BIM - Converted arch files

- all commands are moved to bimcommands
- all make*() functions are moved to Arch.py
- Objects and ViewProvider definitions are left in Arch* files for backwards compatibility
This commit is contained in:
Yorik van Havre
2024-05-02 12:31:22 +02:00
committed by Yorik van Havre
parent 21558764f7
commit d6ae8a4277
32 changed files with 1910 additions and 4170 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -34,9 +34,6 @@ if FreeCAD.GuiUp:
from draftutils.translate import translate
from pivy import coin
from PySide.QtCore import QT_TRANSLATE_NOOP
from ArchAxisSystem import _CommandAxisSystem
from ArchGrid import CommandArchGrid
else:
# \cond
def translate(ctxt,txt):
@@ -57,58 +54,6 @@ __url__ = "https://www.freecad.org"
# An axis is a collection of planar axes with a number/tag
def makeAxis(num=5,size=1000,name=None):
'''makeAxis([num],[size],[name]): makes an Axis set
based on the given number of axes and interval distances'''
if not FreeCAD.ActiveDocument:
FreeCAD.Console.PrintError("No active document. Aborting\n")
return
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","Axis")
obj.Label = name if name else translate("Arch","Axes")
_Axis(obj)
if FreeCAD.GuiUp:
_ViewProviderAxis(obj.ViewObject)
if num:
dist = []
angles = []
for i in range(num):
if i == 0:
dist.append(0)
else:
dist.append(float(size))
angles.append(float(0))
obj.Distances = dist
obj.Angles = angles
FreeCAD.ActiveDocument.recompute()
return obj
class _CommandAxis:
"the Arch Axis command definition"
def GetResources(self):
return {'Pixmap' : 'Arch_Axis',
'MenuText': QT_TRANSLATE_NOOP("Arch_Axis","Axis"),
'Accel': "A, X",
'ToolTip': QT_TRANSLATE_NOOP("Arch_Axis","Creates a set of axes")}
def Activated(self):
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Axis"))
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("Arch.makeAxis()")
FreeCAD.ActiveDocument.commitTransaction()
def IsActive(self):
return not FreeCAD.ActiveDocument is None
class _Axis:
"The Axis object"
@@ -812,21 +757,3 @@ class _AxisTaskPanel:
QtGui.QApplication.translate("Arch", "Angle", None),
QtGui.QApplication.translate("Arch", "Label", None)])
if FreeCAD.GuiUp:
FreeCADGui.addCommand('Arch_Axis',_CommandAxis())
FreeCADGui.addCommand('Arch_AxisSystem',_CommandAxisSystem())
FreeCADGui.addCommand('Arch_Grid',CommandArchGrid())
class _ArchAxisGroupCommand:
def GetCommands(self):
return tuple(['Arch_Axis','Arch_AxisSystem','Arch_Grid'])
def GetResources(self):
return { 'MenuText': QT_TRANSLATE_NOOP("Arch_AxisTools",'Axis tools'),
'ToolTip': QT_TRANSLATE_NOOP("Arch_AxisTools",'Axis tools')
}
def IsActive(self):
return not FreeCAD.ActiveDocument is None
FreeCADGui.addCommand('Arch_AxisTools', _ArchAxisGroupCommand())

View File

@@ -48,55 +48,6 @@ __url__ = "https://www.freecad.org"
# An axis system is a collection of multiple axes
def makeAxisSystem(axes,name=None):
'''makeAxisSystem(axes,[name]): makes a system from the given list of axes'''
if not isinstance(axes,list):
axes = [axes]
obj = FreeCAD.ActiveDocument.addObject("App::FeaturePython","AxisSystem")
obj.Label = name if name else translate("Arch","Axis System")
_AxisSystem(obj)
obj.Axes = axes
if FreeCAD.GuiUp:
_ViewProviderAxisSystem(obj.ViewObject)
FreeCAD.ActiveDocument.recompute()
return obj
class _CommandAxisSystem:
"the Arch Axis System command definition"
def GetResources(self):
return {'Pixmap' : 'Arch_Axis_System',
'MenuText': QT_TRANSLATE_NOOP("Arch_AxisSystem","Axis System"),
'Accel': "X, S",
'ToolTip': QT_TRANSLATE_NOOP("Arch_AxisSystem","Creates an axis system from a set of axes")}
def Activated(self):
if FreeCADGui.Selection.getSelection():
s = "["
for o in FreeCADGui.Selection.getSelection():
if Draft.getType(o) != "Axis":
FreeCAD.Console.PrintError(translate("Arch","Only axes must be selected")+"\n")
return
s += "FreeCAD.ActiveDocument."+o.Name+","
s += "]"
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Axis System"))
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("Arch.makeAxisSystem("+s+")")
FreeCAD.ActiveDocument.commitTransaction()
else:
FreeCAD.Console.PrintError(translate("Arch","Please select at least one axis")+"\n")
def IsActive(self):
return not FreeCAD.ActiveDocument is None
class _AxisSystem:
"The Axis System object"

View File

@@ -197,122 +197,6 @@ BuildingTypes = ['Undefined',
]
def makeBuildingPart(objectslist=None,baseobj=None,name=None):
'''makeBuildingPart([objectslist],[name]): creates a buildingPart including the
objects from the given list.'''
obj = FreeCAD.ActiveDocument.addObject("App::GeometryPython","BuildingPart")
#obj = FreeCAD.ActiveDocument.addObject("App::FeaturePython","BuildingPart")
obj.Label = name if name else translate("Arch","BuildingPart")
BuildingPart(obj)
obj.IfcType = "Building Element Part"
if FreeCAD.GuiUp:
ViewProviderBuildingPart(obj.ViewObject)
if objectslist:
obj.addObjects(objectslist)
return obj
def makeFloor(objectslist=None,baseobj=None,name=None):
"""overwrites ArchFloor.makeFloor"""
obj = makeBuildingPart(objectslist)
obj.Label = name if name else translate("Arch","Floor")
obj.IfcType = "Building Storey"
return obj
def makeBuilding(objectslist=None,baseobj=None,name=None):
"""overwrites ArchBuilding.makeBuilding"""
obj = makeBuildingPart(objectslist)
obj.Label = name if name else translate("Arch","Building")
obj.IfcType = "Building"
obj.addProperty("App::PropertyEnumeration","BuildingType","Building",QT_TRANSLATE_NOOP("App::Property","The type of this building"))
obj.BuildingType = BuildingTypes
if FreeCAD.GuiUp:
obj.ViewObject.ShowLevel = False
obj.ViewObject.ShowLabel = False
return obj
def convertFloors(floor=None):
"""convert the given Floor or Building (or all Arch Floors from the active document if none is given) into BuildingParts"""
todel = []
if floor:
objset = [floor]
else:
objset = FreeCAD.ActiveDocument.Objects
for obj in objset:
if Draft.getType(obj) in ["Floor","Building"]:
nobj = makeBuildingPart(obj.Group)
if Draft.getType(obj) == "Floor":
nobj.IfcType = "Building Storey"
else:
nobj.IfcType = "Building"
nobj.addProperty("App::PropertyEnumeration","BuildingType","Building",QT_TRANSLATE_NOOP("App::Property","The type of this building"))
nobj.BuildingType = BuildingTypes
label = obj.Label
for parent in obj.InList:
if hasattr(parent,"Group"):
if obj in parent.Group:
parent.addObject(nobj)
#g = parent.Group
#g.append(nobj)
#parent.Group = g
else:
print("Warning: couldn't add new object '"+label+"' to parent object '"+parent.Label+"'")
todel.append(obj.Name)
if obj.ViewObject:
obj.ViewObject.Proxy.Object = None # some bug makes this trigger even efter the object has been deleted...
obj.Label = obj.Label+" to delete" # in case FreeCAD doesn't allow 2 objs with same label
nobj.Label = label
for n in todel:
from DraftGui import todo
todo.delay(FreeCAD.ActiveDocument.removeObject,n)
class CommandBuildingPart:
"the Arch BuildingPart command definition"
def GetResources(self):
return {'Pixmap' : 'Arch_BuildingPart',
'MenuText': QT_TRANSLATE_NOOP("Arch_BuildingPart","BuildingPart"),
'Accel': "B, P",
'ToolTip': QT_TRANSLATE_NOOP("Arch_BuildingPart","Creates a BuildingPart including selected objects")}
def IsActive(self):
return not FreeCAD.ActiveDocument is None
def Activated(self):
sel = FreeCADGui.Selection.getSelection()
ss = "[ "
for o in sel:
ss += "FreeCAD.ActiveDocument." + o.Name + ", "
ss += "]"
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create BuildingPart"))
FreeCADGui.addModule("Arch")
FreeCADGui.addModule("Draft")
FreeCADGui.addModule("WorkingPlane")
FreeCADGui.doCommand("obj = Arch.makeBuildingPart("+ss+")")
FreeCADGui.doCommand("obj.Placement = WorkingPlane.get_working_plane().get_placement()")
FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
class BuildingPart(ArchIFC.IfcProduct):
@@ -1100,7 +984,3 @@ class ViewProviderBuildingPart:
f.close()
obj.SavedInventor = tf
os.remove(tf)
if FreeCAD.GuiUp:
FreeCADGui.addCommand('Arch_BuildingPart',CommandBuildingPart())

View File

@@ -1324,298 +1324,6 @@ def printWarning( message ):
if FreeCAD.GuiUp :
QtGui.QMessageBox.warning( None , "" , message )
# command definitions ###############################################
class _CommandAdd:
"the Arch Add command definition"
def GetResources(self):
return {'Pixmap' : 'Arch_Add',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Arch_Add","Add component"),
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Arch_Add","Adds the selected components to the active object")}
def IsActive(self):
return len(FreeCADGui.Selection.getSelection()) > 1
def Activated(self):
sel = FreeCADGui.Selection.getSelection()
if Draft.getType(sel[-1]) == "Space":
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Add space boundary"))
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("Arch.addSpaceBoundaries( FreeCAD.ActiveDocument."+sel[-1].Name+", FreeCADGui.Selection.getSelectionEx() )")
else:
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Grouping"))
if not mergeCells(sel):
host = sel.pop()
ss = "["
for o in sel:
if len(ss) > 1:
ss += ","
ss += "FreeCAD.ActiveDocument."+o.Name
ss += "]"
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("Arch.addComponents("+ss+",FreeCAD.ActiveDocument."+host.Name+")")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
class _CommandRemove:
"the Arch Add command definition"
def GetResources(self):
return {'Pixmap' : 'Arch_Remove',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Arch_Remove","Remove component"),
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Arch_Remove","Remove the selected components from their parents, or create a hole in a component")}
def IsActive(self):
return bool(FreeCADGui.Selection.getSelection())
def Activated(self):
sel = FreeCADGui.Selection.getSelection()
if Draft.getType(sel[-1]) == "Space":
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Remove space boundary"))
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("Arch.removeSpaceBoundaries( FreeCAD.ActiveDocument."+sel[-1].Name+", FreeCADGui.Selection.getSelection() )")
else:
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Ungrouping"))
if len(sel) > 1:
host = sel.pop()
ss = "["
for o in sel:
if len(ss) > 1:
ss += ","
ss += "FreeCAD.ActiveDocument."+o.Name
ss += "]"
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("Arch.removeComponents("+ss+",FreeCAD.ActiveDocument."+host.Name+")")
else:
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("Arch.removeComponents(FreeCAD.ActiveDocument."+sel[0].Name+")")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
class _CommandSplitMesh:
"the Arch SplitMesh command definition"
def GetResources(self):
return {'Pixmap' : 'Arch_SplitMesh',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Arch_SplitMesh","Split Mesh"),
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Arch_SplitMesh","Splits selected meshes into independent components")}
def IsActive(self):
return bool(FreeCADGui.Selection.getSelection())
def Activated(self):
if FreeCADGui.Selection.getSelection():
sel = FreeCADGui.Selection.getSelection()
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Split Mesh"))
for obj in sel:
n = obj.Name
nobjs = splitMesh(obj)
if len(nobjs) > 1:
g = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroup",n)
for o in nobjs:
g.addObject(o)
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
class _CommandMeshToShape:
"the Arch MeshToShape command definition"
def GetResources(self):
return {'Pixmap' : 'Arch_MeshToShape',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Arch_MeshToShape","Mesh to Shape"),
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Arch_MeshToShape","Turns selected meshes into Part Shape objects")}
def IsActive(self):
return bool(FreeCADGui.Selection.getSelection())
def Activated(self):
if FreeCADGui.Selection.getSelection():
f = FreeCADGui.Selection.getSelection()[0]
g = None
if f.isDerivedFrom("App::DocumentObjectGroup"):
g = f
FreeCADGui.Selection.clearSelection()
for o in f.OutList:
FreeCADGui.Selection.addSelection(o)
else:
if f.InList:
if f.InList[0].isDerivedFrom("App::DocumentObjectGroup"):
g = f.InList[0]
fast = params.get_param_arch("ConversionFast")
tol = params.get_param_arch("ConversionTolerance")
flat = params.get_param_arch("ConversionFlat")
cut = params.get_param_arch("ConversionCut")
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Mesh to Shape"))
for obj in FreeCADGui.Selection.getSelection():
newobj = meshToShape(obj,True,fast,tol,flat,cut)
if g and newobj:
g.addObject(newobj)
FreeCAD.ActiveDocument.commitTransaction()
class _CommandSelectNonSolidMeshes:
"the Arch SelectNonSolidMeshes command definition"
def GetResources(self):
return {'Pixmap': 'Arch_SelectNonManifold.svg',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Arch_SelectNonSolidMeshes","Select non-manifold meshes"),
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Arch_SelectNonSolidMeshes","Selects all non-manifold meshes from the document or from the selected groups")}
def IsActive(self):
return not FreeCAD.ActiveDocument is None
def Activated(self):
msel = []
if FreeCADGui.Selection.getSelection():
for o in FreeCADGui.Selection.getSelection():
if o.isDerivedFrom("App::DocumentObjectGroup"):
msel.extend(o.OutList)
if not msel:
msel = FreeCAD.ActiveDocument.Objects
sel = []
for o in msel:
if o.isDerivedFrom("Mesh::Feature"):
if (not o.Mesh.isSolid()) or o.Mesh.hasNonManifolds():
sel.append(o)
if sel:
FreeCADGui.Selection.clearSelection()
for o in sel:
FreeCADGui.Selection.addSelection(o)
class _CommandRemoveShape:
"the Arch RemoveShape command definition"
def GetResources(self):
return {'Pixmap' : 'Arch_RemoveShape',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Arch_RemoveShape","Remove Shape from Arch"),
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Arch_RemoveShape","Removes cubic shapes from Arch components")}
def IsActive(self):
return bool(FreeCADGui.Selection.getSelection())
def Activated(self):
sel = FreeCADGui.Selection.getSelection()
removeShape(sel)
class _CommandCloseHoles:
"the Arch CloseHoles command definition"
def GetResources(self):
return {'Pixmap' : 'Arch_CloseHoles',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Arch_CloseHoles","Close holes"),
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Arch_CloseHoles","Closes holes in open shapes, turning them solids")}
def IsActive(self):
return bool(FreeCADGui.Selection.getSelection())
def Activated(self):
for o in FreeCADGui.Selection.getSelection():
s = closeHole(o.Shape)
if s:
o.Shape = s
class _CommandCheck:
"the Arch Check command definition"
def GetResources(self):
return {'Pixmap' : 'Arch_Check',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Arch_Check","Check"),
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Arch_Check","Checks the selected objects for problems")}
def IsActive(self):
return bool(FreeCADGui.Selection.getSelection())
def Activated(self):
result = check(FreeCADGui.Selection.getSelection())
if not result:
FreeCAD.Console.PrintMessage(str(translate("Arch","All good! No problems found")))
else:
FreeCADGui.Selection.clearSelection()
for i in result:
FreeCAD.Console.PrintWarning("Object "+i[0].Name+" ("+i[0].Label+") "+i[1])
FreeCADGui.Selection.addSelection(i[0])
class _CommandSurvey:
"the Arch Survey command definition"
def GetResources(self):
return {'Pixmap' : 'Arch_Survey',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Arch_Survey","Survey"),
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Arch_Survey","Starts survey")}
def IsActive(self):
return not FreeCAD.ActiveDocument is None
def Activated(self):
FreeCADGui.addModule("Arch")
FreeCADGui.doCommandGui("Arch.survey()")
class _ToggleIfcBrepFlag:
"the Toggle IFC Brep flag command definition"
def GetResources(self):
return {'Pixmap' : 'Arch_ToggleIfcBrepFlag',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Arch_ToggleIfcBrepFlag","Toggle IFC Brep flag"),
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Arch_ToggleIfcBrepFlag","Force an object to be exported as Brep or not")}
def IsActive(self):
return bool(FreeCADGui.Selection.getSelection())
def Activated(self):
for o in FreeCADGui.Selection.getSelection():
toggleIfcBrepFlag(o)
class _CommandComponent:
"the Arch Component command definition"
def GetResources(self):
return {'Pixmap' : 'Arch_Component',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Arch_Component","Component"),
'Accel': "C, M",
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Arch_Component","Creates an undefined architectural component")}
def IsActive(self):
return not FreeCAD.ActiveDocument is None
def Activated(self):
sel = FreeCADGui.Selection.getSelection()
if sel:
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Component"))
FreeCADGui.addModule("Arch")
FreeCADGui.addModule("Draft")
FreeCADGui.Control.closeDialog()
for o in sel:
FreeCADGui.doCommand("obj = Arch.makeComponent(FreeCAD.ActiveDocument."+o.Name+")")
FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
class _CommandCloneComponent:
"the Arch Clone Component command definition"
def GetResources(self):
return {'Pixmap' : 'Arch_Component_Clone',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Arch_CloneComponent","Clone component"),
'Accel': "C, C",
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Arch_CloneComponent","Clones an object as an undefined architectural component")}
def IsActive(self):
return not FreeCAD.ActiveDocument is None
def Activated(self):
sel = FreeCADGui.Selection.getSelection()
if sel:
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Component"))
FreeCADGui.addModule("Arch")
FreeCADGui.addModule("Draft")
FreeCADGui.Control.closeDialog()
for o in sel:
FreeCADGui.doCommand("obj = Arch.cloneComponent(FreeCAD.ActiveDocument."+o.Name+")")
FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
def makeIfcSpreadsheet(archobj=None):
ifc_container = None
for obj in FreeCAD.ActiveDocument.Objects :
@@ -1641,69 +1349,3 @@ def makeIfcSpreadsheet(archobj=None):
else :
return ifc_spreadsheet
class _CommandIfcSpreadsheet:
"the Arch Schedule command definition"
def GetResources(self):
return {'Pixmap': 'Arch_Schedule',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Arch_IfcSpreadsheet","Create IFC spreadsheet..."),
'Accel': "I, P",
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Arch_IfcSpreadsheet","Creates a spreadsheet to store IFC properties of an object.")}
def IsActive(self):
return not FreeCAD.ActiveDocument is None
def Activated(self):
sel = FreeCADGui.Selection.getSelection()
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create IFC properties spreadsheet"))
FreeCADGui.addModule("Arch")
FreeCADGui.Control.closeDialog()
if sel:
for o in sel:
FreeCADGui.doCommand("Arch.makeIfcSpreadsheet(FreeCAD.ActiveDocument."+o.Name+")")
else :
FreeCADGui.doCommand("Arch.makeIfcSpreadsheet()")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
class _ToggleSubs:
"the ToggleSubs command definition"
def GetResources(self):
return {'Pixmap' : 'Arch_ToggleSubs',
'Accel' : 'Ctrl+Space',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Arch_ToggleSubs","Toggle subcomponents"),
'ToolTip' : QtCore.QT_TRANSLATE_NOOP("Arch_ToggleSubs","Shows or hides the subcomponents of this object")}
def IsActive(self):
return bool(FreeCADGui.Selection.getSelection())
def Activated(self):
mode = None
for obj in FreeCADGui.Selection.getSelection():
if hasattr(obj, "Subtractions"):
for sub in obj.Subtractions:
if not (Draft.getType(sub) in ["Window","Roof"]):
if mode is None:
# take the first sub as base
mode = sub.ViewObject.isVisible()
if mode:
sub.ViewObject.hide()
else:
sub.ViewObject.show()
if FreeCAD.GuiUp:
FreeCADGui.addCommand('Arch_Add',_CommandAdd())
FreeCADGui.addCommand('Arch_Remove',_CommandRemove())
FreeCADGui.addCommand('Arch_SplitMesh',_CommandSplitMesh())
FreeCADGui.addCommand('Arch_MeshToShape',_CommandMeshToShape())
FreeCADGui.addCommand('Arch_SelectNonSolidMeshes',_CommandSelectNonSolidMeshes())
FreeCADGui.addCommand('Arch_RemoveShape',_CommandRemoveShape())
FreeCADGui.addCommand('Arch_CloseHoles',_CommandCloseHoles())
FreeCADGui.addCommand('Arch_Check',_CommandCheck())
FreeCADGui.addCommand('Arch_Survey',_CommandSurvey())
FreeCADGui.addCommand('Arch_ToggleIfcBrepFlag',_ToggleIfcBrepFlag())
FreeCADGui.addCommand('Arch_Component',_CommandComponent())
FreeCADGui.addCommand('Arch_CloneComponent',_CommandCloneComponent())
FreeCADGui.addCommand('Arch_IfcSpreadsheet',_CommandIfcSpreadsheet())
FreeCADGui.addCommand('Arch_ToggleSubs',_ToggleSubs())

View File

@@ -70,88 +70,6 @@ the facet is triangulated and receives a third mullion
"""
def makeCurtainWall(baseobj=None,name=None):
"""
makeCurtainWall([baseobj],[name]): Creates a curtain wall in the active document
"""
if not FreeCAD.ActiveDocument:
FreeCAD.Console.PrintError("No active document. Aborting\n")
return
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","CurtainWall")
obj.Label = name if name else translate("Arch","Curtain Wall")
CurtainWall(obj)
if FreeCAD.GuiUp:
ViewProviderCurtainWall(obj.ViewObject)
if baseobj:
obj.Base = baseobj
if FreeCAD.GuiUp:
baseobj.ViewObject.hide()
return obj
class CommandArchCurtainWall:
"the Arch Curtain Wall command definition"
def GetResources(self):
return {'Pixmap' : 'Arch_CurtainWall',
'MenuText': QT_TRANSLATE_NOOP("Arch_CurtainWall","Curtain Wall"),
'Accel': "C, W",
'ToolTip': QT_TRANSLATE_NOOP("Arch_CurtainWall","Creates a curtain wall object from selected line or from scratch")}
def IsActive(self):
return not FreeCAD.ActiveDocument is None
def Activated(self):
sel = FreeCADGui.Selection.getSelection()
if len(sel) > 1:
FreeCAD.Console.PrintError(translate("Arch","Please select only one base object or none")+"\n")
elif len(sel) == 1:
# build on selection
FreeCADGui.Control.closeDialog()
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Curtain Wall"))
FreeCADGui.addModule("Draft")
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("obj = Arch.makeCurtainWall(FreeCAD.ActiveDocument."+FreeCADGui.Selection.getSelection()[0].Name+")")
FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
else:
# interactive line drawing
self.points = []
import WorkingPlane
WorkingPlane.get_working_plane()
if hasattr(FreeCADGui,"Snapper"):
FreeCADGui.Snapper.getPoint(callback=self.getPoint)
def getPoint(self,point=None,obj=None):
"""Callback for clicks during interactive mode"""
if point is None:
# cancelled
return
self.points.append(point)
if len(self.points) == 1:
FreeCADGui.Snapper.getPoint(last=self.points[0],callback=self.getPoint)
elif len(self.points) == 2:
FreeCADGui.Control.closeDialog()
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Curtain Wall"))
FreeCADGui.addModule("Draft")
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("base = Draft.makeLine(FreeCAD."+str(self.points[0])+",FreeCAD."+str(self.points[1])+")")
FreeCADGui.doCommand("obj = Arch.makeCurtainWall(base)")
FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
class CurtainWall(ArchComponent.Component):
@@ -611,7 +529,3 @@ class ViewProviderCurtainWall(ArchComponent.ViewProviderComponent):
if self.areDifferentColors(colors,obj.ViewObject.DiffuseColor) or force:
obj.ViewObject.DiffuseColor = colors
if FreeCAD.GuiUp:
FreeCADGui.addCommand('Arch_CurtainWall',CommandArchCurtainWall())

View File

@@ -157,93 +157,3 @@ def cutComponentwithPlane(baseObj, cutterShp=None, side=0):
baseParent.addObject(cutObj)
cutObj.Base = baseObj
cutObj.Tool = obj
class _CommandCutPlane:
"the Arch CutPlane command definition"
def GetResources(self):
return {"Pixmap": "Arch_CutPlane",
"MenuText": QtCore.QT_TRANSLATE_NOOP("Arch_CutPlane", "Cut with plane"),
"ToolTip": QtCore.QT_TRANSLATE_NOOP("Arch_CutPlane", "Cut an object with a plane")}
def IsActive(self):
return len(FreeCADGui.Selection.getSelection()) > 1
def Activated(self):
baseObj, baseShp, cutterShp = _getShapes(FreeCADGui.Selection.getSelectionEx("", 0))
if baseObj is None:
FreeCAD.Console.PrintError(
translate("Arch", "Select two objects, an object to be cut and an object defining a cutting plane, in that order\n")
)
return
if baseShp is None:
FreeCAD.Console.PrintError(translate("Arch", "The first object does not have a shape\n"))
return
if cutterShp is None:
FreeCAD.Console.PrintError(translate("Arch", "The second object does not define a plane\n"))
return
panel=_CutPlaneTaskPanel()
FreeCADGui.Control.showDialog(panel)
class _CutPlaneTaskPanel:
def __init__(self):
_, self.base, self.cutter = _getShapes(FreeCADGui.Selection.getSelectionEx("", 0))
self.previewObj = FreeCAD.ActiveDocument.addObject("Part::Feature", "PreviewCutVolume")
self.previewObj.ViewObject.ShapeColor = (1.00, 0.00, 0.00)
self.previewObj.ViewObject.Transparency = 75
self.form = QtGui.QWidget()
self.form.setObjectName("TaskPanel")
self.grid = QtGui.QGridLayout(self.form)
self.grid.setObjectName("grid")
self.title = QtGui.QLabel(self.form)
self.grid.addWidget(self.title, 1, 0)
self.infoText = QtGui.QLabel(self.form)
self.grid.addWidget(self.infoText, 2, 0)
self.combobox = QtGui.QComboBox()
self.combobox.setCurrentIndex(0)
self.grid.addWidget(self.combobox, 2, 1)
QtCore.QObject.connect(self.combobox,QtCore.SIGNAL("currentIndexChanged(int)"), self.previewCutVolume)
self.retranslateUi(self.form)
self.previewCutVolume(self.combobox.currentIndex())
def isAllowedAlterSelection(self):
return False
def accept(self):
FreeCAD.ActiveDocument.removeObject(self.previewObj.Name)
side = self.combobox.currentIndex()
FreeCAD.ActiveDocument.openTransaction(translate("Arch", "Cutting"))
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("sels = FreeCADGui.Selection.getSelectionEx('', 0)")
FreeCADGui.doCommand("Arch.cutComponentwithPlane(sels, side=" + str(side) + ")")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
return True
def reject(self):
FreeCAD.ActiveDocument.removeObject(self.previewObj.Name)
FreeCAD.Console.PrintMessage("Cancel Cut Plane\n")
return True
def getStandardButtons(self):
return QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel
def previewCutVolume(self, i):
cutVolume = ArchCommands.getCutVolume(self.cutter, self.base)
if i == 1:
cutVolume = cutVolume[1]
else:
cutVolume = cutVolume[2]
if cutVolume:
self.previewObj.Shape = cutVolume
def retranslateUi(self, TaskPanel):
TaskPanel.setWindowTitle(translate("Arch", "Cut Plane"))
self.title.setText(translate("Arch", "Cut Plane options"))
self.infoText.setText(translate("Arch", "Which side to cut"))
self.combobox.addItems([translate("Arch", "Behind"), translate("Arch", "Front")])
if FreeCAD.GuiUp:
FreeCADGui.addCommand("Arch_CutPlane", _CommandCutPlane())

View File

@@ -49,27 +49,7 @@ else:
# or hydraulic appliances in a building
def makeEquipment(baseobj=None,placement=None,name=None):
"makeEquipment([baseobj],[placement],[name]): creates an equipment object from the given base object."
if not FreeCAD.ActiveDocument:
FreeCAD.Console.PrintError("No active document. Aborting\n")
return
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","Equipment")
obj.Label = name if name else translate("Arch","Equipment")
_Equipment(obj)
if baseobj:
if baseobj.isDerivedFrom("Mesh::Feature"):
obj.Mesh = baseobj
else:
obj.Base = baseobj
if placement:
obj.Placement = placement
if FreeCAD.GuiUp:
_ViewProviderEquipment(obj.ViewObject)
if baseobj:
baseobj.ViewObject.hide()
return obj
def createMeshView(obj,direction=FreeCAD.Vector(0,0,-1),outeronly=False,largestonly=False):
@@ -163,110 +143,6 @@ def createMeshView(obj,direction=FreeCAD.Vector(0,0,-1),outeronly=False,largesto
return shape
class _CommandEquipment:
"the Arch Equipment command definition"
def GetResources(self):
return {'Pixmap' : 'Arch_Equipment',
'MenuText': QT_TRANSLATE_NOOP("Arch_Equipment","Equipment"),
'Accel': "E, Q",
'ToolTip': QT_TRANSLATE_NOOP("Arch_Equipment","Creates an equipment from a selected object (Part or Mesh)")}
def IsActive(self):
return not FreeCAD.ActiveDocument is None
def Activated(self):
s = FreeCADGui.Selection.getSelection()
if not s:
FreeCAD.Console.PrintError(translate("Arch","You must select a base shape object and optionally a mesh object"))
else:
base = ""
mesh = ""
if len(s) == 2:
if hasattr(s[0],'Shape'):
base = s[0].Name
elif s[0].isDerivedFrom("Mesh::Feature"):
mesh = s[0].Name
if hasattr(s[1],'Shape'):
if mesh:
base = s[1].Name
elif s[1].isDerivedFrom("Mesh::Feature"):
if base:
mesh = s[1].Name
else:
if hasattr(s[0],'Shape'):
base = s[0].Name
elif s[0].isDerivedFrom("Mesh::Feature"):
mesh = s[0].Name
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Create Equipment")))
FreeCADGui.addModule("Arch")
if base:
base = "FreeCAD.ActiveDocument." + base
FreeCADGui.doCommand("obj = Arch.makeEquipment(" + base + ")")
if mesh:
FreeCADGui.doCommand("obj.Mesh = FreeCAD.ActiveDocument." + mesh)
FreeCADGui.addModule("Draft")
FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
# get diffuse color info from base object
if base and hasattr(s[0].ViewObject,"DiffuseColor"):
FreeCADGui.doCommand("FreeCAD.ActiveDocument.Objects[-1].ViewObject.DiffuseColor = " + base + ".ViewObject.DiffuseColor")
return
class _Command3Views:
"the Arch 3Views command definition"
def GetResources(self):
return {'Pixmap' : 'Arch_3Views',
'MenuText': QT_TRANSLATE_NOOP("Arch_3Views","3 views from mesh"),
'ToolTip': QT_TRANSLATE_NOOP("Arch_3Views","Creates 3 views (top, front, side) from a mesh-based object")}
def IsActive(self):
return not FreeCAD.ActiveDocument is None
def Activated(self):
s = FreeCADGui.Selection.getSelection()
if len(s) != 1:
FreeCAD.Console.PrintError(translate("Arch","You must select exactly one base object"))
else:
obj = s[0]
if not obj.isDerivedFrom("Mesh::Feature"):
FreeCAD.Console.PrintError(translate("Arch","The selected object must be a mesh"))
else:
if obj.Mesh.CountFacets > 1000:
msgBox = QtGui.QMessageBox()
msgBox.setText(translate("Arch","This mesh has more than 1000 facets."))
msgBox.setInformativeText(translate("Arch","This operation can take a long time. Proceed?"))
msgBox.setStandardButtons(QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel)
msgBox.setDefaultButton(QtGui.QMessageBox.Cancel)
ret = msgBox.exec_()
if ret == QtGui.QMessageBox.Cancel:
return
elif obj.Mesh.CountFacets >= 500:
FreeCAD.Console.PrintWarning(translate("Arch","The mesh has more than 500 facets. This will take a couple of minutes..."))
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Create 3 views")))
FreeCADGui.addModule("Arch")
FreeCADGui.addModule("Part")
FreeCADGui.doCommand("s1 = Arch.createMeshView(FreeCAD.ActiveDocument." + obj.Name + ",FreeCAD.Vector(0,0,-1),outeronly=False,largestonly=False)")
FreeCADGui.doCommand("Part.show(s1)")
FreeCADGui.doCommand("s2 = Arch.createMeshView(FreeCAD.ActiveDocument." + obj.Name + ",FreeCAD.Vector(1,0,0),outeronly=False,largestonly=False)")
FreeCADGui.doCommand("Part.show(s2)")
FreeCADGui.doCommand("s3 = Arch.createMeshView(FreeCAD.ActiveDocument." + obj.Name + ",FreeCAD.Vector(0,1,0),outeronly=False,largestonly=False)")
FreeCADGui.doCommand("Part.show(s3)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
return
class _Equipment(ArchComponent.Component):
@@ -428,7 +304,3 @@ class _ViewProviderEquipment(ArchComponent.ViewProviderComponent):
else:
self.coords.point.deleteValues(0)
if FreeCAD.GuiUp:
FreeCADGui.addCommand('Arch_Equipment',_CommandEquipment())
FreeCADGui.addCommand('Arch_3Views', _Command3Views())

View File

@@ -374,61 +374,12 @@ class _ViewProviderFence(ArchComponent.ViewProviderComponent):
return colorsToUse[start:end]
class _CommandFence:
"the Arch Fence command definition"
def GetResources(self):
return {'Pixmap': 'Arch_Fence',
'MenuText': QT_TRANSLATE_NOOP("Arch_Fence", "Fence"),
'ToolTip': QT_TRANSLATE_NOOP("Arch_Fence", "Creates a fence object from a selected section, post and path")}
def IsActive(self):
return not FreeCAD.ActiveDocument is None
def Activated(self):
sel = FreeCADGui.Selection.getSelection()
if len(sel) != 3:
QtGui.QMessageBox.information(QtGui.QApplication.activeWindow(
), 'Arch Fence selection', 'Select a section, post and path in exactly this order to build a fence.')
return
section = sel[0]
post = sel[1]
path = sel[2]
makeFence(section, post, path)
def makeFence(section, post, path):
obj = FreeCAD.ActiveDocument.addObject(
'Part::FeaturePython', 'Fence')
_Fence(obj)
obj.Section = section
obj.Post = post
obj.Path = path
if FreeCAD.GuiUp:
_ViewProviderFence(obj.ViewObject)
hide(section)
hide(post)
hide(path)
FreeCAD.ActiveDocument.recompute()
return obj
def hide(obj):
if hasattr(obj, 'ViewObject') and obj.ViewObject:
obj.ViewObject.Visibility = False
if FreeCAD.GuiUp:
FreeCADGui.addCommand('Arch_Fence', _CommandFence())
if __name__ == '__main__':
# For testing purposes. When someone runs the File as a macro a default fence will be generated

View File

@@ -48,55 +48,6 @@ __author__ = "Yorik van Havre"
__url__ = "https://www.freecad.org"
def makeFrame(baseobj,profile,name=None):
"""makeFrame(baseobj,profile,[name]): creates a frame object from a base sketch (or any other object
containing wires) and a profile object (an extrudable 2D object containing faces or closed wires)"""
if not FreeCAD.ActiveDocument:
FreeCAD.Console.PrintError("No active document. Aborting\n")
return
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","Frame")
obj.Label = name if name else translate("Arch","Frame")
_Frame(obj)
if FreeCAD.GuiUp:
_ViewProviderFrame(obj.ViewObject)
if baseobj:
obj.Base = baseobj
if profile:
obj.Profile = profile
if FreeCAD.GuiUp:
profile.ViewObject.hide()
return obj
class _CommandFrame:
"the Arch Frame command definition"
def GetResources(self):
return {'Pixmap' : 'Arch_Frame',
'MenuText': QT_TRANSLATE_NOOP("Arch_Frame","Frame"),
'Accel': "F, R",
'ToolTip': QT_TRANSLATE_NOOP("Arch_Frame","Creates a frame object from a planar 2D object (the extrusion path(s)) and a profile. Make sure objects are selected in that order.")}
def IsActive(self):
return not FreeCAD.ActiveDocument is None
def Activated(self):
s = FreeCADGui.Selection.getSelection()
if len(s) == 2:
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Frame"))
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("obj = Arch.makeFrame(FreeCAD.ActiveDocument."+s[0].Name+",FreeCAD.ActiveDocument."+s[1].Name+")")
FreeCADGui.addModule("Draft")
FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
class _Frame(ArchComponent.Component):
@@ -276,6 +227,3 @@ class _ViewProviderFrame(ArchComponent.ViewProviderComponent):
p = [self.Object.Profile]
return ArchComponent.ViewProviderComponent.claimChildren(self)+p
if FreeCAD.GuiUp:
FreeCADGui.addCommand('Arch_Frame',_CommandFrame())

View File

@@ -47,44 +47,6 @@ __url__ = "https://www.freecad.org"
# This module provides tools to build grid systems
def makeGrid(name=None):
'''makeGrid([name]): makes a grid object'''
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","Grid")
obj.Label = name if name else translate("Arch","Grid")
ArchGrid(obj)
if FreeCAD.GuiUp:
ViewProviderArchGrid(obj.ViewObject)
obj.ViewObject.Transparency = 85
FreeCAD.ActiveDocument.recompute()
return obj
class CommandArchGrid:
"the Arch Grid command definition"
def GetResources(self):
return {'Pixmap' : 'Arch_Grid',
'MenuText': QT_TRANSLATE_NOOP("Arch_Grid","Grid"),
'Accel': "A, X",
'ToolTip': QT_TRANSLATE_NOOP("Arch_Grid","Creates a customizable grid object")}
def Activated(self):
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Grid"))
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("Arch.makeGrid()")
FreeCAD.ActiveDocument.commitTransaction()
def IsActive(self):
return not FreeCAD.ActiveDocument is None
class ArchGrid:
"The Grid object"

View File

@@ -47,134 +47,6 @@ __url__ = "https://www.freecad.org"
# This module provides tools to add materials to
# Arch objects
def makeMaterial(name=None,color=None,transparency=None):
'''makeMaterial([name],[color],[transparency]): makes an Material object'''
if not FreeCAD.ActiveDocument:
FreeCAD.Console.PrintError("No active document. Aborting\n")
return
obj = FreeCAD.ActiveDocument.addObject("App::MaterialObjectPython","Material")
obj.Label = name if name else translate("Arch","Material")
_ArchMaterial(obj)
if FreeCAD.GuiUp:
_ViewProviderArchMaterial(obj.ViewObject)
getMaterialContainer().addObject(obj)
if color:
obj.Color = color[:3]
if len(color) > 3:
obj.Transparency = color[3]*100
if transparency:
obj.Transparency = transparency
return obj
def getMaterialContainer():
'''getMaterialContainer(): returns a group object to put materials in'''
for obj in FreeCAD.ActiveDocument.Objects:
if obj.Name == "MaterialContainer":
return obj
obj = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroupPython","MaterialContainer")
obj.Label = "Materials"
_ArchMaterialContainer(obj)
if FreeCAD.GuiUp:
_ViewProviderArchMaterialContainer(obj.ViewObject)
return obj
def makeMultiMaterial(name=None):
'''makeMultiMaterial([name]): makes an MultiMaterial object'''
obj = FreeCAD.ActiveDocument.addObject("App::FeaturePython","MultiMaterial")
obj.Label = name if name else translate("Arch","MultiMaterial")
_ArchMultiMaterial(obj)
if FreeCAD.GuiUp:
_ViewProviderArchMultiMaterial(obj.ViewObject)
getMaterialContainer().addObject(obj)
return obj
def getDocumentMaterials():
'''getDocumentMaterials(): returns all the arch materials of the document'''
for obj in FreeCAD.ActiveDocument.Objects:
if obj.Name == "MaterialContainer":
mats = []
for o in obj.Group:
if o.isDerivedFrom("App::MaterialObjectPython"):
mats.append(o)
return mats
return []
class _CommandArchMaterial:
"the Arch Material command definition"
def GetResources(self):
return {'Pixmap': 'Arch_Material_Group',
'MenuText': QT_TRANSLATE_NOOP("Arch_Material","Material"),
'Accel': "M, T",
'ToolTip': QT_TRANSLATE_NOOP("Arch_Material","Creates or edits the material definition of a selected object.")}
def Activated(self):
sel = FreeCADGui.Selection.getSelection()
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create material"))
FreeCADGui.addModule("Arch")
FreeCADGui.Control.closeDialog()
FreeCADGui.doCommand("mat = Arch.makeMaterial()")
for obj in sel:
if hasattr(obj,"Material"):
FreeCADGui.doCommand("FreeCAD.ActiveDocument.getObject(\""+obj.Name+"\").Material = mat")
FreeCADGui.doCommandGui("mat.ViewObject.Document.setEdit(mat.ViewObject, 0)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
def IsActive(self):
if FreeCAD.ActiveDocument:
return True
else:
return False
class _CommandArchMultiMaterial:
"the Arch MultiMaterial command definition"
def GetResources(self):
return {'Pixmap': 'Arch_Material_Multi',
'MenuText': QT_TRANSLATE_NOOP("Arch_MultiMaterial","Multi-Material"),
'Accel': "M, T",
'ToolTip': QT_TRANSLATE_NOOP("Arch_MultiMaterial","Creates or edits multi-materials")}
def Activated(self):
sel = FreeCADGui.Selection.getSelection()
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create multi-material"))
FreeCADGui.addModule("Arch")
FreeCADGui.Control.closeDialog()
FreeCADGui.doCommand("mat = Arch.makeMultiMaterial()")
for obj in sel:
if hasattr(obj,"Material"):
if not obj.isDerivedFrom("App::MaterialObject"):
FreeCADGui.doCommand("FreeCAD.ActiveDocument."+obj.Name+".Material = mat")
FreeCADGui.doCommandGui("mat.ViewObject.Document.setEdit(mat.ViewObject, 0)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
def IsActive(self):
if FreeCAD.ActiveDocument:
return True
else:
return False
class _ArchMaterialContainer:
@@ -1023,19 +895,3 @@ class _ArchMultiMaterialTaskPanel:
return True
if FreeCAD.GuiUp:
FreeCADGui.addCommand('Arch_Material',_CommandArchMaterial())
FreeCADGui.addCommand('Arch_MultiMaterial',_CommandArchMultiMaterial())
class _ArchMaterialToolsCommand:
def GetCommands(self):
return tuple(['Arch_Material','Arch_MultiMaterial'])
def GetResources(self):
return { 'MenuText': QT_TRANSLATE_NOOP("Arch_MaterialTools",'Material tools'),
'ToolTip': QT_TRANSLATE_NOOP("Arch_MaterialTools",'Material tools')
}
def IsActive(self):
return not FreeCAD.ActiveDocument is None
FreeCADGui.addCommand('Arch_MaterialTools', _ArchMaterialToolsCommand())

View File

@@ -70,309 +70,6 @@ Presets = [None,
def makePanel(baseobj=None,length=0,width=0,thickness=0,placement=None,name=None):
'''makePanel([baseobj],[length],[width],[thickness],[placement],[name]): creates a
panel element based on the given profile object and the given
extrusion thickness. If no base object is given, you can also specify
length and width for a simple cubic object.'''
if not FreeCAD.ActiveDocument:
FreeCAD.Console.PrintError("No active document. Aborting\n")
return
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","Panel")
obj.Label = name if name else translate("Arch","Panel")
_Panel(obj)
if FreeCAD.GuiUp:
_ViewProviderPanel(obj.ViewObject)
if baseobj:
obj.Base = baseobj
if FreeCAD.GuiUp:
obj.Base.ViewObject.hide()
if width:
obj.Width = width
if thickness:
obj.Thickness = thickness
if length:
obj.Length = length
return obj
def makePanelCut(panel,name=None):
"""makePanelCut(panel,[name]) : Creates a 2D view of the given panel
in the 3D space, positioned at the origin."""
view = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","PanelCut")
view.Label = name if name else translate("Arch","View of")+" "+panel.Label
PanelCut(view)
view.Source = panel
if FreeCAD.GuiUp:
ViewProviderPanelCut(view.ViewObject)
return view
def makePanelSheet(panels=[],name=None):
"""makePanelSheet([panels],[name]) : Creates a sheet with the given panel cuts
in the 3D space, positioned at the origin."""
sheet = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","PanelSheet")
sheet.Label = name if name else translate("Arch","PanelSheet")
PanelSheet(sheet)
if panels:
sheet.Group = panels
if FreeCAD.GuiUp:
ViewProviderPanelSheet(sheet.ViewObject)
return sheet
class CommandPanel:
"the Arch Panel command definition"
def GetResources(self):
return {'Pixmap' : 'Arch_Panel',
'MenuText': QT_TRANSLATE_NOOP("Arch_Panel","Panel"),
'Accel': "P, A",
'ToolTip': QT_TRANSLATE_NOOP("Arch_Panel","Creates a panel object from scratch or from a selected object (sketch, wire, face or solid)")}
def IsActive(self):
return not FreeCAD.ActiveDocument is None
def Activated(self):
self.Length = params.get_param_arch("PanelLength")
self.Width = params.get_param_arch("PanelWidth")
self.Thickness = params.get_param_arch("PanelThickness")
self.Profile = None
self.continueCmd = False
self.rotated = False
sel = FreeCADGui.Selection.getSelection()
if sel:
if len(sel) == 1:
if Draft.getType(sel[0]) == "Panel":
return
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Create Panel")))
FreeCADGui.addModule("Arch")
FreeCADGui.addModule("Draft")
for obj in sel:
FreeCADGui.doCommand("obj = Arch.makePanel(FreeCAD.ActiveDocument." + obj.Name + ",thickness=" + str(self.Thickness) + ")")
FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
return
# interactive mode
import WorkingPlane
WorkingPlane.get_working_plane()
self.points = []
self.tracker = DraftTrackers.boxTracker()
self.tracker.width(self.Width)
self.tracker.height(self.Thickness)
self.tracker.length(self.Length)
self.tracker.on()
FreeCADGui.Snapper.getPoint(callback=self.getPoint,movecallback=self.update,extradlg=self.taskbox())
def getPoint(self,point=None,obj=None):
"this function is called by the snapper when it has a 3D point"
self.tracker.finalize()
if point is None:
return
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Panel"))
FreeCADGui.addModule("Arch")
if self.Profile:
pr = Presets[self.Profile]
FreeCADGui.doCommand('p = Arch.makeProfile('+str(pr[2])+','+str(pr[3])+','+str(pr[4])+','+str(pr[5])+')')
FreeCADGui.doCommand('s = Arch.makePanel(p,thickness='+str(self.Thickness)+')')
#FreeCADGui.doCommand('s.Placement.Rotation = FreeCAD.Rotation(-0.5,0.5,-0.5,0.5)')
else:
FreeCADGui.doCommand('s = Arch.makePanel(length='+str(self.Length)+',width='+str(self.Width)+',thickness='+str(self.Thickness)+')')
FreeCADGui.doCommand('s.Placement.Base = '+DraftVecUtils.toString(point))
if self.rotated:
FreeCADGui.doCommand('s.Placement.Rotation = FreeCAD.Rotation(FreeCAD.Vector(1.00,0.00,0.00),90.00)')
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
if self.continueCmd:
self.Activated()
def taskbox(self):
"sets up a taskbox widget"
w = QtGui.QWidget()
ui = FreeCADGui.UiLoader()
w.setWindowTitle(translate("Arch","Panel options"))
grid = QtGui.QGridLayout(w)
# presets box
labelp = QtGui.QLabel(translate("Arch","Preset"))
valuep = QtGui.QComboBox()
fpresets = [" "]
for p in Presets[1:]:
fpresets.append(translate("Arch",p[0]))
valuep.addItems(fpresets)
grid.addWidget(labelp,0,0,1,1)
grid.addWidget(valuep,0,1,1,1)
# length
label1 = QtGui.QLabel(translate("Arch","Length"))
self.vLength = ui.createWidget("Gui::InputField")
self.vLength.setText(FreeCAD.Units.Quantity(self.Length,FreeCAD.Units.Length).UserString)
grid.addWidget(label1,1,0,1,1)
grid.addWidget(self.vLength,1,1,1,1)
# width
label2 = QtGui.QLabel(translate("Arch","Width"))
self.vWidth = ui.createWidget("Gui::InputField")
self.vWidth.setText(FreeCAD.Units.Quantity(self.Width,FreeCAD.Units.Length).UserString)
grid.addWidget(label2,2,0,1,1)
grid.addWidget(self.vWidth,2,1,1,1)
# height
label3 = QtGui.QLabel(translate("Arch","Thickness"))
self.vHeight = ui.createWidget("Gui::InputField")
self.vHeight.setText(FreeCAD.Units.Quantity(self.Thickness,FreeCAD.Units.Length).UserString)
grid.addWidget(label3,3,0,1,1)
grid.addWidget(self.vHeight,3,1,1,1)
# horizontal button
value5 = QtGui.QPushButton(translate("Arch","Rotate"))
grid.addWidget(value5,4,0,1,2)
# continue button
label4 = QtGui.QLabel(translate("Arch","Con&tinue"))
value4 = QtGui.QCheckBox()
value4.setObjectName("ContinueCmd")
value4.setLayoutDirection(QtCore.Qt.RightToLeft)
label4.setBuddy(value4)
self.continueCmd = params.get_param("ContinueMode")
value4.setChecked(self.continueCmd)
grid.addWidget(label4,5,0,1,1)
grid.addWidget(value4,5,1,1,1)
QtCore.QObject.connect(valuep,QtCore.SIGNAL("currentIndexChanged(int)"),self.setPreset)
QtCore.QObject.connect(self.vLength,QtCore.SIGNAL("valueChanged(double)"),self.setLength)
QtCore.QObject.connect(self.vWidth,QtCore.SIGNAL("valueChanged(double)"),self.setWidth)
QtCore.QObject.connect(self.vHeight,QtCore.SIGNAL("valueChanged(double)"),self.setThickness)
QtCore.QObject.connect(value4,QtCore.SIGNAL("stateChanged(int)"),self.setContinue)
QtCore.QObject.connect(value5,QtCore.SIGNAL("pressed()"),self.rotate)
return w
def update(self,point,info):
"this function is called by the Snapper when the mouse is moved"
if FreeCADGui.Control.activeDialog():
self.tracker.pos(point)
if self.rotated:
self.tracker.width(self.Thickness)
self.tracker.height(self.Width)
self.tracker.length(self.Length)
else:
self.tracker.width(self.Width)
self.tracker.height(self.Thickness)
self.tracker.length(self.Length)
def setWidth(self,d):
self.Width = d
params.set_param_arch("PanelWidth",d)
def setThickness(self,d):
self.Thickness = d
params.set_param_arch("PanelThickness",d)
def setLength(self,d):
self.Length = d
params.set_param_arch("PanelLength",d)
def setContinue(self,i):
self.continueCmd = bool(i)
params.set_param("ContinueMode", bool(i))
def setPreset(self,i):
if i > 0:
self.vLength.setText(FreeCAD.Units.Quantity(float(Presets[i][1]),FreeCAD.Units.Length).UserString)
self.vWidth.setText(FreeCAD.Units.Quantity(float(Presets[i][2]),FreeCAD.Units.Length).UserString)
self.vHeight.setText(FreeCAD.Units.Quantity(float(Presets[i][3]),FreeCAD.Units.Length).UserString)
def rotate(self):
self.rotated = not self.rotated
class CommandPanelCut:
"the Arch Panel Cut command definition"
def GetResources(self):
return {'Pixmap' : 'Arch_Panel_Cut',
'MenuText': QT_TRANSLATE_NOOP("Arch_Panel_Cut","Panel Cut"),
'Accel': "P, C",
'ToolTip': QT_TRANSLATE_NOOP("Arch_Panel_Cut","Creates 2D views of selected panels")}
def IsActive(self):
return not FreeCAD.ActiveDocument is None
def Activated(self):
if FreeCADGui.Selection.getSelection():
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Create Panel Cut")))
FreeCADGui.addModule("Arch")
for obj in FreeCADGui.Selection.getSelection():
if Draft.getType(obj) == "Panel":
FreeCADGui.doCommand("Arch.makePanelCut(FreeCAD.ActiveDocument."+obj.Name+")")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
class CommandPanelSheet:
"the Arch Panel Sheet command definition"
def GetResources(self):
return {'Pixmap' : 'Arch_Panel_Sheet',
'MenuText': QT_TRANSLATE_NOOP("Arch_Panel_Sheet","Panel Sheet"),
'Accel': "P, S",
'ToolTip': QT_TRANSLATE_NOOP("Arch_Panel_Sheet","Creates a 2D sheet which can contain panel cuts")}
def IsActive(self):
return not FreeCAD.ActiveDocument is None
def Activated(self):
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Create Panel Sheet")))
FreeCADGui.addModule("Arch")
if FreeCADGui.Selection.getSelection():
l = "["
for obj in FreeCADGui.Selection.getSelection():
l += "FreeCAD.ActiveDocument."+obj.Name+","
l += "]"
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
FreeCADGui.doCommand("__objs__ = "+l)
FreeCADGui.doCommand("Arch.makePanelSheet(__objs__)")
FreeCADGui.doCommand("del __objs__")
else:
FreeCADGui.doCommand("Arch.makePanelSheet()")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
class _Panel(ArchComponent.Component):
"The Panel object"
@@ -1394,190 +1091,4 @@ class SheetTaskPanel(ArchComponent.ComponentTaskPanel):
FreeCADGui.runCommand("Draft_Edit")
class CommandNest:
"the Arch Panel command definition"
def GetResources(self):
return {'Pixmap' : 'Arch_Nest',
'MenuText': QT_TRANSLATE_NOOP("Arch_Nest","Nest"),
'Accel': "N, E",
'ToolTip': QT_TRANSLATE_NOOP("Arch_Nest","Nests a series of selected shapes in a container")}
def IsActive(self):
return not FreeCAD.ActiveDocument is None
def Activated(self):
FreeCADGui.Control.closeDialog()
FreeCADGui.Control.showDialog(NestTaskPanel())
class NestTaskPanel:
'''The TaskPanel for Arch Nest command'''
def __init__(self,obj=None):
import ArchNesting
self.form = FreeCADGui.PySideUic.loadUi(":/ui/ArchNest.ui")
self.form.progressBar.hide()
self.form.ButtonPreview.setEnabled(False)
self.form.ButtonStop.setEnabled(False)
QtCore.QObject.connect(self.form.ButtonContainer,QtCore.SIGNAL("pressed()"),self.getContainer)
QtCore.QObject.connect(self.form.ButtonShapes,QtCore.SIGNAL("pressed()"),self.getShapes)
QtCore.QObject.connect(self.form.ButtonRemove,QtCore.SIGNAL("pressed()"),self.removeShapes)
QtCore.QObject.connect(self.form.ButtonStart,QtCore.SIGNAL("pressed()"),self.start)
QtCore.QObject.connect(self.form.ButtonStop,QtCore.SIGNAL("pressed()"),self.stop)
QtCore.QObject.connect(self.form.ButtonPreview,QtCore.SIGNAL("pressed()"),self.preview)
self.shapes = []
self.container = None
self.nester = None
self.temps = []
def reject(self):
self.stop()
self.clearTemps()
return True
def accept(self):
self.stop()
self.clearTemps()
if self.nester:
FreeCAD.ActiveDocument.openTransaction("Nesting")
self.nester.apply()
FreeCAD.ActiveDocument.commitTransaction()
return True
def clearTemps(self):
for t in self.temps:
if FreeCAD.ActiveDocument.getObject(t.Name):
FreeCAD.ActiveDocument.removeObject(t.Name)
self.temps = []
def getContainer(self):
s = FreeCADGui.Selection.getSelection()
if len(s) == 1:
if hasattr(s[0],'Shape'):
if len(s[0].Shape.Faces) == 1:
if not (s[0] in self.shapes):
self.form.Container.clear()
self.addObject(s[0],self.form.Container)
self.container = s[0]
else:
FreeCAD.Console.PrintError(translate("Arch","This object has no face"))
if Draft.getType(s[0]) == "PanelSheet":
if hasattr(s[0],"Rotations"):
if s[0].Rotations:
self.form.Rotations.setText(str(s[0].Rotations))
def getShapes(self):
s = FreeCADGui.Selection.getSelection()
for o in s:
if hasattr(o,'Shape'):
if not o in self.shapes:
if o != self.container:
self.addObject(o,self.form.Shapes)
self.shapes.append(o)
def addObject(self,obj,form):
i = QtGui.QListWidgetItem()
i.setText(obj.Label)
i.setToolTip(obj.Name)
if hasattr(obj.ViewObject,"Proxy"):
if hasattr(obj.ViewObject.Proxy,"getIcon"):
i.setIcon(QtGui.QIcon(obj.ViewObject.Proxy.getIcon()))
elif hasattr(obj.ViewObject, "Icon"):
i.setIcon(QtGui.QIcon(obj.ViewObject.Icon))
else:
i.setIcon(QtGui.QIcon(":/icons/Part_3D_object.svg"))
form.addItem(i)
def removeShapes(self):
for i in self.form.Shapes.selectedItems():
o = FreeCAD.ActiveDocument.getObject(i.toolTip())
if o:
if o in self.shapes:
self.shapes.remove(o)
self.form.Shapes.takeItem(self.form.Shapes.row(i))
def setCounter(self,value):
self.form.progressBar.setValue(value)
def start(self):
self.clearTemps()
self.form.progressBar.setFormat("pass 1: %p%")
self.form.progressBar.setValue(0)
self.form.progressBar.show()
tolerance = self.form.Tolerance.value()
discretize = self.form.Subdivisions.value()
rotations = [float(x) for x in self.form.Rotations.text().split(",")]
import ArchNesting
ArchNesting.TOLERANCE = tolerance
ArchNesting.DISCRETIZE = discretize
ArchNesting.ROTATIONS = rotations
self.nester = ArchNesting.Nester()
self.nester.addContainer(self.container)
self.nester.addObjects(self.shapes)
self.nester.setCounter = self.setCounter
self.form.ButtonStop.setEnabled(True)
self.form.ButtonStart.setEnabled(False)
self.form.ButtonPreview.setEnabled(False)
QtGui.QApplication.processEvents()
result = self.nester.run()
self.form.progressBar.hide()
self.form.ButtonStart.setEnabled(True)
self.form.ButtonStop.setEnabled(False)
if result:
self.form.ButtonPreview.setEnabled(True)
def stop(self):
if self.nester:
self.nester.stop()
self.form.ButtonStart.setEnabled(True)
self.form.ButtonStop.setEnabled(False)
self.form.ButtonPreview.setEnabled(False)
self.form.progressBar.hide()
def preview(self):
self.clearTemps()
if self.nester:
t = self.nester.show()
if t:
self.temps.extend(t)
if FreeCAD.GuiUp:
class CommandPanelGroup:
def GetCommands(self):
return tuple(['Arch_Panel','Arch_Panel_Cut','Arch_Panel_Sheet','Arch_Nest'])
def GetResources(self):
return { 'MenuText': QT_TRANSLATE_NOOP("Arch_PanelTools",'Panel tools'),
'ToolTip': QT_TRANSLATE_NOOP("Arch_PanelTools",'Panel tools')
}
def IsActive(self):
return not FreeCAD.ActiveDocument is None
FreeCADGui.addCommand('Arch_Panel',CommandPanel())
FreeCADGui.addCommand('Arch_Panel_Cut',CommandPanelCut())
FreeCADGui.addCommand('Arch_Panel_Sheet',CommandPanelSheet())
FreeCADGui.addCommand('Arch_Nest',CommandNest())
FreeCADGui.addCommand('Arch_PanelTools', CommandPanelGroup())

View File

@@ -49,132 +49,6 @@ __author__ = "Yorik van Havre"
__url__ = "https://www.freecad.org"
def makePipe(baseobj=None,diameter=0,length=0,placement=None,name=None):
"makePipe([baseobj],[diameter],[length],[placement],[name]): creates an pipe object from the given base object"
if not FreeCAD.ActiveDocument:
FreeCAD.Console.PrintError("No active document. Aborting\n")
return
obj= FreeCAD.ActiveDocument.addObject("Part::FeaturePython","Pipe")
obj.Label = name if name else translate("Arch","Pipe")
_ArchPipe(obj)
if FreeCAD.GuiUp:
_ViewProviderPipe(obj.ViewObject)
if baseobj:
baseobj.ViewObject.hide()
if baseobj:
obj.Base = baseobj
else:
if length:
obj.Length = length
else:
obj.Length = 1000
if diameter:
obj.Diameter = diameter
else:
obj.Diameter = params.get_param_arch("PipeDiameter")
if placement:
obj.Placement = placement
return obj
def makePipeConnector(pipes,radius=0,name=None):
"makePipeConnector(pipes,[radius],[name]): creates a connector between the given pipes"
if not FreeCAD.ActiveDocument:
FreeCAD.Console.PrintError("No active document. Aborting\n")
return
obj= FreeCAD.ActiveDocument.addObject("Part::FeaturePython","Connector")
obj.Label = name if name else translate("Arch","Connector")
_ArchPipeConnector(obj)
obj.Pipes = pipes
if not radius:
radius = pipes[0].Diameter
obj.Radius = radius
if FreeCAD.GuiUp:
_ViewProviderPipe(obj.ViewObject)
return obj
class _CommandPipe:
"the Arch Pipe command definition"
def GetResources(self):
return {'Pixmap' : 'Arch_Pipe',
'MenuText': QT_TRANSLATE_NOOP("Arch_Pipe","Pipe"),
'Accel': "P, I",
'ToolTip': QT_TRANSLATE_NOOP("Arch_Pipe","Creates a pipe object from a given Wire or Line")}
def IsActive(self):
return not FreeCAD.ActiveDocument is None
def Activated(self):
s = FreeCADGui.Selection.getSelection()
if s:
for obj in s:
if hasattr(obj,'Shape'):
if len(obj.Shape.Wires) == 1:
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Pipe"))
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("obj = Arch.makePipe(FreeCAD.ActiveDocument."+obj.Name+")")
FreeCADGui.addModule("Draft")
FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
else:
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Pipe"))
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("obj = Arch.makePipe()")
FreeCADGui.addModule("Draft")
FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
class _CommandPipeConnector:
"the Arch Pipe command definition"
def GetResources(self):
return {'Pixmap' : 'Arch_PipeConnector',
'MenuText': QT_TRANSLATE_NOOP("Arch_PipeConnector","Connector"),
'Accel': "P, C",
'ToolTip': QT_TRANSLATE_NOOP("Arch_PipeConnector","Creates a connector between 2 or 3 selected pipes")}
def IsActive(self):
return not FreeCAD.ActiveDocument is None
def Activated(self):
import Draft
s = FreeCADGui.Selection.getSelection()
if not (len(s) in [2,3]):
FreeCAD.Console.PrintError(translate("Arch","Please select exactly 2 or 3 Pipe objects")+"\n")
return
o = "["
for obj in s:
if Draft.getType(obj) != "Pipe":
FreeCAD.Console.PrintError(translate("Arch","Please select only Pipe objects")+"\n")
return
o += "FreeCAD.ActiveDocument."+obj.Name+","
o += "]"
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Connector"))
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("obj = Arch.makePipeConnector("+o+")")
FreeCADGui.addModule("Draft")
FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
class _ArchPipe(ArchComponent.Component):
@@ -509,19 +383,3 @@ class _ArchPipeConnector(ArchComponent.Component):
pipe.Proxy.execute(pipe)
if FreeCAD.GuiUp:
FreeCADGui.addCommand('Arch_Pipe',_CommandPipe())
FreeCADGui.addCommand('Arch_PipeConnector',_CommandPipeConnector())
class _ArchPipeGroupCommand:
def GetCommands(self):
return tuple(['Arch_Pipe','Arch_PipeConnector'])
def GetResources(self):
return { 'MenuText': QT_TRANSLATE_NOOP("Arch_PipeTools",'Pipe tools'),
'ToolTip': QT_TRANSLATE_NOOP("Arch_PipeTools",'Pipe tools')
}
def IsActive(self):
return not FreeCAD.ActiveDocument is None
FreeCADGui.addCommand('Arch_PipeTools', _ArchPipeGroupCommand())

View File

@@ -777,14 +777,14 @@ class _PrecastTaskPanel:
def __init__(self):
import FreeCADGui
from PySide import QtCore,QtGui,QtSvgWidgets
from PySide import QtCore,QtGui,QtSvg
self.form = QtGui.QWidget()
self.grid = QtGui.QGridLayout(self.form)
self.PrecastTypes = ["Beam","I-Beam","Pillar","Panel","Slab","Stairs"]
self.SlabTypes = ["Champagne","Hat"]
# image display
self.preview = QtSvgWidgets.QSvgWidget(":/ui/ParametersBeam.svg")
self.preview = QtSvg.QSvgWidget(":/ui/ParametersBeam.svg")
self.preview.setMaximumWidth(200)
self.preview.setMinimumHeight(120)
self.grid.addWidget(self.preview,0,0,1,2)
@@ -1263,7 +1263,7 @@ class _DentsTaskPanel:
def __init__(self):
import FreeCADGui
from PySide import QtCore,QtGui,QtSvgWidgets
from PySide import QtCore,QtGui,QtSvg
self.form = QtGui.QWidget()
self.grid = QtGui.QGridLayout(self.form)
self.Rotations = ["N","S","E","O"]
@@ -1282,7 +1282,7 @@ class _DentsTaskPanel:
self.grid.addWidget(self.buttonRemove,2,1,1,1)
# image display
self.preview = QtSvgWidgets.QSvgWidget(":/ui/ParametersDent.svg")
self.preview = QtSvg.QSvgWidget(":/ui/ParametersDent.svg")
self.preview.setMaximumWidth(200)
self.preview.setMinimumHeight(120)
self.grid.addWidget(self.preview,3,0,1,2)

View File

@@ -85,150 +85,6 @@ def readPresets():
print("Could not open ",profilefile)
return Presets
def makeProfile(profile=[0,'REC','REC100x100','R',100,100]):
'''makeProfile(profile): returns a shape with the face defined by the profile data'''
if not FreeCAD.ActiveDocument:
FreeCAD.Console.PrintError("No active document. Aborting\n")
return
obj = FreeCAD.ActiveDocument.addObject("Part::Part2DObjectPython",profile[2])
obj.Label = profile[2]
if profile[3]=="C":
_ProfileC(obj, profile)
elif profile[3]=="H":
_ProfileH(obj, profile)
elif profile[3]=="R":
_ProfileR(obj, profile)
elif profile[3]=="RH":
_ProfileRH(obj, profile)
elif profile[3]=="U":
_ProfileU(obj, profile)
elif profile[3]=="L":
_ProfileL(obj, profile)
elif profile[3]=="T":
_ProfileT(obj, profile)
else :
print("Profile not supported")
if FreeCAD.GuiUp:
ViewProviderProfile(obj.ViewObject)
return obj
class Arch_Profile:
"""The FreeCAD Arch_Profile command definition"""
def GetResources(self):
return {'Pixmap' : 'Arch_Profile',
'MenuText': QT_TRANSLATE_NOOP("Arch_Profile","Profile"),
'Accel': "P, F",
'ToolTip': QT_TRANSLATE_NOOP("Arch_Profile","Creates a profile")}
def IsActive(self):
return not FreeCAD.ActiveDocument is None
def Activated(self):
self.Profile = None
self.Categories = []
self.Presets = readPresets()
for pre in self.Presets:
if pre[1] not in self.Categories:
self.Categories.append(pre[1])
FreeCADGui.Snapper.getPoint(callback=self.getPoint,extradlg=[self.taskbox()],title=translate("Arch","Create profile"))
def taskbox(self):
"sets up a taskbox widget"
w = QtGui.QWidget()
ui = FreeCADGui.UiLoader()
w.setWindowTitle(translate("Arch","Profile settings"))
grid = QtGui.QGridLayout(w)
# categories box
labelc = QtGui.QLabel(translate("Arch","Category"))
self.vCategory = QtGui.QComboBox()
self.vCategory.addItems([" "] + self.Categories)
grid.addWidget(labelc,1,0,1,1)
grid.addWidget(self.vCategory,1,1,1,1)
# presets box
labelp = QtGui.QLabel(translate("Arch","Preset"))
self.vPresets = QtGui.QComboBox()
self.pSelect = [None]
fpresets = [" "]
self.vPresets.addItems(fpresets)
grid.addWidget(labelp,2,0,1,1)
grid.addWidget(self.vPresets,2,1,1,1)
# connect slots
self.vCategory.currentIndexChanged.connect(self.setCategory)
self.vPresets.currentIndexChanged.connect(self.setPreset)
# restore preset
stored = params.get_param_arch("StructurePreset")
if stored:
if ";" in stored:
stored = stored.split(";")
if len(stored) >= 3:
if stored[1] in self.Categories:
self.vCategory.setCurrentIndex(1+self.Categories.index(stored[1]))
self.setCategory(1+self.Categories.index(stored[1]))
ps = [p[2] for p in self.pSelect]
if stored[2] in ps:
self.vPresets.setCurrentIndex(ps.index(stored[2]))
return w
def getPoint(self,point=None,obj=None):
"this function is called by the snapper when it has a 3D point"
if not point:
return
if not self.Profile:
return
pt = "FreeCAD.Vector("+str(point.x)+","+str(point.y)+","+str(point.z)+")"
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Profile"))
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand('p = Arch.makeProfile('+str(self.Profile)+')')
FreeCADGui.doCommand('p.Placement.move('+pt+')')
FreeCADGui.addModule("Draft")
FreeCADGui.doCommand("Draft.autogroup(p)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
def setCategory(self,i):
self.vPresets.clear()
if i == 0:
self.pSelect = [None]
self.vPresets.addItems([" "])
params.set_param_arch("StructurePreset","")
else:
self.pSelect = [p for p in self.Presets if p[1] == self.Categories[i-1]]
fpresets = []
for p in self.pSelect:
f = FreeCAD.Units.Quantity(p[4],FreeCAD.Units.Length).getUserPreferred()
d = params.get_param("Decimals",path="Units")
s1 = str(round(p[4]/f[1],d))
s2 = str(round(p[5]/f[1],d))
s3 = str(f[2])
fpresets.append(p[2]+" ("+s1+"x"+s2+s3+")")
self.vPresets.addItems(fpresets)
self.setPreset(0)
def setPreset(self,i):
self.Profile = None
elt = self.pSelect[i]
if elt:
p=elt[0]-1 # Presets indexes are 1-based
self.Profile = self.Presets[p]
params.set_param_arch("StructurePreset",";".join([str(i) for i in self.Profile]))
class _Profile(Draft._DraftObject):
@@ -611,6 +467,3 @@ class ProfileTaskPanel:
self.form.setWindowTitle(self.type+" "+QtGui.QApplication.translate("Arch", "Profile", None))
if FreeCAD.GuiUp:
FreeCADGui.addCommand('Arch_Profile',Arch_Profile())

View File

@@ -48,89 +48,6 @@ __title__ = "FreeCAD Project"
__author__ = "Yorik van Havre"
__url__ = "https://www.freecad.org"
def makeProject(sites=None, name=None):
"""Create an Arch project.
If sites are provided, add them as children of the new project.
Parameters
----------
sites: list of <Part::FeaturePython>, optional
Sites to add as children of the project. Ultimately this could be
anything, however.
name: str, optional
The label for the project.
Returns
-------
<Part::FeaturePython>
The created project.
"""
if not FreeCAD.ActiveDocument:
return FreeCAD.Console.PrintError("No active document. Aborting\n")
import Part
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "Project")
obj.Label = name if name else translate("Arch", "Project")
_Project(obj)
if FreeCAD.GuiUp:
_ViewProviderProject(obj.ViewObject)
if sites:
obj.Group = sites
return obj
class _CommandProject:
"""The command definition for the Arch workbench's gui tool, Arch Project.
A tool for creating Arch projects.
Creates a project from the objects selected by the user that have the Site
IfcType, if any.
Find documentation on the end user usage of Arch Project here:
https://wiki.freecad.org/Arch_Project
"""
def GetResources(self):
"""Return a dictionary with the visual aspects of the Arch Project tool."""
return {'Pixmap' : 'Arch_Project',
'MenuText': QT_TRANSLATE_NOOP("Arch_Project", "Project"),
'Accel': "P, O",
'ToolTip': QT_TRANSLATE_NOOP("Arch_Project", "Creates a project entity aggregating the selected sites.")}
def IsActive(self):
"""Determine whether or not the Arch Project tool is active.
Inactive commands are indicated by a greyed-out icon in the menus and toolbars.
"""
return not FreeCAD.ActiveDocument is None
def Activated(self):
"""Executed when Arch Project is called.
Create a project from the objects selected by the user that have the
Site IfcType, if any.
"""
selection = FreeCADGui.Selection.getSelection()
siteobj = []
for obj in selection:
if hasattr(obj, "IfcType") and obj.IfcType == "Site":
siteobj.append(obj)
ss = "[ "
for o in siteobj:
ss += "FreeCAD.ActiveDocument." + o.Name + ", "
ss += "]"
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Project"))
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("obj = Arch.makeProject("+ss+")")
FreeCADGui.addModule("Draft")
FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
class _Project(ArchIFC.IfcContext):
"""The project object.
@@ -219,6 +136,3 @@ class _ViewProviderProject(ArchIFCView.IfcContextView):
def onChanged(self,vobj,prop):
self.removeDisplaymodeChildNodes(vobj)
if FreeCAD.GuiUp:
FreeCADGui.addCommand('Arch_Project', _CommandProject())

View File

@@ -39,6 +39,10 @@ else:
return txt
# \endcond
# for Rebar addon compatibility
from bimcommands import BimRebar
_CommandRebar = BimRebar.Arch_Rebar
## @package ArchRebar
# \ingroup ARCH
# \brief The Rebar object and tools
@@ -52,117 +56,6 @@ __author__ = "Yorik van Havre"
__url__ = "https://www.freecad.org"
def makeRebar(baseobj=None,sketch=None,diameter=None,amount=1,offset=None,name=None):
"""makeRebar([baseobj],[sketch],[diameter],[amount],[offset],[name]): adds a Reinforcement Bar object
to the given structural object, using the given sketch as profile."""
if not FreeCAD.ActiveDocument:
FreeCAD.Console.PrintError("No active document. Aborting\n")
return
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","Rebar")
obj.Label = name if name else translate("Arch","Rebar")
_Rebar(obj)
if FreeCAD.GuiUp:
_ViewProviderRebar(obj.ViewObject)
if baseobj and sketch:
if hasattr(sketch,"AttachmentSupport"):
if sketch.AttachmentSupport:
if isinstance(sketch.AttachmentSupport,tuple):
if sketch.AttachmentSupport[0] == baseobj:
sketch.AttachmentSupport = None
elif sketch.AttachmentSupport == baseobj:
sketch.AttachmentSupport = None
obj.Base = sketch
if FreeCAD.GuiUp:
sketch.ViewObject.hide()
obj.Host = baseobj
elif sketch and not baseobj:
# a rebar could be based on a wire without the existence of a Structure
obj.Base = sketch
if FreeCAD.GuiUp:
sketch.ViewObject.hide()
obj.Host = None
elif baseobj and not sketch:
obj.Shape = baseobj.Shape
if diameter:
obj.Diameter = diameter
else:
obj.Diameter = params.get_param_arch("RebarDiameter")
obj.Amount = amount
obj.Document.recompute()
if offset is not None:
obj.OffsetStart = offset
obj.OffsetEnd = offset
else:
obj.OffsetStart = params.get_param_arch("RebarOffset")
obj.OffsetEnd = params.get_param_arch("RebarOffset")
obj.Mark = obj.Label
return obj
class _CommandRebar:
"the Arch Rebar command definition"
def GetResources(self):
return {'Pixmap' : 'Arch_Rebar',
'MenuText': QT_TRANSLATE_NOOP("Arch_Rebar","Custom Rebar"),
'Accel': "R, B",
'ToolTip': QT_TRANSLATE_NOOP("Arch_Rebar","Creates a Reinforcement bar from the selected face of solid object and/or a sketch")}
def IsActive(self):
return not FreeCAD.ActiveDocument is None
def Activated(self):
sel = FreeCADGui.Selection.getSelectionEx()
if sel:
obj = sel[0].Object
if hasattr(obj,"Shape") and obj.Shape.Solids:
# this is our host object
if len(sel) > 1:
sk = sel[1].Object
if hasattr(sk,'Shape'):
if len(sk.Shape.Wires) == 1:
# we have a structure and a wire: create the rebar now
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Rebar"))
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("Arch.makeRebar(FreeCAD.ActiveDocument."+obj.Name+",FreeCAD.ActiveDocument."+sk.Name+")")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
return
else:
# we have only a structure: open the sketcher
FreeCADGui.activateWorkbench("SketcherWorkbench")
FreeCADGui.runCommand("Sketcher_NewSketch")
FreeCAD.ArchObserver = ArchComponent.ArchSelectionObserver(obj,FreeCAD.ActiveDocument.Objects[-1],hide=False,nextCommand="Arch_Rebar")
FreeCADGui.Selection.addObserver(FreeCAD.ArchObserver)
return
elif hasattr(obj,'Shape'):
if len(obj.Shape.Wires) == 1:
# we have only a wire: extract its support object, if available, and make the rebar
support = "None"
if hasattr(obj,"AttachmentSupport"):
if obj.AttachmentSupport:
if len(obj.AttachmentSupport) != 0:
support = "FreeCAD.ActiveDocument."+obj.AttachmentSupport[0][0].Name
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Rebar"))
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("Arch.makeRebar("+support+",FreeCAD.ActiveDocument."+obj.Name+")")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
return
FreeCAD.Console.PrintMessage(translate("Arch","Please select a base face on a structural object")+"\n")
FreeCADGui.Control.closeDialog()
FreeCADGui.Control.showDialog(ArchComponent.SelectionTaskPanel())
FreeCAD.ArchObserver = ArchComponent.ArchSelectionObserver(nextCommand="Arch_Rebar")
FreeCADGui.Selection.addObserver(FreeCAD.ArchObserver)
class _Rebar(ArchComponent.Component):
"A parametric reinforcement bar (rebar) object"
@@ -676,5 +569,3 @@ def getLengthOfRebar(rebar):
FreeCAD.Console.PrintError("Cannot calculate rebar length from its base object\n")
return None
if FreeCAD.GuiUp:
FreeCADGui.addCommand('Arch_Rebar',_CommandRebar())

View File

@@ -52,29 +52,6 @@ else:
# another file.
def makeReference(filepath=None, partname=None, name=None):
"""makeReference([filepath],[partname],[name]): Creates an Arch Reference object"""
if not FreeCAD.ActiveDocument:
FreeCAD.Console.PrintError("No active document. Aborting\n")
return
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","ArchReference")
obj.Label = name if name else translate("Arch","External Reference")
ArchReference(obj)
if FreeCAD.GuiUp:
ViewProviderArchReference(obj.ViewObject)
if filepath:
obj.File = filepath
if partname:
obj.Part = partname
import Draft
Draft.select(obj)
return obj
class ArchReference:
"""The Arch Reference object"""
@@ -197,8 +174,8 @@ class ArchReference:
if not ifcfile:
return
try:
import ifc_tools
import ifc_generator
from nativeifc import ifc_tools
from nativeifc import ifc_generator
except:
t = translate("Arch","NativeIFC not available - unable to process IFC files")
FreeCAD.Console.PrintError(t+"\n")
@@ -244,7 +221,7 @@ class ArchReference:
"""returns IFC elements for this object"""
try:
import ifc_generator
from nativeifc import ifc_generator
except:
t = translate("Arch","NativeIFC not available - unable to process IFC files")
FreeCAD.Console.PrintError(t+"\n")
@@ -852,8 +829,8 @@ class ViewProviderArchReference:
"""Sets the coin node of this object from an IFC file"""
try:
import ifc_tools
import ifc_generator
from nativeifc import ifc_tools
from nativeifc import ifc_generator
except:
t = translate("Arch","NativeIFC not available - unable to process IFC files")
FreeCAD.Console.PrintError(t+"\n")
@@ -957,7 +934,7 @@ class ArchReferenceTaskPanel:
filters = "*.FCStd *.dxf"
# enable IFC support if NativeIFC is present
try:
import ifc_tools
from nativeifc import ifc_tools
except:
pass
else:
@@ -995,34 +972,4 @@ class ArchReferenceTaskPanel:
FreeCADGui.ActiveDocument.resetEdit()
class ArchReferenceCommand:
"the Arch Reference command definition"
def GetResources(self):
return {'Pixmap' : 'Arch_Reference',
'MenuText': QT_TRANSLATE_NOOP("Arch_Reference","External reference"),
'Accel': "E, X",
'ToolTip': QT_TRANSLATE_NOOP("Arch_Reference","Creates an external reference object")}
def IsActive(self):
return not FreeCAD.ActiveDocument is None
def Activated(self):
FreeCADGui.Control.closeDialog()
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create external reference"))
FreeCADGui.addModule("Arch")
FreeCADGui.addModule("Draft")
FreeCADGui.doCommand("obj = Arch.makeReference()")
FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCADGui.doCommand("obj.ViewObject.Document.setEdit(obj.ViewObject, 0)")
if FreeCAD.GuiUp:
FreeCADGui.addCommand('Arch_Reference', ArchReferenceCommand())

View File

@@ -144,107 +144,6 @@ def face_from_points(ptLst):
return Part.Face(wire)
def makeRoof(baseobj=None,
facenr=0,
angles=[45.0], run=[250.0], idrel=[-1], thickness=[50.0], overhang=[100.0],
name=None):
'''makeRoof(baseobj, [facenr], [angle], [name]): Makes a roof based on
a closed wire or an object.
You can provide a list of angles, run, idrel, thickness, overhang for
each edge in the wire to define the roof shape. The default for angle is
45 and the list is automatically completed to match the number of edges
in the wire.
If the base object is a solid the roof uses its shape.
'''
if not FreeCAD.ActiveDocument:
FreeCAD.Console.PrintError("No active document. Aborting\n")
return
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "Roof")
obj.Label = name if name else translate("Arch", "Roof")
baseWire = None
_Roof(obj)
if FreeCAD.GuiUp:
_ViewProviderRoof(obj.ViewObject)
if baseobj:
obj.Base = baseobj
if hasattr(obj.Base, "Shape"):
if obj.Base.Shape.Solids:
if FreeCAD.GuiUp:
obj.Base.ViewObject.hide()
else:
if (obj.Base.Shape.Faces and obj.Face):
baseWire = obj.Base.Shape.Faces[obj.Face-1].Wires[0]
if FreeCAD.GuiUp:
obj.Base.ViewObject.hide()
elif obj.Base.Shape.Wires:
baseWire = obj.Base.Shape.Wires[0]
if FreeCAD.GuiUp:
obj.Base.ViewObject.hide()
if baseWire:
if baseWire.isClosed():
if FreeCAD.GuiUp:
obj.Base.ViewObject.hide()
edges = Part.__sortEdges__(baseWire.Edges)
ln = len(edges)
obj.Angles = adjust_list_len(angles, ln, angles[0])
obj.Runs = adjust_list_len(run, ln, run[0])
obj.IdRel = adjust_list_len(idrel, ln, idrel[0])
obj.Thickness = adjust_list_len(thickness, ln, thickness[0])
obj.Overhang = adjust_list_len(overhang, ln, overhang[0])
obj.Face = facenr
return obj
class _CommandRoof:
'''the Arch Roof command definition'''
def GetResources(self):
return {"Pixmap" : "Arch_Roof",
"MenuText": QT_TRANSLATE_NOOP("Arch_Roof", "Roof"),
"Accel" : "R, F",
"ToolTip" : QT_TRANSLATE_NOOP("Arch_Roof", "Creates a roof object from the selected wire.")}
def IsActive(self):
return not FreeCAD.ActiveDocument is None
def Activated(self):
sel = FreeCADGui.Selection.getSelectionEx()
if sel:
sel = sel[0]
obj = sel.Object
FreeCADGui.Control.closeDialog()
if sel.HasSubObjects:
if "Face" in sel.SubElementNames[0]:
i = int(sel.SubElementNames[0][4:])
FreeCAD.ActiveDocument.openTransaction(translate("Arch", "Create Roof"))
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("obj = Arch.makeRoof(FreeCAD.ActiveDocument." + obj.Name + "," + str(i) + ")")
FreeCADGui.addModule("Draft")
FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
return
if hasattr(obj, "Shape"):
if obj.Shape.Wires:
FreeCAD.ActiveDocument.openTransaction(translate("Arch", "Create Roof"))
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("obj = Arch.makeRoof(FreeCAD.ActiveDocument." + obj.Name + ")")
FreeCADGui.addModule("Draft")
FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
return
else:
FreeCAD.Console.PrintMessage(translate("Arch", "Unable to create a roof"))
else:
FreeCAD.Console.PrintMessage(translate("Arch", "Please select a base object") + "\n")
FreeCADGui.Control.showDialog(ArchComponent.SelectionTaskPanel())
FreeCAD.ArchObserver = ArchComponent.ArchSelectionObserver(nextCommand = "Arch_Roof")
FreeCADGui.Selection.addObserver(FreeCAD.ArchObserver)
class _Roof(ArchComponent.Component):
'''The Roof object'''
@@ -1053,6 +952,3 @@ class _RoofTaskPanel:
QtGui.QApplication.translate("Arch", "Overhang (mm)", None),
QtGui.QApplication.translate("Arch", "Height (mm)", None)])
if FreeCAD.GuiUp:
FreeCADGui.addCommand("Arch_Roof", _CommandRoof())

View File

@@ -53,28 +53,6 @@ verbose = True # change this for silent recomputes
class CommandArchSchedule:
"the Arch Schedule command definition"
def GetResources(self):
return {'Pixmap': 'Arch_Schedule',
'MenuText': QT_TRANSLATE_NOOP("Arch_Schedule","Schedule"),
'ToolTip': QT_TRANSLATE_NOOP("Arch_Schedule","Creates a schedule to collect data from the model")}
def Activated(self):
if hasattr(self,"taskd"):
if self.taskd:
self.taskd.form.hide()
self.taskd = ArchScheduleTaskPanel()
def IsActive(self):
if FreeCAD.ActiveDocument:
return True
else:
return False
class _ArchScheduleDocObserver:
"doc observer to monitor all recomputes"
@@ -769,5 +747,3 @@ class ArchScheduleTaskPanel:
FreeCAD.ActiveDocument.recompute()
if FreeCAD.GuiUp:
FreeCADGui.addCommand('Arch_Schedule',CommandArchSchedule())

View File

@@ -57,34 +57,6 @@ else:
ISRENDERING = False # flag to prevent concurrent runs of the coin renderer
def makeSectionPlane(objectslist=None,name=None):
"""makeSectionPlane([objectslist],[name]) : Creates a Section plane objects including the
given objects. If no object is given, the whole document will be considered."""
if not FreeCAD.ActiveDocument:
FreeCAD.Console.PrintError("No active document. Aborting\n")
return
obj = FreeCAD.ActiveDocument.addObject("App::FeaturePython","Section")
obj.Label = name if name else translate("Arch","Section")
_SectionPlane(obj)
if FreeCAD.GuiUp:
_ViewProviderSectionPlane(obj.ViewObject)
if objectslist:
obj.Objects = objectslist
bb = FreeCAD.BoundBox()
for o in Draft.get_group_contents(objectslist):
if hasattr(o,"Shape") and hasattr(o.Shape,"BoundBox"):
bb.add(o.Shape.BoundBox)
import WorkingPlane
obj.Placement = WorkingPlane.get_working_plane().get_placement()
obj.Placement.Base = bb.Center
if FreeCAD.GuiUp:
margin = bb.XLength*0.1
obj.ViewObject.DisplayLength = bb.XLength+margin
obj.ViewObject.DisplayHeight = bb.YLength+margin
return obj
def getSectionData(source):
@@ -825,38 +797,6 @@ def closeViewer(name):
sw.close()
class _CommandSectionPlane:
"the Arch SectionPlane command definition"
def GetResources(self):
return {'Pixmap' : 'Arch_SectionPlane',
'Accel': "S, E",
'MenuText': QT_TRANSLATE_NOOP("Arch_SectionPlane","Section Plane"),
'ToolTip': QT_TRANSLATE_NOOP("Arch_SectionPlane","Creates a section plane object, including the selected objects")}
def IsActive(self):
return not FreeCAD.ActiveDocument is None
def Activated(self):
sel = FreeCADGui.Selection.getSelection()
ss = "["
for o in sel:
if len(ss) > 1:
ss += ","
ss += "FreeCAD.ActiveDocument."+o.Name
ss += "]"
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Section Plane"))
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("section = Arch.makeSectionPlane("+ss+")")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
class _SectionPlane:
"A section plane object"
@@ -1398,5 +1338,3 @@ class SectionPlaneTaskPanel:
self.recenterButton.setText(QtGui.QApplication.translate("Arch", "Center", None))
self.recenterButton.setToolTip(QtGui.QApplication.translate("Arch", "Centers the plane on the objects in the list above", None))
if FreeCAD.GuiUp:
FreeCADGui.addCommand('Arch_SectionPlane',_CommandSectionPlane())

View File

@@ -61,31 +61,6 @@ __author__ = "Yorik van Havre"
__url__ = "https://www.freecad.org"
def makeSite(objectslist=None,baseobj=None,name=None):
'''makeBuilding([objectslist],[baseobj],[name]): creates a site including the
objects from the given list.'''
if not FreeCAD.ActiveDocument:
FreeCAD.Console.PrintError("No active document. Aborting\n")
return
import Part
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","Site")
obj.Label = name if name else translate("Arch","Site")
_Site(obj)
if FreeCAD.GuiUp:
_ViewProviderSite(obj.ViewObject)
if objectslist:
obj.Group = objectslist
if baseobj:
import Part
if isinstance(baseobj,Part.Shape):
obj.Shape = baseobj
else:
obj.Terrain = baseobj
return obj
def toNode(shape):
"""builds a linear pivy node from a shape"""
@@ -503,57 +478,6 @@ class Compass(object):
return coords
class _CommandSite:
"the Arch Site command definition"
def GetResources(self):
return {'Pixmap' : 'Arch_Site',
'MenuText': QT_TRANSLATE_NOOP("Arch_Site","Site"),
'Accel': "S, I",
'ToolTip': QT_TRANSLATE_NOOP("Arch_Site","Creates a site including selected objects.")}
def IsActive(self):
return not FreeCAD.ActiveDocument is None
def Activated(self):
sel = FreeCADGui.Selection.getSelection()
link = params.get_param_arch("FreeLinking")
siteobj = []
warning = False
for obj in sel:
if (Draft.getType(obj) == "Building") or (hasattr(obj,"IfcType") and obj.IfcType == "Building"):
siteobj.append(obj)
else:
if link:
siteobj.append(obj)
else:
warning = True
if warning:
message = translate( "Arch" , "Please either select only Building objects or nothing at all!\n\
Site is not allowed to accept any other object besides Building.\n\
Other objects will be removed from the selection.\n\
Note: You can change that in the preferences.")
ArchCommands.printMessage( message )
if sel and len(siteobj) == 0:
message = translate( "Arch" , "There is no valid object in the selection.\n\
Site creation aborted.") + "\n"
ArchCommands.printMessage( message )
else:
ss = "[ "
for o in siteobj:
ss += "FreeCAD.ActiveDocument." + o.Name + ", "
ss += "]"
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Site"))
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("obj = Arch.makeSite("+ss+")")
FreeCADGui.addModule("Draft")
FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
@@ -1242,6 +1166,3 @@ class _ViewProviderSite:
return None
if FreeCAD.GuiUp:
FreeCADGui.addCommand('Arch_Site',_CommandSite())

View File

@@ -172,33 +172,7 @@ else:
# Spaces define an open volume inside or outside a
# building, ie. a room.
def makeSpace(objects=None,baseobj=None,name=None):
"""makeSpace([objects],[baseobj],[name]): Creates a space object from the given objects.
Objects can be one document object, in which case it becomes the base shape of the space
object, or a list of selection objects as got from getSelectionEx(), or a list of tuples
(object, subobjectname)"""
if not FreeCAD.ActiveDocument:
FreeCAD.Console.PrintError("No active document. Aborting\n")
return
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","Space")
obj.Label = name if name else translate("Arch","Space")
_Space(obj)
if FreeCAD.GuiUp:
_ViewProviderSpace(obj.ViewObject)
if baseobj:
objects = baseobj
if objects:
if not isinstance(objects,list):
objects = [objects]
if len(objects) == 1:
obj.Base = objects[0]
if FreeCAD.GuiUp:
objects[0].ViewObject.hide()
else:
obj.Proxy.addSubobjects(obj,objects)
return obj
def addSpaceBoundaries(space,subobjects):
@@ -222,42 +196,6 @@ def removeSpaceBoundaries(space,objects):
break
space.Boundaries = bounds
class _CommandSpace:
"the Arch Space command definition"
def GetResources(self):
return {'Pixmap' : 'Arch_Space',
'MenuText': QT_TRANSLATE_NOOP("Arch_Space","Space"),
'Accel': "S, P",
'ToolTip': QT_TRANSLATE_NOOP("Arch_Space","Creates a space object from selected boundary objects")}
def IsActive(self):
return not FreeCAD.ActiveDocument is None
def Activated(self):
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Space"))
FreeCADGui.addModule("Arch")
sel = FreeCADGui.Selection.getSelection()
if sel:
FreeCADGui.Control.closeDialog()
if len(sel) == 1:
FreeCADGui.doCommand("obj = Arch.makeSpace(FreeCADGui.Selection.getSelection())")
else:
FreeCADGui.doCommand("obj = Arch.makeSpace(FreeCADGui.Selection.getSelectionEx())")
FreeCADGui.addModule("Draft")
FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
else:
FreeCAD.Console.PrintMessage(translate("Arch","Please select a base object")+"\n")
FreeCADGui.Control.showDialog(ArchComponent.SelectionTaskPanel())
FreeCAD.ArchObserver = ArchComponent.ArchSelectionObserver(nextCommand="Arch_Space")
FreeCADGui.Selection.addObserver(FreeCAD.ArchObserver)
class _Space(ArchComponent.Component):
@@ -727,7 +665,7 @@ class _ViewProviderSpace(ArchComponent.ViewProviderComponent):
elif prop == "ShapeColor":
if hasattr(vobj,"ShapeColor"):
self.fmat.diffuseColor.setValue((vobj.ShapeColor[0],vobj.ShapeColor[1],vobj.ShapeColor[2]))
self.fmat = vobj.ShapeColor.getValue()
elif prop == "Transparency":
if hasattr(vobj,"Transparency"):
@@ -839,7 +777,3 @@ class SpaceTaskPanel(ArchComponent.ComponentTaskPanel):
break
self.obj.Boundaries = bounds
self.updateBoundaries()
if FreeCAD.GuiUp:
FreeCADGui.addCommand('Arch_Space',_CommandSpace())

View File

@@ -51,197 +51,6 @@ else:
zeroMM = FreeCAD.Units.Quantity('0mm')
def makeStairs(baseobj=None,length=None,width=None,height=None,steps=None,name=None):
"""makeStairs([baseobj],[length],[width],[height],[steps],[name]): creates a Stairs
objects with given attributes."""
if not FreeCAD.ActiveDocument:
FreeCAD.Console.PrintError("No active document. Aborting\n")
return
stairs = []
additions = []
label = name if name else translate("Arch","Stairs")
def setProperty(obj,length,width,height,steps):
if length:
obj.Length = length
else:
obj.Length = params.get_param_arch("StairsLength")
if width:
obj.Width = width
else:
obj.Width = params.get_param_arch("StairsWidth")
if height:
obj.Height = height
else:
obj.Height = params.get_param_arch("StairsHeight")
if steps:
obj.NumberOfSteps = steps
obj.Structure = "Massive"
obj.StructureThickness = 150
obj.DownSlabThickness = 150
obj.UpSlabThickness = 150
obj.RailingOffsetLeft = 60
obj.RailingOffsetRight = 60
obj.RailingHeightLeft = 900
obj.RailingHeightRight = 900
if baseobj:
if not isinstance(baseobj,list):
baseobj = [baseobj]
lenSelection = len(baseobj)
if lenSelection > 1:
stair = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","Stairs")
stair.Label = label
_Stairs(stair)
stairs.append(stair)
stairs[0].Label = label
i = 1
else:
i = 0
for baseobjI in baseobj:
stair = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","Stairs")
stair.Label = label
_Stairs(stair)
stairs.append(stair)
stairs[i].Label = label
stairs[i].Base = baseobjI
if len(baseobjI.Shape.Edges) > 1:
stepsI = 1 #'landing' if 'multi-edges' currently
elif steps:
stepsI = steps
else:
stepsI = 20
setProperty(stairs[i],None,width,height,stepsI)
if i > 1:
additions.append(stairs[i])
stairs[i].LastSegment = stairs[i-1]
else:
if len(stairs) > 1: # i.e. length >1, have a 'master' staircase created
stairs[0].Base = stairs[1]
i += 1
if lenSelection > 1:
stairs[0].Additions = additions
else:
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","Stairs")
obj.Label = label
_Stairs(obj)
setProperty(obj,length,width,height,steps)
stairs.append(obj)
if FreeCAD.GuiUp:
if baseobj:
for stair in stairs:
_ViewProviderStairs(stair.ViewObject)
else:
_ViewProviderStairs(obj.ViewObject)
if stairs:
for stair in stairs:
stair.recompute()
makeRailing(stairs)
# return stairs - all other functions expect one object as return value
return stairs[0]
else:
obj.recompute()
return obj
def makeRailing(stairs):
"simple make Railing function testing"
def makeRailingLorR(stairs,side="L"):
for stair in reversed(stairs):
if side == "L":
outlineLR = stair.OutlineLeft
outlineLRAll = stair.OutlineLeftAll
stairRailingLR = "RailingLeft"
elif side == "R":
outlineLR = stair.OutlineRight
outlineLRAll = stair.OutlineRightAll
stairRailingLR = "RailingRight"
if outlineLR or outlineLRAll:
lrRail = ArchPipe.makePipe(baseobj=None,diameter=0,length=0,placement=None,name=translate("Arch","Railing"))
if outlineLRAll:
setattr(stair, stairRailingLR, lrRail)
break
elif outlineLR:
setattr(stair, stairRailingLR, lrRail)
if stairs is None:
sel = FreeCADGui.Selection.getSelection()
sel0 = sel[0]
stairs = []
# TODO currently consider 1st selected object, then would tackle multiple objects?
if Draft.getType(sel[0]) == "Stairs":
stairs.append(sel0)
if Draft.getType(sel0.Base) == "Stairs":
stairs.append(sel0.Base)
additions = sel0.Additions
for additionsI in additions:
if Draft.getType(additionsI) == "Stairs":
stairs.append(additionsI)
else:
stairs.append(sel[0])
else:
print("No Stairs object selected")
return
makeRailingLorR(stairs,"L")
makeRailingLorR(stairs,"R")
class _CommandStairs:
"the Arch Stairs command definition"
def GetResources(self):
return {'Pixmap' : 'Arch_Stairs',
'MenuText': QT_TRANSLATE_NOOP("Arch_Stairs","Stairs"),
'Accel': "S, R",
'ToolTip': QT_TRANSLATE_NOOP("Arch_Stairs","Creates a flight of stairs")}
def IsActive(self):
return not FreeCAD.ActiveDocument is None
def Activated(self):
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Stairs"))
FreeCADGui.addModule("Arch")
# a list of 'segment' / 'flight' of stairs
stairs = []
additions = []
if len(FreeCADGui.Selection.getSelection()) > 0:
n = []
nStr = ""
for obj in FreeCADGui.Selection.getSelection():
n.append(obj.Name) # would no longer use
if nStr != "":
nStr = nStr + ","
nStr = nStr + "FreeCAD.ActiveDocument." + obj.Name
FreeCADGui.doCommand("obj = Arch.makeStairs(baseobj=["+nStr+"])")
else:
FreeCADGui.doCommand("obj = Arch.makeStairs(steps="+str(params.get_param_arch("StairsSteps"))+")")
FreeCADGui.addModule("Draft")
for obj in stairs:
Draft.autogroup(obj) # seems not working?
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
class _Stairs(ArchComponent.Component):
@@ -1521,5 +1330,3 @@ class _ViewProviderStairs(ArchComponent.ViewProviderComponent):
return []
if FreeCAD.GuiUp:
FreeCADGui.addCommand('Arch_Stairs',_CommandStairs())

View File

@@ -51,86 +51,6 @@ rodmodes = ("/|/|/|",
"/|\\|/|\\",
)
def makeTruss(baseobj=None,name=None):
"""
makeTruss([baseobj],[name]): Creates a space object from the given object (a line)
"""
if not FreeCAD.ActiveDocument:
FreeCAD.Console.PrintError("No active document. Aborting\n")
return
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","Truss")
obj.Label = name if name else translate("Arch","Truss")
Truss(obj)
if FreeCAD.GuiUp:
ViewProviderTruss(obj.ViewObject)
if baseobj:
obj.Base = baseobj
if FreeCAD.GuiUp:
baseobj.ViewObject.hide()
return obj
class CommandArchTruss:
"the Arch Truss command definition"
def GetResources(self):
return {'Pixmap' : 'Arch_Truss',
'MenuText': QT_TRANSLATE_NOOP("Arch_Truss","Truss"),
'Accel': "T, U",
'ToolTip': QT_TRANSLATE_NOOP("Arch_Truss","Creates a truss object from selected line or from scratch")}
def IsActive(self):
return not FreeCAD.ActiveDocument is None
def Activated(self):
sel = FreeCADGui.Selection.getSelection()
if len(sel) > 1:
FreeCAD.Console.PrintError(translate("Arch","Please select only one base object or none")+"\n")
elif len(sel) == 1:
# build on selection
FreeCADGui.Control.closeDialog()
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Truss"))
FreeCADGui.addModule("Draft")
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("obj = Arch.makeTruss(FreeCAD.ActiveDocument."+FreeCADGui.Selection.getSelection()[0].Name+")")
FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
else:
# interactive line drawing
self.points = []
import WorkingPlane
WorkingPlane.get_working_plane()
if hasattr(FreeCADGui,"Snapper"):
FreeCADGui.Snapper.getPoint(callback=self.getPoint)
def getPoint(self,point=None,obj=None):
"""Callback for clicks during interactive mode"""
if point is None:
# cancelled
return
self.points.append(point)
if len(self.points) == 1:
FreeCADGui.Snapper.getPoint(last=self.points[0],callback=self.getPoint)
elif len(self.points) == 2:
FreeCADGui.Control.closeDialog()
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Truss"))
FreeCADGui.addModule("Draft")
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("base = Draft.makeLine(FreeCAD."+str(self.points[0])+",FreeCAD."+str(self.points[1])+")")
FreeCADGui.doCommand("obj = Arch.makeTruss(base)")
FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
class Truss(ArchComponent.Component):
@@ -407,6 +327,3 @@ class ViewProviderTruss(ArchComponent.ViewProviderComponent):
import Arch_rc
return ":/icons/Arch_Truss_Tree.svg"
if FreeCAD.GuiUp:
FreeCADGui.addCommand('Arch_Truss',CommandArchTruss())

View File

@@ -59,151 +59,7 @@ __title__ = "FreeCAD Wall"
__author__ = "Yorik van Havre"
__url__ = "https://www.freecad.org"
def makeWall(baseobj=None,height=None,length=None,width=None,align=None,face=None,name=None):
"""Create a wall based on a given object, and returns the generated wall.
TODO: It is unclear what defines which units this function uses.
Parameters
----------
baseobj: <Part::PartFeature>, optional
The base object with which to build the wall. This can be a sketch, a
draft object, a face, or a solid. It can also be left as None.
height: float, optional
The height of the wall.
length: float, optional
The length of the wall. Not used if the wall is based off an object.
Will use Arch default if left empty.
width: float, optional
The width of the wall. Not used if the base object is a face. Will use
Arch default if left empty.
align: str, optional
Either "Center", "Left", or "Right". Effects the alignment of the wall
on its baseline.
face: int, optional
The index number of a face on the given baseobj, to base the wall on.
name: str, optional
The name to give to the created wall.
Returns
-------
<Part::FeaturePython>
Returns the generated wall.
Notes
-----
Creates a new <Part::FeaturePython> object, and turns it into a parametric wall
object. This <Part::FeaturePython> object does not yet have any shape.
The wall then uses the baseobj.Shape as the basis to extrude out a wall shape,
giving the new <Part::FeaturePython> object a shape.
It then hides the original baseobj.
"""
if not FreeCAD.ActiveDocument:
FreeCAD.Console.PrintError("No active document. Aborting\n")
return
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","Wall")
if name:
obj.Label = name
else:
obj.Label = translate("Arch","Wall")
_Wall(obj)
if FreeCAD.GuiUp:
_ViewProviderWall(obj.ViewObject)
if baseobj:
if hasattr(baseobj,'Shape') or baseobj.isDerivedFrom("Mesh::Feature"):
obj.Base = baseobj
else:
FreeCAD.Console.PrintWarning(str(translate("Arch","Walls can only be based on Part or Mesh objects")))
if face:
obj.Face = face
if length:
obj.Length = length
if width:
obj.Width = width
else:
obj.Width = params.get_param_arch("WallWidth")
if height:
obj.Height = height
else:
obj.Height = params.get_param_arch("WallHeight")
if align:
obj.Align = align
else:
obj.Align = ["Center","Left","Right"][params.get_param_arch("WallAlignment")]
if obj.Base and FreeCAD.GuiUp:
if Draft.getType(obj.Base) != "Space":
obj.Base.ViewObject.hide()
return obj
def joinWalls(walls,delete=False):
"""Join the given list of walls into one sketch-based wall.
Take the first wall in the list, and adds on the other walls in the list.
Return the modified first wall.
Setting delete to True, will delete the other walls. Only join walls
if the walls have the same width, height and alignment.
Parameters
----------
walls: list of <Part::FeaturePython>
List containing the walls to add to the first wall in the list. Walls must
be based off a base object.
delete: bool, optional
If True, deletes the other walls in the list.
Returns
-------
<Part::FeaturePython>
"""
import Part
if not walls:
return None
if not isinstance(walls,list):
walls = [walls]
if not areSameWallTypes(walls):
return None
deleteList = []
base = walls.pop()
if base.Base:
if base.Base.Shape.Faces:
return None
# Use ArchSketch if SketchArch add-on is present
if Draft.getType(base.Base) == "ArchSketch":
sk = base.Base
else:
try:
import ArchSketchObject
newSk=ArchSketchObject.makeArchSketch()
except:
if Draft.getType(base.Base) != "Sketcher::SketchObject":
newSk=FreeCAD.ActiveDocument.addObject("Sketcher::SketchObject","WallTrace")
else:
newSk=None
if newSk:
sk = Draft.makeSketch(base.Base,autoconstraints=True, addTo=newSk)
base.Base = sk
else:
sk = base.Base
for w in walls:
if w.Base:
if not w.Base.Shape.Faces:
for e in w.Base.Shape.Edges:
l = e.Curve
if isinstance(l,Part.Line):
l = Part.LineSegment(e.Vertexes[0].Point,e.Vertexes[-1].Point)
sk.addGeometry(l)
deleteList.append(w.Name)
if delete:
for n in deleteList:
FreeCAD.ActiveDocument.removeObject(n)
FreeCAD.ActiveDocument.recompute()
base.ViewObject.show()
return base
def mergeShapes(w1,w2):
"""Not currently implemented.
@@ -265,447 +121,6 @@ def areSameWallTypes(walls):
return True
class _CommandWall:
"""The command definition for the Arch workbench's gui tool, Arch Wall.
A tool for creating Arch walls.
Create a wall from the object selected by the user. If no objects are
selected, enter an interactive mode to create a wall using selected points
to create a base.
Find documentation on the end user usage of Arch Wall here:
https://wiki.freecad.org/Arch_Wall
"""
def GetResources(self):
"""Returns a dictionary with the visual aspects of the Arch Wall tool."""
return {'Pixmap' : 'Arch_Wall',
'MenuText': QT_TRANSLATE_NOOP("Arch_Wall","Wall"),
'Accel': "W, A",
'ToolTip': QT_TRANSLATE_NOOP("Arch_Wall","Creates a wall object from scratch or from a selected object (wire, face or solid)")}
def IsActive(self):
"""Determines whether or not the Arch Wall tool is active.
Inactive commands are indicated by a greyed-out icon in the menus and
toolbars.
"""
return not FreeCAD.ActiveDocument is None
def Activated(self):
"""Executed when Arch Wall is called.
Creates a wall from the object selected by the user. If no objects are
selected, enters an interactive mode to create a wall using selected
points to create a base.
"""
self.Align = ["Center","Left","Right"][params.get_param_arch("WallAlignment")]
self.MultiMat = None
self.Length = None
self.lengthValue = 0
self.continueCmd = False
self.Width = params.get_param_arch("WallWidth")
self.Height = params.get_param_arch("WallHeight")
self.JOIN_WALLS_SKETCHES = params.get_param_arch("joinWallSketches")
self.AUTOJOIN = params.get_param_arch("autoJoinWalls")
sel = FreeCADGui.Selection.getSelectionEx()
done = False
self.existing = []
self.wp = None
if sel:
# automatic mode
import Draft
if Draft.getType(sel[0].Object) != "Wall":
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Wall"))
FreeCADGui.addModule("Arch")
for selobj in sel:
if Draft.getType(selobj.Object) == "Space":
spacedone = False
if selobj.HasSubObjects:
if "Face" in selobj.SubElementNames[0]:
idx = int(selobj.SubElementNames[0][4:])
FreeCADGui.doCommand("obj = Arch.makeWall(FreeCAD.ActiveDocument."+selobj.Object.Name+",face="+str(idx)+")")
spacedone = True
if not spacedone:
FreeCADGui.doCommand('obj = Arch.makeWall(FreeCAD.ActiveDocument.'+selobj.Object.Name+')')
else:
FreeCADGui.doCommand('obj = Arch.makeWall(FreeCAD.ActiveDocument.'+selobj.Object.Name+')')
FreeCADGui.addModule("Draft")
FreeCADGui.doCommand("Draft.autogroup(obj)")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
done = True
if not done:
# interactive mode
self.points = []
import WorkingPlane
self.wp = WorkingPlane.get_working_plane()
self.tracker = DraftTrackers.boxTracker()
FreeCAD.activeDraftCommand = self # register as a Draft command for auto grid on/off
FreeCADGui.Snapper.getPoint(callback=self.getPoint,
extradlg=self.taskbox(),
title=translate("Arch","First point of wall")+":")
def getPoint(self,point=None,obj=None):
"""Callback for clicks during interactive mode.
When method _CommandWall.Activated() has entered the interactive mode,
this callback runs when the user clicks.
Parameters
----------
point: <class 'Base.Vector'>
The point the user has selected.
obj: <Part::PartFeature>, optional
The object the user's cursor snapped to, if any.
"""
if obj:
if Draft.getType(obj) == "Wall":
if not obj in self.existing:
self.existing.append(obj)
if point is None:
self.tracker.finalize()
FreeCAD.activeDraftCommand = None
FreeCADGui.Snapper.off()
return
self.points.append(point)
if len(self.points) == 1:
self.tracker.width(self.Width)
self.tracker.height(self.Height)
self.tracker.on()
FreeCADGui.Snapper.getPoint(last=self.points[0],
callback=self.getPoint,
movecallback=self.update,
extradlg=self.taskbox(),
title=translate("Arch","Next point")+":",mode="line")
elif len(self.points) == 2:
import Part
l = Part.LineSegment(self.wp.get_local_coords(self.points[0]),
self.wp.get_local_coords(self.points[1]))
self.tracker.finalize()
FreeCAD.activeDraftCommand = None
FreeCADGui.Snapper.off()
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Wall"))
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand('import Part')
FreeCADGui.doCommand('trace=Part.LineSegment(FreeCAD.'+str(l.StartPoint)+',FreeCAD.'+str(l.EndPoint)+')')
if not self.existing:
# no existing wall snapped, just add a default wall
self.addDefault()
else:
if self.JOIN_WALLS_SKETCHES:
# join existing subwalls first if possible, then add the new one
w = joinWalls(self.existing)
if w:
if areSameWallTypes([w,self]):
FreeCADGui.doCommand('FreeCAD.ActiveDocument.'+w.Name+'.Base.addGeometry(trace)')
else:
# if not possible, add new wall as addition to the existing one
self.addDefault()
if self.AUTOJOIN:
FreeCADGui.doCommand('Arch.addComponents(FreeCAD.ActiveDocument.'+FreeCAD.ActiveDocument.Objects[-1].Name+',FreeCAD.ActiveDocument.'+w.Name+')')
else:
self.addDefault()
else:
# add new wall as addition to the first existing one
self.addDefault()
if self.AUTOJOIN:
FreeCADGui.doCommand('Arch.addComponents(FreeCAD.ActiveDocument.'+FreeCAD.ActiveDocument.Objects[-1].Name+',FreeCAD.ActiveDocument.'+self.existing[0].Name+')')
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
if self.continueCmd:
self.Activated()
def addDefault(self):
"""Create a wall using a line segment, with all parameters as the default.
Used solely by _CommandWall.getPoint() when the interactive mode has
selected two points.
Relies on the assumption that FreeCADGui.doCommand() has already
created a Part.LineSegment assigned as the variable "trace"
"""
FreeCADGui.addModule("Draft")
FreeCADGui.addModule("WorkingPlane")
FreeCADGui.doCommand("wp = WorkingPlane.get_working_plane()")
if params.get_param_arch("WallSketches"):
# Use ArchSketch if SketchArch add-on is present
try:
import ArchSketchObject
FreeCADGui.doCommand('import ArchSketchObject')
FreeCADGui.doCommand('base=ArchSketchObject.makeArchSketch()')
except:
FreeCADGui.doCommand('base=FreeCAD.ActiveDocument.addObject("Sketcher::SketchObject","WallTrace")')
FreeCADGui.doCommand('base.Placement = wp.get_placement()')
FreeCADGui.doCommand('base.addGeometry(trace)')
else:
FreeCADGui.doCommand('base=Draft.make_line(trace)')
# The created line should not stay selected as this causes an issue in continue mode.
# Two walls would then be created based on the same line.
FreeCADGui.Selection.clearSelection()
FreeCADGui.doCommand('base.Placement = wp.get_placement()')
FreeCADGui.doCommand('FreeCAD.ActiveDocument.recompute()')
FreeCADGui.doCommand('wall = Arch.makeWall(base,width='+str(self.Width)+',height='+str(self.Height)+',align="'+str(self.Align)+'")')
FreeCADGui.doCommand('wall.Normal = wp.axis')
if self.MultiMat:
FreeCADGui.doCommand("wall.Material = FreeCAD.ActiveDocument."+self.MultiMat.Name)
FreeCADGui.doCommand("Draft.autogroup(wall)")
def update(self,point,info):
# info parameter is not used but needed for compatibility with the snapper
"""Callback for the mouse moving during the interactive mode.
Update the active dialog box to show the coordinates of the location of
the cursor. Also show the length the line would take, if the user
selected that point.
Parameters
----------
point: <class 'Base.Vector'>
The point the cursor is currently at, or has snapped to.
"""
if FreeCADGui.Control.activeDialog():
b = self.points[0]
n = self.wp.axis
bv = point.sub(b)
dv = bv.cross(n)
dv = DraftVecUtils.scaleTo(dv,self.Width/2)
if self.Align == "Center":
self.tracker.update([b,point])
elif self.Align == "Left":
self.tracker.update([b.add(dv),point.add(dv)])
else:
dv = dv.negative()
self.tracker.update([b.add(dv),point.add(dv)])
if self.Length:
self.Length.setText(FreeCAD.Units.Quantity(bv.Length,FreeCAD.Units.Length).UserString)
def taskbox(self):
"""Set up a simple gui widget for the interactive mode."""
w = QtGui.QWidget()
ui = FreeCADGui.UiLoader()
w.setWindowTitle(translate("Arch","Wall options"))
grid = QtGui.QGridLayout(w)
matCombo = QtGui.QComboBox()
matCombo.addItem(translate("Arch","Wall Presets..."))
matCombo.setToolTip(translate("Arch","This list shows all the MultiMaterials objects of this document. Create some to define wall types."))
self.multimats = []
self.MultiMat = None
for o in FreeCAD.ActiveDocument.Objects:
if Draft.getType(o) == "MultiMaterial":
self.multimats.append(o)
matCombo.addItem(o.Label)
if hasattr(FreeCAD,"LastArchMultiMaterial"):
for i,o in enumerate(self.multimats):
if o.Name == FreeCAD.LastArchMultiMaterial:
matCombo.setCurrentIndex(i+1)
self.MultiMat = o
grid.addWidget(matCombo,0,0,1,2)
label5 = QtGui.QLabel(translate("Arch","Length"))
self.Length = ui.createWidget("Gui::InputField")
self.Length.setText("0.00 mm")
grid.addWidget(label5,1,0,1,1)
grid.addWidget(self.Length,1,1,1,1)
label1 = QtGui.QLabel(translate("Arch","Width"))
value1 = ui.createWidget("Gui::InputField")
value1.setText(FreeCAD.Units.Quantity(self.Width,FreeCAD.Units.Length).UserString)
grid.addWidget(label1,2,0,1,1)
grid.addWidget(value1,2,1,1,1)
label2 = QtGui.QLabel(translate("Arch","Height"))
value2 = ui.createWidget("Gui::InputField")
value2.setText(FreeCAD.Units.Quantity(self.Height,FreeCAD.Units.Length).UserString)
grid.addWidget(label2,3,0,1,1)
grid.addWidget(value2,3,1,1,1)
label3 = QtGui.QLabel(translate("Arch","Alignment"))
value3 = QtGui.QComboBox()
items = [translate("Arch","Center"),translate("Arch","Left"),translate("Arch","Right")]
value3.addItems(items)
value3.setCurrentIndex(["Center","Left","Right"].index(self.Align))
grid.addWidget(label3,4,0,1,1)
grid.addWidget(value3,4,1,1,1)
label4 = QtGui.QLabel(translate("Arch","Con&tinue"))
value4 = QtGui.QCheckBox()
value4.setObjectName("ContinueCmd")
value4.setLayoutDirection(QtCore.Qt.RightToLeft)
label4.setBuddy(value4)
self.continueCmd = params.get_param("ContinueMode")
value4.setChecked(self.continueCmd)
grid.addWidget(label4,5,0,1,1)
grid.addWidget(value4,5,1,1,1)
label5 = QtGui.QLabel(translate("Arch","Use sketches"))
value5 = QtGui.QCheckBox()
value5.setObjectName("UseSketches")
value5.setLayoutDirection(QtCore.Qt.RightToLeft)
label5.setBuddy(value5)
value5.setChecked(params.get_param_arch("WallSketches"))
grid.addWidget(label5,6,0,1,1)
grid.addWidget(value5,6,1,1,1)
QtCore.QObject.connect(self.Length,QtCore.SIGNAL("valueChanged(double)"),self.setLength)
QtCore.QObject.connect(value1,QtCore.SIGNAL("valueChanged(double)"),self.setWidth)
QtCore.QObject.connect(value2,QtCore.SIGNAL("valueChanged(double)"),self.setHeight)
QtCore.QObject.connect(value3,QtCore.SIGNAL("currentIndexChanged(int)"),self.setAlign)
QtCore.QObject.connect(value4,QtCore.SIGNAL("stateChanged(int)"),self.setContinue)
QtCore.QObject.connect(value5,QtCore.SIGNAL("stateChanged(int)"),self.setUseSketch)
QtCore.QObject.connect(self.Length,QtCore.SIGNAL("returnPressed()"),value1.setFocus)
QtCore.QObject.connect(self.Length,QtCore.SIGNAL("returnPressed()"),value1.selectAll)
QtCore.QObject.connect(value1,QtCore.SIGNAL("returnPressed()"),value2.setFocus)
QtCore.QObject.connect(value1,QtCore.SIGNAL("returnPressed()"),value2.selectAll)
QtCore.QObject.connect(value2,QtCore.SIGNAL("returnPressed()"),self.createFromGUI)
QtCore.QObject.connect(matCombo,QtCore.SIGNAL("currentIndexChanged(int)"),self.setMat)
return w
def setMat(self,d):
"""Simple callback for the interactive mode gui widget to set material."""
if d == 0:
self.MultiMat = None
del FreeCAD.LastArchMultiMaterial
elif d <= len(self.multimats):
self.MultiMat = self.multimats[d-1]
FreeCAD.LastArchMultiMaterial = self.MultiMat.Name
def setLength(self,d):
"""Simple callback for the interactive mode gui widget to set length."""
self.lengthValue = d
def setWidth(self,d):
"""Simple callback for the interactive mode gui widget to set width."""
self.Width = d
self.tracker.width(d)
params.set_param_arch("WallWidth",d)
def setHeight(self,d):
"""Simple callback for the interactive mode gui widget to set height."""
self.Height = d
self.tracker.height(d)
params.set_param_arch("WallHeight",d)
def setAlign(self,i):
"""Simple callback for the interactive mode gui widget to set alignment."""
self.Align = ["Center","Left","Right"][i]
params.set_param_arch("WallAlignment",i)
def setContinue(self,i):
"""Simple callback to set if the interactive mode will restart when finished.
This allows for several walls to be placed one after another.
"""
self.continueCmd = bool(i)
params.set_param("ContinueMode", bool(i))
def setUseSketch(self,i):
"""Simple callback to set if walls should based on sketches."""
params.set_param_arch("WallSketches",bool(i))
def createFromGUI(self):
"""Callback to create wall by using the _CommandWall.taskbox()"""
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Wall"))
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand('wall = Arch.makeWall(length='+str(self.lengthValue)+',width='+str(self.Width)+',height='+str(self.Height)+',align="'+str(self.Align)+'")')
if self.MultiMat:
FreeCADGui.doCommand("wall.Material = FreeCAD.ActiveDocument."+self.MultiMat.Name)
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
if hasattr(FreeCADGui,"draftToolBar"):
FreeCADGui.draftToolBar.escape()
class _CommandMergeWalls:
"""The command definition for the Arch workbench's gui tool, Arch MergeWalls.
A tool for merging walls.
Join two or more walls by using the ArchWall.joinWalls() function.
Find documentation on the end user usage of Arch Wall here:
https://wiki.freecad.org/Arch_MergeWalls
"""
def GetResources(self):
"""Returns a dictionary with the visual aspects of the Arch MergeWalls tool."""
return {'Pixmap' : 'Arch_MergeWalls',
'MenuText': QT_TRANSLATE_NOOP("Arch_MergeWalls","Merge Walls"),
'ToolTip': QT_TRANSLATE_NOOP("Arch_MergeWalls","Merges the selected walls, if possible")}
def IsActive(self):
"""Determines whether or not the Arch MergeWalls tool is active.
Inactive commands are indicated by a greyed-out icon in the menus and
toolbars.
"""
return bool(FreeCADGui.Selection.getSelection())
def Activated(self):
"""Executed when Arch MergeWalls is called.
Call ArchWall.joinWalls() on walls selected by the user, with the
delete option enabled. If the user has selected a single wall, check to
see if the wall has any Additions that are walls. If so, merges these
additions to the wall, deleting the additions.
"""
walls = FreeCADGui.Selection.getSelection()
if len(walls) == 1:
if Draft.getType(walls[0]) == "Wall":
ostr = "FreeCAD.ActiveDocument."+ walls[0].Name
ok = False
for o in walls[0].Additions:
if Draft.getType(o) == "Wall":
ostr += ",FreeCAD.ActiveDocument." + o.Name
ok = True
if ok:
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Merge Wall"))
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("Arch.joinWalls(["+ostr+"],delete=True)")
FreeCAD.ActiveDocument.commitTransaction()
return
else:
FreeCAD.Console.PrintWarning(translate("Arch","The selected wall contains no subwall to merge"))
return
else:
FreeCAD.Console.PrintWarning(translate("Arch","Please select only wall objects"))
return
for w in walls:
if Draft.getType(w) != "Wall":
FreeCAD.Console.PrintMessage(translate("Arch","Please select only wall objects"))
return
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Merge Walls"))
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("Arch.joinWalls(FreeCADGui.Selection.getSelection(),delete=True)")
FreeCAD.ActiveDocument.commitTransaction()
class _Wall(ArchComponent.Component):
"""The Wall object.
@@ -1061,7 +476,7 @@ class _Wall(ArchComponent.Component):
if Draft.getType(obj.Base) == "Wire":
#print "modifying p2"
obj.Base.End = p2
elif Draft.getType(obj.Base) in ["Sketcher::SketchObject", "ArchSketch"]:
elif Draft.getType(obj.Base) == "Sketcher::SketchObject":
try:
obj.Base.recompute() # Fix for the 'GeoId index out range' error.
obj.Base.movePoint(0, 2, obj.Base.Placement.inverse().multVec(p2))
@@ -1211,8 +626,11 @@ class _Wall(ArchComponent.Component):
if not height:
return None
if obj.Normal == Vector(0,0,0):
import DraftGeomUtils
normal = DraftGeomUtils.get_shape_normal(obj.Base.Shape)
if obj.Base:
baseshape = obj.Base.Shape
else:
baseshape = Part.makeLine((0,0,0),(length,0,0))
normal = DraftGeomUtils.get_shape_normal(baseshape)
if normal == None:
normal = Vector(0,0,1)
else:
@@ -1772,7 +1190,3 @@ class _ViewProviderWall(ArchComponent.ViewProviderComponent):
elif obj.Align == "Right":
obj.Align = "Left"
FreeCAD.ActiveDocument.recompute()
if FreeCAD.GuiUp:
FreeCADGui.addCommand('Arch_Wall',_CommandWall())
FreeCADGui.addCommand('Arch_MergeWalls',_CommandMergeWalls())

View File

@@ -34,7 +34,7 @@ from draftutils.messages import _wrn
if FreeCAD.GuiUp:
import FreeCADGui
from PySide import QtCore, QtGui, QtSvgWidgets
from PySide import QtCore, QtGui, QtSvg
from draftutils.translate import translate
from PySide.QtCore import QT_TRANSLATE_NOOP
import draftguitools.gui_trackers as DraftTrackers
@@ -67,64 +67,7 @@ WindowOpeningModes = ["None","Arc 90","Arc 90 inv","Arc 45","Arc 45 inv","Arc 18
WindowPresets = ArchWindowPresets.WindowPresets
def makeWindow(baseobj=None,width=None,height=None,parts=None,name=None):
'''makeWindow(baseobj,[width,height,parts,name]): creates a window based on the
given base 2D object (sketch or draft).'''
if not FreeCAD.ActiveDocument:
FreeCAD.Console.PrintError("No active document. Aborting\n")
return
if baseobj:
if Draft.getType(baseobj) == "Window":
obj = Draft.clone(baseobj)
return obj
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","Window")
_Window(obj)
if name:
obj.Label = name
else:
obj.Label = translate("Arch","Window")
if FreeCAD.GuiUp:
_ViewProviderWindow(obj.ViewObject)
if width:
obj.Width = width
if height:
obj.Height = height
if baseobj:
obj.Normal = baseobj.Placement.Rotation.multVec(FreeCAD.Vector(0,0,-1))
obj.Base = baseobj
if parts is not None:
obj.WindowParts = parts
else:
if baseobj:
if baseobj.getLinkedObject().isDerivedFrom("Part::Part2DObject"):
# create default component
if baseobj.Shape.Wires:
tp = "Frame"
if len(baseobj.Shape.Wires) == 1:
tp = "Solid panel"
i = 0
ws = ''
for w in baseobj.Shape.Wires:
if w.isClosed():
if ws: ws += ","
ws += "Wire" + str(i)
i += 1
obj.WindowParts = ["Default",tp,ws,"1","0"]
else:
# bind properties from base obj if existing
for prop in ["Height","Width","Subvolume","Tag","Description","Material"]:
for p in baseobj.PropertiesList:
if (p == prop) or p.endswith("_"+prop):
obj.setExpression(prop, baseobj.Name+"."+p)
if obj.Base and FreeCAD.GuiUp:
obj.Base.ViewObject.DisplayMode = "Wireframe"
obj.Base.ViewObject.hide()
from DraftGui import todo
todo.delay(recolorize,[obj.Document.Name,obj.Name])
return obj
def recolorize(attr): # names is [docname,objname]
@@ -147,416 +90,6 @@ def recolorize(attr): # names is [docname,objname]
class _CommandWindow:
"the Arch Window command definition"
def __init__(self):
self.doormode = False
def GetResources(self):
return {'Pixmap' : 'Arch_Window',
'MenuText': QT_TRANSLATE_NOOP("Arch_Window","Window"),
'Accel': "W, N",
'ToolTip': QT_TRANSLATE_NOOP("Arch_Window","Creates a window object from a selected object (wire, rectangle or sketch)")}
def IsActive(self):
return not FreeCAD.ActiveDocument is None
def Activated(self):
self.sel = FreeCADGui.Selection.getSelection()
self.W1 = params.get_param_arch("WindowW1") # thickness of the fixed frame
if self.doormode:
self.Width = params.get_param_arch("DoorWidth")
self.Height = params.get_param_arch("DoorHeight")
else:
self.Width = params.get_param_arch("WindowWidth")
self.Height = params.get_param_arch("WindowHeight")
self.RemoveExternal = params.get_param_arch("archRemoveExternal")
self.Preset = 0
self.LibraryPreset = 0
self.Sill = 0
self.Include = True
self.baseFace = None
self.wparams = ["Width","Height","H1","H2","H3","W1","W2","O1","O2"]
self.wp = None
# autobuild mode
if FreeCADGui.Selection.getSelectionEx():
FreeCADGui.draftToolBar.offUi()
obj = self.sel[0]
if hasattr(obj,'Shape'):
if obj.Shape.Wires and (not obj.Shape.Solids) and (not obj.Shape.Shells):
FreeCADGui.Control.closeDialog()
host = None
if hasattr(obj,"AttachmentSupport"):
if obj.AttachmentSupport:
if isinstance(obj.AttachmentSupport,tuple):
host = obj.AttachmentSupport[0]
elif isinstance(obj.AttachmentSupport,list):
host = obj.AttachmentSupport[0][0]
else:
host = obj.AttachmentSupport
obj.AttachmentSupport = None # remove
elif Draft.isClone(obj,"Window"):
if obj.Objects[0].Inlist:
host = obj.Objects[0].Inlist[0]
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Window"))
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("win = Arch.makeWindow(FreeCAD.ActiveDocument."+obj.Name+")")
if host and self.Include:
FreeCADGui.doCommand("win.Hosts = [FreeCAD.ActiveDocument."+host.Name+"]")
siblings = host.Proxy.getSiblings(host)
sibs = [host]
for sibling in siblings:
if not sibling in sibs:
sibs.append(sibling)
FreeCADGui.doCommand("win.Hosts = win.Hosts+[FreeCAD.ActiveDocument."+sibling.Name+"]")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
return
# Try to detect an object to use as a window type - TODO we must make this safer
elif obj.Shape.Solids and (Draft.getType(obj) not in ["Wall","Structure","Roof"]):
# we consider the selected object as a type
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Window"))
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("Arch.makeWindow(FreeCAD.ActiveDocument."+obj.Name+")")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
return
# interactive mode
import WorkingPlane
self.wp = WorkingPlane.get_working_plane()
self.tracker = DraftTrackers.boxTracker()
self.tracker.length(self.Width)
self.tracker.width(self.W1)
self.tracker.height(self.Height)
self.tracker.on()
FreeCAD.Console.PrintMessage(translate("Arch","Choose a face on an existing object or select a preset")+"\n")
FreeCADGui.Snapper.getPoint(callback=self.getPoint,movecallback=self.update,extradlg=self.taskbox())
#FreeCADGui.Snapper.setSelectMode(True)
def has_width_and_height_constraint(self, sketch):
width_found = False
height_found = False
for constr in sketch.Constraints:
if constr.Name == "Width":
width_found = True
elif constr.Name == "Height":
height_found = True
elif width_found and height_found:
break
return (width_found and height_found)
def getPoint(self,point=None,obj=None):
"this function is called by the snapper when it has a 3D point"
self.tracker.finalize()
if point is None:
return
# if something was selected, override the underlying object
if self.sel:
obj = self.sel[0]
point = point.add(FreeCAD.Vector(0,0,self.Sill))
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Window"))
FreeCADGui.doCommand("import math, FreeCAD, Arch, DraftGeomUtils, WorkingPlane")
FreeCADGui.doCommand("wp = WorkingPlane.get_working_plane()")
if self.baseFace is not None:
FreeCADGui.doCommand("face = FreeCAD.ActiveDocument." + self.baseFace[0].Name + ".Shape.Faces[" + str(self.baseFace[1]) + "]")
FreeCADGui.doCommand("pl = DraftGeomUtils.placement_from_face(face, vec_z = wp.axis)")
else:
FreeCADGui.doCommand("pl = FreeCAD.Placement()")
FreeCADGui.doCommand("pl.Rotation = FreeCAD.Rotation(wp.u, wp.axis, -wp.v, 'XZY')")
FreeCADGui.doCommand("pl.Base = FreeCAD.Vector(" + str(point.x) + ", " + str(point.y) + ", " + str(point.z) + ")")
if self.Preset >= len(WindowPresets):
# library object
col = FreeCAD.ActiveDocument.Objects
path = self.librarypresets[self.Preset - len(WindowPresets)][1]
FreeCADGui.doCommand("FreeCADGui.ActiveDocument.mergeProject('" + path + "')")
# find the latest added window
nol = FreeCAD.ActiveDocument.Objects
for o in nol[len(col):]:
if Draft.getType(o) == "Window":
if Draft.getType(o.Base) != "Sketcher::SketchObject":
_wrn(translate("Arch", "Window not based on sketch. Window not aligned or resized."))
self.Include = False
break
FreeCADGui.doCommand("win = FreeCAD.ActiveDocument.getObject('" + o.Name + "')")
FreeCADGui.doCommand("win.Base.Placement = pl")
FreeCADGui.doCommand("win.Normal = pl.Rotation.multVec(FreeCAD.Vector(0, 0, -1))")
FreeCADGui.doCommand("win.Width = " + str(self.Width))
FreeCADGui.doCommand("win.Height = " + str(self.Height))
FreeCADGui.doCommand("win.Base.recompute()")
if not self.has_width_and_height_constraint(o.Base):
_wrn(translate("Arch", "No Width and/or Height constraint in window sketch. Window not resized."))
break
else:
_wrn(translate("Arch", "No window found. Cannot continue."))
self.Include = False
else:
# preset
wp = ""
for p in self.wparams:
wp += p.lower() + "=" + str(getattr(self,p)) + ", "
FreeCADGui.doCommand("win = Arch.makeWindowPreset('" + WindowPresets[self.Preset] + "', " + wp + "placement=pl)")
if self.Include:
host = None
if self.baseFace is not None:
host = self.baseFace[0]
elif obj:
host = obj
if Draft.getType(host) in AllowedHosts:
FreeCADGui.doCommand("win.Hosts = [FreeCAD.ActiveDocument." + host.Name + "]")
siblings = host.Proxy.getSiblings(host)
for sibling in siblings:
FreeCADGui.doCommand("win.Hosts = win.Hosts + [FreeCAD.ActiveDocument." + sibling.Name + "]")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
return
def update(self,point,info):
"this function is called by the Snapper when the mouse is moved"
delta = FreeCAD.Vector(self.Width/2,self.W1/2,self.Height/2)
delta = delta.add(FreeCAD.Vector(0,0,self.Sill))
if self.baseFace is None:
rot = FreeCAD.Rotation(self.wp.u,self.wp.v,-self.wp.axis,"XZY")
self.tracker.setRotation(rot)
if info:
if "Face" in info['Component']:
import DraftGeomUtils
o = FreeCAD.ActiveDocument.getObject(info['Object'])
self.baseFace = [o,int(info['Component'][4:])-1]
#print("switching to ",o.Label," face ",self.baseFace[1])
f = o.Shape.Faces[self.baseFace[1]]
p = DraftGeomUtils.placement_from_face(f,vec_z=self.wp.axis,rotated=True)
rot = p.Rotation
self.tracker.setRotation(rot)
r = self.tracker.trans.rotation.getValue().getValue()
if r != (0,0,0,1):
delta = FreeCAD.Rotation(r[0],r[1],r[2],r[3]).multVec(FreeCAD.Vector(delta.x,-delta.y,-delta.z))
self.tracker.pos(point.add(delta))
def taskbox(self):
"sets up a taskbox widget"
w = QtGui.QWidget()
ui = FreeCADGui.UiLoader()
w.setWindowTitle(translate("Arch","Window options"))
grid = QtGui.QGridLayout(w)
# include box
include = QtGui.QCheckBox(translate("Arch","Auto include in host object"))
include.setChecked(True)
grid.addWidget(include,0,0,1,2)
QtCore.QObject.connect(include,QtCore.SIGNAL("stateChanged(int)"),self.setInclude)
# sill height
labels = QtGui.QLabel(translate("Arch","Sill height"))
values = ui.createWidget("Gui::InputField")
grid.addWidget(labels,1,0,1,1)
grid.addWidget(values,1,1,1,1)
QtCore.QObject.connect(values,QtCore.SIGNAL("valueChanged(double)"),self.setSill)
# check for Parts library and Arch presets
# because of the use of FreeCADGui.doCommand() backslashes in the
# paths in librarypresets need to be double escaped "\\\\", so let's
# use forward slashes instead...
self.librarypresets = []
librarypath = FreeCAD.ParamGet("User parameter:Plugins/parts_library").GetString("destination", "")
# librarypath should have only forward slashes already, but let's use replace() anyway just to be sure:
librarypath = librarypath.replace("\\", "/") + "/Architectural Parts"
presetdir = FreeCAD.getUserAppDataDir().replace("\\", "/") + "/Arch"
for path in [librarypath, presetdir]:
if os.path.isdir(path):
for wtype in ["Windows", "Doors"]:
wdir = path + "/" + wtype
if os.path.isdir(wdir):
for subtype in os.listdir(wdir):
subdir = wdir + "/" + subtype
if os.path.isdir(subdir):
for subfile in os.listdir(subdir):
if (os.path.isfile(subdir + "/" + subfile)
and subfile.lower().endswith(".fcstd")):
self.librarypresets.append([wtype + " - " + subtype + " - " + subfile[:-6],
subdir + "/" + subfile])
# presets box
labelp = QtGui.QLabel(translate("Arch","Preset"))
valuep = QtGui.QComboBox()
valuep.setMinimumContentsLength(6)
valuep.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents)
valuep.addItems(WindowPresets)
valuep.setCurrentIndex(self.Preset)
grid.addWidget(labelp,2,0,1,1)
grid.addWidget(valuep,2,1,1,1)
QtCore.QObject.connect(valuep,QtCore.SIGNAL("currentIndexChanged(int)"),self.setPreset)
for it in self.librarypresets:
valuep.addItem(it[0])
# image display
self.pic = QtGui.QLabel()
grid.addWidget(self.pic,3,0,1,2)
self.pic.setFixedHeight(128)
self.pic.hide()
# SVG display
self.im = QtSvgWidgets.QSvgWidget(":/ui/ParametersWindowFixed.svg")
self.im.setMaximumWidth(200)
self.im.setMinimumHeight(120)
grid.addWidget(self.im,4,0,1,2)
#self.im.hide()
# parameters
i = 5
for param in self.wparams:
lab = QtGui.QLabel(translate("Arch",param))
setattr(self,"val"+param,ui.createWidget("Gui::InputField"))
wid = getattr(self,"val"+param)
if param == "W1":
wid.setText(FreeCAD.Units.Quantity(self.W1,FreeCAD.Units.Length).UserString)
elif param == "Width":
wid.setText(FreeCAD.Units.Quantity(self.Width,FreeCAD.Units.Length).UserString)
elif param == "Height":
wid.setText(FreeCAD.Units.Quantity(self.Height,FreeCAD.Units.Length).UserString)
else:
n = params.get_param_arch("Window"+param)
wid.setText(FreeCAD.Units.Quantity(n,FreeCAD.Units.Length).UserString)
setattr(self,param,n)
grid.addWidget(lab,i,0,1,1)
grid.addWidget(wid,i,1,1,1)
i += 1
valueChanged = self.getValueChanged(param)
FreeCAD.wid = wid
QtCore.QObject.connect(getattr(self,"val"+param),QtCore.SIGNAL("valueChanged(double)"), valueChanged)
# restore saved states
if self.doormode:
i = params.get_param_arch("DoorPreset")
d = params.get_param_arch("DoorSill")
else:
i = params.get_param_arch("WindowPreset")
d = params.get_param_arch("WindowSill")
if i < valuep.count():
valuep.setCurrentIndex(i)
values.setText(FreeCAD.Units.Quantity(d,FreeCAD.Units.Length).UserString)
return w
def getValueChanged(self,p):
return lambda d : self.setParams(p, d)
def setSill(self,d):
self.Sill = d
if self.doormode:
params.set_param_arch("DoorSill",d)
else:
params.set_param_arch("WindowSill",d)
def setInclude(self,i):
self.Include = bool(i)
def setParams(self,param,d):
setattr(self,param,d)
self.tracker.length(self.Width)
self.tracker.height(self.Height)
self.tracker.width(self.W1)
prefix = "Door" if self.doormode and param in ("Width","Height") else "Window"
params.set_param_arch(prefix+param,d)
def setPreset(self,i):
self.Preset = i
if self.doormode:
params.set_param_arch("DoorPreset",i)
else:
params.set_param_arch("WindowPreset",i)
if i >= 0:
FreeCADGui.Snapper.setSelectMode(False)
self.tracker.length(self.Width)
self.tracker.height(self.Height)
self.tracker.width(self.W1)
self.tracker.on()
self.pic.hide()
self.im.show()
if i == 0:
self.im.load(":/ui/ParametersWindowFixed.svg")
elif i in [1,8]:
self.im.load(":/ui/ParametersWindowSimple.svg")
elif i in [2,4,7]:
self.im.load(":/ui/ParametersWindowDouble.svg")
elif i == 3:
self.im.load(":/ui/ParametersWindowStash.svg")
elif i == 5:
self.im.load(":/ui/ParametersDoorSimple.svg")
elif i == 6:
self.im.load(":/ui/ParametersDoorGlass.svg")
elif i == 9:
self.im.load(":/ui/ParametersOpening.svg")
else:
# From Library
self.im.hide()
path = self.librarypresets[i-len(WindowPresets)][1]
if path.lower().endswith(".fcstd"):
try:
import tempfile
import zipfile
except Exception:
pass
else:
zfile = zipfile.ZipFile(path)
files = zfile.namelist()
# check for meta-file if it's really a FreeCAD document
if files[0] == "Document.xml":
image="thumbnails/Thumbnail.png"
if image in files:
image = zfile.read(image)
thumbfile = tempfile.mkstemp(suffix='.png')[1]
thumb = open(thumbfile,"wb")
thumb.write(image)
thumb.close()
im = QtGui.QPixmap(thumbfile)
self.pic.setPixmap(im)
self.pic.show()
#for param in self.wparams:
# getattr(self,"val"+param).setEnabled(True)
else:
FreeCADGui.Snapper.setSelectMode(True)
self.tracker.off()
self.im.hide()
for param in self.wparams:
getattr(self,"val"+param).setEnabled(False)
class _Window(ArchComponent.Component):
"The Window object"
@@ -1841,5 +1374,4 @@ class _ArchWindowTaskPanel:
self.obj.ViewObject.Proxy.invertHinge()
if FreeCAD.GuiUp:
FreeCADGui.addCommand('Arch_Window',_CommandWindow())

View File

@@ -11,20 +11,11 @@ SET(Arch_SRCS
ArchIFCSchema.py
ArchProject.py
ArchWall.py
importIFC.py
importIFClegacy.py
importIFCHelper.py
importIFCmulticore.py
exportIFCHelper.py
Arch.py
ArchBuilding.py
ArchFloor.py
ArchSite.py
ArchStructure.py
ArchCommands.py
ArchSectionPlane.py
importDAE.py
importOBJ.py
ArchWindow.py
ArchWindowPresets.py
ArchAxis.py
@@ -33,8 +24,6 @@ SET(Arch_SRCS
ArchVRM.py
ArchRoof.py
ArchStairs.py
importWebGL.py
importJSON.py
ArchSpace.py
ArchRebar.py
TestArch.py
@@ -45,23 +34,39 @@ SET(Arch_SRCS
ArchMaterial.py
ArchSchedule.py
ArchProfile.py
import3DS.py
ArchPrecast.py
importSH3D.py
ArchPipe.py
ArchNesting.py
ArchBuildingPart.py
ArchReference.py
ArchFence.py
OfflineRenderingUtils.py
exportIFC.py
ArchTruss.py
ArchCurtainWall.py
importSHP.py
exportIFCStructuralTools.py
ifc_objects.py
ifc_viewproviders.py
ArchSketchObject.py
BimSelect.py
BimStatusBar.py
)
SET(importers_SRCS
importers/__init__.py
importers/importIFC.py
importers/importIFClegacy.py
importers/importIFCHelper.py
importers/importIFCmulticore.py
importers/importDAE.py
importers/importOBJ.py
importers/importWebGL.py
importers/importJSON.py
importers/importSH3D.py
importers/import3DS.py
importers/importSHP.py
importers/importGBXML.py
importers/exportIFCStructuralTools.py
importers/exportIFC.py
importers/exportIFCHelper.py
)
SET(Dice3DS_SRCS
@@ -81,18 +86,132 @@ SET(Arch_presets
Presets/ifc_contexts_IFC4.json
)
SET(bimcommands_SRCS
bimcommands/BimArchUtils.py
bimcommands/BimAxis.py
bimcommands/BimBackground.py
bimcommands/BimBeam.py
bimcommands/BimBox.py
bimcommands/BimBuilder.py
bimcommands/BimBuildingPart.py
bimcommands/BimClassification.py
bimcommands/BimClone.py
bimcommands/BimColumn.py
bimcommands/BimCommon.py
bimcommands/BimCompound.py
bimcommands/BimConvert.py
bimcommands/BimCopy.py
bimcommands/BimCurtainwall.py
bimcommands/BimCutPlane.py
bimcommands/BimCut.py
bimcommands/BimDiff.py
bimcommands/BimDimensions.py
bimcommands/BimDoor.py
bimcommands/BimEmptyTrash.py
bimcommands/BimEquipment.py
bimcommands/BimExamples.py
bimcommands/BimExtrude.py
bimcommands/BimFence.py
bimcommands/BimFrame.py
bimcommands/BimFuse.py
bimcommands/BimGlue.py
bimcommands/BimHelp.py
bimcommands/BimIfcElements.py
bimcommands/BimIfcExplorer.py
bimcommands/BimIfcProperties.py
bimcommands/BimIfcQuantities.py
bimcommands/BimImagePlane.py
bimcommands/BimLayers.py
bimcommands/BimLeader.py
bimcommands/BimLibrary.py
bimcommands/BimMaterial.py
bimcommands/BimMoveView.py
bimcommands/BimNudge.py
bimcommands/BimOffset.py
bimcommands/BimPanel.py
bimcommands/BimPipe.py
bimcommands/BimPreflight.py
bimcommands/BimProfile.py
bimcommands/BimProjectManager.py
bimcommands/BimProject.py
bimcommands/BimRebar.py
bimcommands/BimReextrude.py
bimcommands/BimReference.py
bimcommands/BimReorder.py
bimcommands/BimResetCloneColors.py
bimcommands/BimRewire.py
bimcommands/BimRoof.py
bimcommands/BimSchedule.py
bimcommands/BimSectionPlane.py
bimcommands/BimSetup.py
bimcommands/BimShape2DView.py
bimcommands/BimSimpleCopy.py
bimcommands/BimSite.py
bimcommands/BimSketch.py
bimcommands/BimSlab.py
bimcommands/BimSpace.py
bimcommands/BimStairs.py
bimcommands/BimTDPage.py
bimcommands/BimTDView.py
bimcommands/BimText.py
bimcommands/BimTogglePanels.py
bimcommands/BimTrash.py
bimcommands/BimTruss.py
bimcommands/BimTutorial.py
bimcommands/BimUnclone.py
bimcommands/BimUngroup.py
bimcommands/BimViews.py
bimcommands/BimWall.py
bimcommands/BimWelcome.py
bimcommands/BimWindow.py
bimcommands/BimWindows.py
bimcommands/BimWPCommands.py
bimcommands/__init__.py
)
SET(nativeifc_SRCS
nativeifc/ifc_commands.py
nativeifc/ifc_diff.py
nativeifc/ifc_generator.py
nativeifc/ifc_geometry.py
nativeifc/ifc_import.py
nativeifc/ifc_layers.py
nativeifc/ifc_materials.py
nativeifc/ifc_objects.py
nativeifc/ifc_observer.py
nativeifc/ifc_performance_test.py
nativeifc/ifc_preferences.py
nativeifc/ifc_psets.py
nativeifc/ifc_selftest.py
nativeifc/ifc_status.py
nativeifc/ifc_tools.py
nativeifc/ifc_tree.py
nativeifc/ifc_viewproviders.py
nativeifc/__init__.py
)
SOURCE_GROUP("" FILES ${Arch_SRCS})
SET(ArchGuiIcon_SVG
Resources/icons/ArchWorkbench.svg
Resources/icons/BIMWorkbench.svg
)
ADD_CUSTOM_TARGET(Arch ALL
SOURCES ${Arch_SRCS} ${Arch_QRC_SRCS} ${Dice3DS_SRCS} ${Arch_presets} ${ArchGuiIcon_SVG}
SOURCES ${Arch_SRCS}
${Arch_QRC_SRCS}
${Dice3DS_SRCS}
${Arch_presets}
${ArchGuiIcon_SVG}
${importers_SRCS}
${bimcommands_SRCS}
${nativeifc_SRCS}
)
fc_copy_sources(Arch "${CMAKE_BINARY_DIR}/Mod/Arch" ${Arch_SRCS})
fc_copy_sources(Arch "${CMAKE_BINARY_DIR}/Mod/Arch" ${Dice3DS_SRCS})
fc_copy_sources(Arch "${CMAKE_BINARY_DIR}/Mod/Arch" ${importers_SRCS})
fc_copy_sources(Arch "${CMAKE_BINARY_DIR}/Mod/Arch" ${bimcommands_SRCS})
fc_copy_sources(Arch "${CMAKE_BINARY_DIR}/Mod/Arch" ${nativeifc_SRCS})
fc_copy_sources(Arch "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_DATADIR}/Mod/Arch" ${ArchGuiIcon_SVG})
fc_target_copy_resource(Arch
@@ -120,12 +239,32 @@ INSTALL(
${Dice3DS_SRCS}
DESTINATION Mod/Arch/Dice3DS
)
INSTALL(
FILES
${importers_SRCS}
DESTINATION Mod/Arch/importers
)
INSTALL(
FILES
${bimcommands_SRCS}
DESTINATION Mod/Arch/bimcommands
)
INSTALL(
FILES
${nativeifc_SRCS}
DESTINATION Mod/Arch/nativeifc
)
INSTALL(
DIRECTORY
Presets
DESTINATION
${CMAKE_INSTALL_DATADIR}/Mod/Arch
)
INSTALL(
FILES
${ArchGuiIcon_SVG}

View File

@@ -1,34 +1,37 @@
#***************************************************************************
#* Copyright (c) 2011 Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
#* *
#* This program is distributed in the hope that it will be useful, *
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
#* GNU Library General Public License for more details. *
#* *
#* You should have received a copy of the GNU Library General Public *
#* License along with this program; if not, write to the Free Software *
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA *
#* *
#***************************************************************************
# ***************************************************************************
# * *
# * Copyright (c) 2022 Yorik van Havre <yorik@uncreated.net> *
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU Lesser General Public License (LGPL) *
# * as published by the Free Software Foundation; either version 2 of *
# * the License, or (at your option) any later version. *
# * for detail see the LICENCE text file. *
# * *
# * This program is distributed in the hope that it will be useful, *
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# * GNU Library General Public License for more details. *
# * *
# * You should have received a copy of the GNU Library General Public *
# * License along with this program; if not, write to the Free Software *
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************
# add import/export types
FreeCAD.addImportType("Industry Foundation Classes (*.ifc *.IFC)","importIFC")
FreeCAD.addExportType("Industry Foundation Classes (*.ifc)","exportIFC")
FreeCAD.addExportType("Industry Foundation Classes - IFCJSON (*.ifcJSON)","exportIFC")
FreeCAD.addImportType("Wavefront OBJ - Arch module (*.obj *.OBJ)","importOBJ")
FreeCAD.addExportType("Wavefront OBJ - Arch module (*.obj)","importOBJ")
FreeCAD.addExportType("WebGL file (*.html)","importWebGL")
FreeCAD.addExportType("JavaScript Object Notation (*.json)","importJSON")
FreeCAD.addImportType("Collada (*.dae *.DAE)","importDAE")
FreeCAD.addExportType("Collada (*.dae)","importDAE")
FreeCAD.addImportType("3D Studio mesh (*.3ds *.3DS)","import3DS")
FreeCAD.addImportType("SweetHome3D XML export (*.zip *.ZIP)","importSH3D")
FreeCAD.addImportType("Shapefile (*.shp *.SHP)","importSHP")
FreeCAD.addImportType("Industry Foundation Classes (*.ifc)","importers.exportIFC")
# FreeCAD.addExportType("Industry Foundation Classes (*.ifc)","importIFC")
FreeCAD.addImportType("Industry Foundation Classes (*.ifc)", "nativeifc.ifc_import")
FreeCAD.addExportType("Industry Foundation Classes - IFCJSON (*.ifcJSON)","importers.exportIFC")
FreeCAD.addImportType("Wavefront OBJ - Arch module (*.obj *.OBJ)","importers.importOBJ")
FreeCAD.addExportType("Wavefront OBJ - Arch module (*.obj)","importers.importOBJ")
FreeCAD.addExportType("WebGL file (*.html)","importers.importWebGL")
FreeCAD.addExportType("JavaScript Object Notation (*.json)","importers.importJSON")
FreeCAD.addImportType("Collada (*.dae *.DAE)","importers.importDAE")
FreeCAD.addExportType("Collada (*.dae)","importers.importDAE")
FreeCAD.addImportType("3D Studio mesh (*.3ds *.3DS)","importers.import3DS")
FreeCAD.addImportType("SweetHome3D XML export (*.zip *.ZIP)","importers.importSH3D")
FreeCAD.addImportType("Shapefile (*.shp *.SHP)","importers.importSHP")

View File

@@ -1,5 +1,6 @@
# ***************************************************************************
# * Copyright (c) 2011 Yorik van Havre <yorik@uncreated.net> *
# * *
# * Copyright (c) 2017 Yorik van Havre <yorik@uncreated.net> *
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU Lesser General Public License (LGPL) *
@@ -19,248 +20,656 @@
# * *
# ***************************************************************************
"""Initialization of the Arch workbench (graphical interface)."""
"""The BIM workbench"""
import os
import FreeCAD
import FreeCADGui
import Arch_rc
class ArchWorkbench(FreeCADGui.Workbench):
"""The Arch workbench definition."""
class BIMWorkbench(Workbench):
def __init__(self):
def QT_TRANSLATE_NOOP(context, text):
return text
__dirname__ = os.path.join(FreeCAD.getResourceDir(), "Mod", "Arch")
_tooltip = ("The Arch workbench is used to model "
"architectural components, and entire buildings")
self.__class__.Icon = os.path.join(__dirname__,
"Resources", "icons",
"ArchWorkbench.svg")
self.__class__.MenuText = QT_TRANSLATE_NOOP("Arch", "Arch")
self.__class__.ToolTip = QT_TRANSLATE_NOOP("Arch", _tooltip)
bdir = os.path.join(FreeCAD.getResourceDir(), "Mod", "BIM")
tt = QT_TRANSLATE_NOOP("BIM","The BIM workbench is used to model buildings")
self.__class__.MenuText = QT_TRANSLATE_NOOP("BIM", "BIM")
self.__class__.ToolTip = tt
self.__class__.Icon = os.path.join(bdir,"Resources", "icons",
"BIMWorkbench.svg")
def Initialize(self):
"""When the workbench is first loaded."""
# add translations and icon paths
FreeCADGui.addIconPath(":/icons")
FreeCADGui.addLanguagePath(":/translations")
# Create menus and toolbars
self.createTools()
# Load Arch & Draft preference pages
self.loadPreferences()
Log("Loading BIM module... done\n")
FreeCADGui.updateLocale()
def createTools(self):
"Create tolbars and menus"
def QT_TRANSLATE_NOOP(context, text):
return text
import Draft_rc
# Import Draft & BIM commands
import DraftTools
import DraftGui
import Arch_rc
import Arch
import bimcommands
from nativeifc import ifc_commands
# build menus and toolbars
self.draftingtools = [
"BIM_Sketch",
"Draft_Line",
"Draft_Wire",
"Draft_Circle",
"Draft_Arc",
"Draft_Arc_3Points",
"Draft_Fillet",
"Draft_Ellipse",
"Draft_Polygon",
"Draft_Rectangle",
"Draft_BSpline",
"Draft_BezCurve",
"Draft_CubicBezCurve",
"Draft_Point",
]
self.annotationtools = [
#"BIM_ImagePlane",
"BIM_Text",
"Draft_ShapeString",
"BIM_DimensionAligned",
"BIM_DimensionHorizontal",
"BIM_DimensionVertical",
"BIM_Leader",
"Draft_Label",
"Arch_Axis",
"Arch_AxisSystem",
"Arch_Grid",
"Arch_SectionPlane",
"Draft_Hatch",
"BIM_TDPage",
"BIM_TDView",
"BIM_Shape2DView",
]
self.bimtools = [
"BIM_Project",
"Arch_Site",
"Arch_Building",
"Arch_Level",
"Arch_Space",
"Separator",
"Arch_Wall",
"Arch_CurtainWall",
"BIM_Column",
"BIM_Beam",
"BIM_Slab",
"BIM_Door",
"Arch_Window",
"Arch_Pipe",
"Arch_PipeConnector",
"Arch_Stairs",
"Arch_Roof",
"Arch_Panel",
"Arch_Frame",
"Arch_Fence",
"Arch_Truss",
"Arch_Rebar",
]
self.generictools = [
"Arch_Profile",
"BIM_Box",
"BIM_Builder",
"Draft_Facebinder",
"BIM_Library",
"Arch_Component",
"Arch_Reference",
]
self.modify = [
"Draft_Move",
"BIM_Copy",
"Draft_Rotate",
"BIM_Clone",
"BIM_Unclone",
"Draft_Offset",
"BIM_Offset2D",
"Draft_Trimex",
"Draft_Join",
"Draft_Split",
"Draft_Scale",
"Draft_Stretch",
"BIM_Rewire",
"BIM_Glue",
"Draft_Upgrade",
"Draft_Downgrade",
"Draft_Draft2Sketch",
"Arch_CutPlane",
"Arch_Add",
"Arch_Remove",
"BIM_Reextrude",
"Draft_OrthoArray",
"Draft_PathArray",
"Draft_PointArray",
"Draft_Mirror",
"BIM_Extrude",
"BIM_Cut",
"BIM_Fuse",
"BIM_Common",
"BIM_Compound",
"BIM_SimpleCopy",
]
self.manage = [
"BIM_Setup",
"BIM_Views",
"BIM_ProjectManager",
"BIM_Windows",
"BIM_IfcElements",
"BIM_IfcQuantities",
"BIM_IfcProperties",
"BIM_Classification",
"BIM_Layers",
"BIM_Material",
"Arch_Schedule",
"BIM_Preflight",
"Draft_AnnotationStyleEditor",
]
self.utils = [
"BIM_TogglePanels",
"BIM_Trash",
"BIM_WPView",
"Draft_SelectGroup",
"Draft_Slope",
"Draft_WorkingPlaneProxy",
"Draft_AddConstruction",
"Arch_SplitMesh",
"Arch_MeshToShape",
"Arch_SelectNonSolidMeshes",
"Arch_RemoveShape",
"Arch_CloseHoles",
"Arch_MergeWalls",
"Arch_Check",
"Arch_ToggleIfcBrepFlag",
"Arch_ToggleSubs",
"Arch_Survey",
"BIM_Diff",
"BIM_IfcExplorer",
]
nudge = [
"BIM_Nudge_Switch",
"BIM_Nudge_Up",
"BIM_Nudge_Down",
"BIM_Nudge_Left",
"BIM_Nudge_Right",
"BIM_Nudge_RotateLeft",
"BIM_Nudge_RotateRight",
"BIM_Nudge_Extend",
"BIM_Nudge_Shrink",
]
# append BIM snaps
from draftutils import init_tools
self.snapbar = init_tools.get_draft_snap_commands()
self.snapmenu = self.snapbar + [
"BIM_SetWPTop",
"BIM_SetWPFront",
"BIM_SetWPSide",
]
# create generic tools command
class BIM_GenericTools:
def __init__(self, tools):
self.tools = tools
def GetCommands(self):
return self.tools
def GetResources(self):
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
FreeCADGui.addCommand("BIM_GenericTools", BIM_GenericTools(self.generictools))
self.bimtools.append("BIM_GenericTools")
# load rebar tools (Reinforcement addon)
# Load Reinforcement WB translations
try:
import RebarTools
RebarTools.load_translations()
except Exception:
except ImportError:
pass
from ArchStructure import _ArchStructureGroupCommand
from ArchAxis import _ArchAxisGroupCommand
from ArchPanel import CommandPanelGroup
from ArchMaterial import _ArchMaterialToolsCommand
from ArchPipe import _ArchPipeGroupCommand
stru_group = _ArchStructureGroupCommand
axis_group = _ArchAxisGroupCommand
pan_group = CommandPanelGroup
mat_group = _ArchMaterialToolsCommand
pipe_group = _ArchPipeGroupCommand
# Set up command lists
self.archtools = ["Arch_Wall",
([QT_TRANSLATE_NOOP("Workbench", "Structure tools")],
list(stru_group.GetCommands(stru_group))), # tuple len=2: submenu
("Arch_StructureTools", ), # tuple len=1: toolbar flyout
"Arch_Rebar_Submenu", # will be replaced or removed
"Arch_Rebar", # may be replaced
"Arch_CurtainWall",
"Arch_BuildingPart",
"Arch_Project",
"Arch_Site",
"Arch_Building",
"Arch_Floor",
"Arch_Reference",
"Arch_Window",
"Arch_Roof",
([QT_TRANSLATE_NOOP("Workbench", "Axis tools")],
list(axis_group.GetCommands(axis_group))),
("Arch_AxisTools", ),
"Arch_SectionPlane",
"Arch_Space",
"Arch_Stairs",
([QT_TRANSLATE_NOOP("Workbench", "Panel tools")],
list(pan_group.GetCommands(pan_group))),
("Arch_PanelTools", ),
"Arch_Equipment",
"Arch_Frame",
"Arch_Fence",
"Arch_Truss",
"Arch_Profile",
([QT_TRANSLATE_NOOP("Workbench", "Material tools")],
list(mat_group.GetCommands(mat_group))),
("Arch_MaterialTools", ),
"Arch_Schedule",
([QT_TRANSLATE_NOOP("Workbench", "Pipe tools")],
list(pipe_group.GetCommands(pipe_group))),
("Arch_PipeTools", ),
"Arch_CutPlane",
"Arch_Add",
"Arch_Remove",
"Arch_Survey"]
self.utilities = ["Arch_Component",
"Arch_CloneComponent",
"Arch_SplitMesh",
"Arch_MeshToShape",
"Arch_SelectNonSolidMeshes",
"Arch_RemoveShape",
"Arch_CloseHoles",
"Arch_MergeWalls",
"Arch_Check",
"Arch_ToggleIfcBrepFlag",
"Arch_3Views",
"Arch_IfcSpreadsheet",
"Arch_ToggleSubs"]
# Add the rebar tools from the Reinforcement addon, if available
try:
import RebarTools
except Exception:
del self.archtools[3] # remove "Arch_Rebar_Submenu"
else:
# create popup group for Rebar tools
class RebarGroupCommand:
def GetCommands(self):
return tuple(RebarTools.RebarCommands + ["Arch_Rebar"])
return tuple(["Arch_Rebar"] + RebarTools.RebarCommands)
def GetResources(self):
return {'MenuText': QT_TRANSLATE_NOOP("Arch_RebarTools", "Rebar tools"),
'ToolTip': QT_TRANSLATE_NOOP("Arch_RebarTools",
"Create various types of rebars, "
"including U-shaped, L-shaped, and stirrup")}
return {
"MenuText": QT_TRANSLATE_NOOP(
"Arch_RebarTools", "Reinforcement tools"
),
"ToolTip": QT_TRANSLATE_NOOP(
"Arch_RebarTools", "Reinforcement tools"
),
"Icon": "Arch_Rebar",
}
def IsActive(self):
return not FreeCAD.ActiveDocument is None
FreeCADGui.addCommand('Arch_RebarTools', RebarGroupCommand())
self.archtools[3] = ([QT_TRANSLATE_NOOP("Workbench", "Rebar tools")],
RebarTools.RebarCommands + ["Arch_Rebar"])
self.archtools[4] = ("Arch_RebarTools", )
# Set up Draft command lists
import draftutils.init_tools as it
self.draft_drawing_commands = it.get_draft_drawing_commands()
self.draft_annotation_commands = it.get_draft_annotation_commands()
self.draft_modification_commands = it.get_draft_modification_commands()
self.draft_utility_commands = it.get_draft_utility_commands_menu()
self.draft_context_commands = it.get_draft_context_commands()
self.draft_snap_commands = it.get_draft_snap_commands()
FreeCADGui.addCommand("Arch_RebarTools", RebarGroupCommand())
self.bimtools[self.bimtools.index("Arch_Rebar")] = "Arch_RebarTools"
RebarTools.load_translations()
Log("Load Reinforcement Module...done\n")
if hasattr(RebarTools, "updateLocale"):
RebarTools.updateLocale()
#self.rebar = RebarTools.RebarCommands + ["Arch_Rebar"]
# Set up toolbars
it.init_toolbar(self,
QT_TRANSLATE_NOOP("Workbench", "Arch tools"),
self.archtools)
it.init_toolbar(self,
QT_TRANSLATE_NOOP("Workbench", "Draft creation tools"),
self.draft_drawing_commands)
it.init_toolbar(self,
QT_TRANSLATE_NOOP("Workbench", "Draft annotation tools"),
self.draft_annotation_commands)
it.init_toolbar(self,
QT_TRANSLATE_NOOP("Workbench", "Draft modification tools"),
self.draft_modification_commands)
it.init_toolbar(self,
QT_TRANSLATE_NOOP("Workbench", "Draft snap"),
self.draft_snap_commands)
# try to load bimbots
# Set up menus
it.init_menu(self,
[QT_TRANSLATE_NOOP("Workbench", "&Arch"),
QT_TRANSLATE_NOOP("Workbench", "Utilities")],
self.utilities)
it.init_menu(self,
[QT_TRANSLATE_NOOP("Workbench", "&Arch")],
self.archtools)
it.init_menu(self,
[QT_TRANSLATE_NOOP("Workbench", "&Draft"),
QT_TRANSLATE_NOOP("Workbench", "Creation")],
self.draft_drawing_commands)
it.init_menu(self,
[QT_TRANSLATE_NOOP("Workbench", "&Draft"),
QT_TRANSLATE_NOOP("Workbench", "Annotation")],
self.draft_annotation_commands)
it.init_menu(self,
[QT_TRANSLATE_NOOP("Workbench", "&Draft"),
QT_TRANSLATE_NOOP("Workbench", "Modification")],
self.draft_modification_commands)
it.init_menu(self,
[QT_TRANSLATE_NOOP("Workbench", "&Draft"),
QT_TRANSLATE_NOOP("Workbench", "Utilities")],
self.draft_utility_commands)
try:
import bimbots
except ImportError:
pass
else:
class BIMBots:
def GetResources(self):
return bimbots.get_plugin_info()
FreeCADGui.addIconPath(":/icons")
FreeCADGui.addLanguagePath(":/translations")
def Activated(self):
bimbots.launch_ui()
# Set up preferences pages
FreeCADGui.addCommand("BIMBots", BIMBots())
self.utils.append("BIMBots")
# load Reporting
try:
import report
except ImportError:
pass
else:
if "Report_Create" in Gui.listCommands():
self.manage[self.manage.index("Arch_Schedule")] = "Report_Create"
# load webtools
try:
import BIMServer, Git, Sketchfab
except ImportError:
pass
else:
self.utils.extend(
[
"WebTools_Git",
"WebTools_BimServer",
"WebTools_Sketchfab",
]
)
# load flamingo
try:
import CommandsPolar, CommandsFrame, CommandsPipe
except ImportError:
flamingo = None
else:
flamingo = [
"frameIt",
"fillFrame",
"insertPath",
"insertSection",
"FrameLineManager",
"spinSect",
"reverseBeam",
"shiftBeam",
"pivotBeam",
"levelBeam",
"alignEdge",
"rotJoin",
"alignFlange",
"stretchBeam",
"extend",
"adjustFrameAngle",
"insertPipe",
"insertElbow",
"insertReduct",
"insertCap",
"insertFlange",
"insertUbolt",
"insertPypeLine",
"breakPipe",
"mateEdges",
"extend2intersection",
"extend1intersection",
"laydown",
"raiseup",
]
# load fasteners
try:
import FastenerBase, FastenersCmd
except ImportError:
fasteners = None
else:
fasteners = [
c
for c in FastenerBase.FSGetCommands("screws")
if not isinstance(c, tuple)
]
# load nativeifc tools
ifctools = ifc_commands.get_commands()
# create toolbars
t1 = QT_TRANSLATE_NOOP("Workbench", "Drafting tools")
t2 = QT_TRANSLATE_NOOP("Workbench", "Draft snap")
t3 = QT_TRANSLATE_NOOP("Workbench", "3D/BIM tools")
t4 = QT_TRANSLATE_NOOP("Workbench", "Annotation tools")
t5 = QT_TRANSLATE_NOOP("Workbench", "Modification tools")
t6 = QT_TRANSLATE_NOOP("Workbench", "Manage tools")
self.appendToolbar(t1, self.draftingtools)
self.appendToolbar(t2, self.snapbar)
self.appendToolbar(t3, self.bimtools)
self.appendToolbar(t4, self.annotationtools)
self.appendToolbar(t5, self.modify)
self.appendToolbar(t6, self.manage)
# create menus
t1 = QT_TRANSLATE_NOOP("Workbench", "&2D Drafting")
t2 = QT_TRANSLATE_NOOP("Workbench", "&3D/BIM")
t3 = QT_TRANSLATE_NOOP("Workbench", "Reinforcement tools")
t4 = QT_TRANSLATE_NOOP("Workbench", "&Annotation")
t5 = QT_TRANSLATE_NOOP("Workbench", "&Snapping")
t6 = QT_TRANSLATE_NOOP("Workbench", "&Modify")
t7 = QT_TRANSLATE_NOOP("Workbench", "&Manage")
t8 = QT_TRANSLATE_NOOP("Workbench", "&IFC")
t9 = QT_TRANSLATE_NOOP("Workbench", "&Flamingo")
t10 = QT_TRANSLATE_NOOP("Workbench", "&Fasteners")
t11 = QT_TRANSLATE_NOOP("Workbench", "&Utils")
t12 = QT_TRANSLATE_NOOP("Workbench", "Nudge")
#self.bimtools_menu = list(self.bimtools)
#if "Arch_RebarTools" in self.bimtools_menu:
# self.bimtools_menu.remove("Arch_RebarTools")
self.appendMenu(t1, self.draftingtools)
self.appendMenu(t2, self.bimtools)
#if self.rebar:
# self.appendMenu([t2, t3], self.rebar)
self.appendMenu(t4, self.annotationtools)
self.appendMenu(t5, self.snapmenu)
self.appendMenu(t6, self.modify)
self.appendMenu(t7, self.manage)
if ifctools:
self.appendMenu(t8, ifctools)
if flamingo:
self.appendMenu(t9, flamingo)
if fasteners:
self.appendMenu(t10, fasteners)
self.appendMenu(t11, self.utils)
self.appendMenu([t11, t12], nudge)
def loadPreferences(self):
"""Set up preferences pages"""
def QT_TRANSLATE_NOOP(context, text):
return text
t1 = QT_TRANSLATE_NOOP("QObject", "Arch")
t2 = QT_TRANSLATE_NOOP("QObject", "Draft")
FreeCADGui.addPreferencePage(":/ui/preferences-arch.ui", t1)
FreeCADGui.addPreferencePage(":/ui/preferences-archdefaults.ui", t1)
if hasattr(FreeCADGui, "draftToolBar"):
if not hasattr(FreeCADGui.draftToolBar, "loadedArchPreferences"):
FreeCADGui.addPreferencePage(":/ui/preferences-arch.ui", QT_TRANSLATE_NOOP("QObject", "Arch"))
FreeCADGui.addPreferencePage(":/ui/preferences-archdefaults.ui", QT_TRANSLATE_NOOP("QObject", "Arch"))
FreeCADGui.draftToolBar.loadedArchPreferences = True
if not hasattr(FreeCADGui.draftToolBar, "loadedPreferences"):
from draftutils import params
params._param_observer_start()
FreeCADGui.addPreferencePage(":/ui/preferences-draft.ui", QT_TRANSLATE_NOOP("QObject", "Draft"))
FreeCADGui.addPreferencePage(":/ui/preferences-draftinterface.ui", QT_TRANSLATE_NOOP("QObject", "Draft"))
FreeCADGui.addPreferencePage(":/ui/preferences-draftsnap.ui", QT_TRANSLATE_NOOP("QObject", "Draft"))
FreeCADGui.addPreferencePage(":/ui/preferences-draftvisual.ui", QT_TRANSLATE_NOOP("QObject", "Draft"))
FreeCADGui.addPreferencePage(":/ui/preferences-drafttexts.ui", QT_TRANSLATE_NOOP("QObject", "Draft"))
FreeCADGui.draftToolBar.loadedPreferences = True
if hasattr(FreeCADGui.draftToolBar, "loadedPreferences"):
return
from draftutils import params
params._param_observer_start()
FreeCADGui.addPreferencePage(":/ui/preferences-draft.ui", t2)
FreeCADGui.addPreferencePage(":/ui/preferences-draftinterface.ui", t2)
FreeCADGui.addPreferencePage(":/ui/preferences-draftsnap.ui", t2)
FreeCADGui.addPreferencePage(":/ui/preferences-draftvisual.ui", t2)
FreeCADGui.addPreferencePage(":/ui/preferences-drafttexts.ui", t2)
FreeCADGui.draftToolBar.loadedPreferences = True
FreeCAD.Console.PrintLog('Loading Arch workbench, done.\n')
def setupMultipleObjectSelection(self):
import BimSelect
if hasattr(FreeCADGui, "addDocumentObserver") and not hasattr(
self, "BimSelectObserver"
):
self.BimSelectObserver = BimSelect.Setup()
FreeCADGui.addDocumentObserver(self.BimSelectObserver)
def Activated(self):
"""When entering the workbench."""
import WorkingPlane
from DraftGui import todo
import BimStatusBar
from nativeifc import ifc_observer
PARAMS = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/BIM")
if hasattr(FreeCADGui, "draftToolBar"):
FreeCADGui.draftToolBar.Activated()
if hasattr(FreeCADGui, "Snapper"):
FreeCADGui.Snapper.show()
import WorkingPlane
WorkingPlane._view_observer_start()
FreeCAD.Console.PrintLog("Arch workbench activated.\n")
if hasattr(WorkingPlane, "_view_observer_start"):
WorkingPlane._view_observer_start()
if PARAMS.GetBool("FirstTime", True) and (not hasattr(FreeCAD, "TestEnvironment")):
todo.delay(FreeCADGui.runCommand, "BIM_Welcome")
todo.delay(BimStatusBar.setStatusIcons, True)
FreeCADGui.Control.clearTaskWatcher()
class BimWatcher:
def __init__(self, cmds, name, invert=False):
self.commands = cmds
self.title = name
self.invert = invert
def shouldShow(self):
if self.invert:
return (FreeCAD.ActiveDocument != None) and (
FreeCADGui.Selection.getSelection() != []
)
else:
return (FreeCAD.ActiveDocument != None) and (
not FreeCADGui.Selection.getSelection()
)
FreeCADGui.Control.addTaskWatcher(
[
BimWatcher(self.draftingtools + self.annotationtools, "2D geometry"),
BimWatcher(self.bimtools, "3D/BIM geometry"),
BimWatcher(self.modify, "Modify", invert=True),
]
)
# restore views widget if needed
if PARAMS.GetBool("RestoreBimViews", True):
from bimcommands import BimViews
w = BimViews.findWidget()
if not w:
FreeCADGui.runCommand("BIM_Views")
else:
w.show()
w.toggleViewAction().setVisible(True)
self.setupMultipleObjectSelection()
# add NativeIFC document observer
ifc_observer.add_observer()
# adding a Help menu manipulator
# https://github.com/FreeCAD/FreeCAD/pull/10933
class BIM_WBManipulator:
def modifyMenuBar(self):
return [
{"insert": "BIM_Examples", "menuItem": "Std_ReportBug", "after": ""},
{"insert": "BIM_Tutorial", "menuItem": "Std_ReportBug", "after": ""},
{"insert": "BIM_Help", "menuItem": "Std_ReportBug", "after": ""},
{"insert": "BIM_Welcome", "menuItem": "Std_ReportBug", "after": ""},
]
if not hasattr(Gui, "BIM_WBManipulator"):
Gui.BIM_WBManipulator = BIM_WBManipulator()
Gui.addWorkbenchManipulator(Gui.BIM_WBManipulator)
Log("BIM workbench activated\n")
def Deactivated(self):
"""When leaving the workbench."""
from DraftGui import todo
import BimStatusBar
from bimcommands import BimViews
import WorkingPlane
from nativeifc import ifc_observer
PARAMS = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/BIM")
if hasattr(self, "BimSelectObserver"):
FreeCADGui.removeDocumentObserver(self.BimSelectObserver)
del self.BimSelectObserver
if hasattr(FreeCADGui, "draftToolBar"):
FreeCADGui.draftToolBar.Deactivated()
if hasattr(FreeCADGui, "Snapper"):
FreeCADGui.Snapper.hide()
import WorkingPlane
WorkingPlane._view_observer_stop()
FreeCAD.Console.PrintLog("Arch workbench deactivated.\n")
if hasattr(WorkingPlane, "_view_observer_stop"):
WorkingPlane._view_observer_stop()
# print("Deactivating status icon")
todo.delay(BimStatusBar.setStatusIcons, False)
FreeCADGui.Control.clearTaskWatcher()
# store views widget state and vertical size
w = BimViews.findWidget()
PARAMS.SetBool("RestoreBimViews", bool(w))
if w:
PARAMS.SetInt("BimViewsSize", w.height())
w.hide()
w.toggleViewAction().setVisible(False)
# add NativeIFC document observer
ifc_observer.remove_observer()
# Ifc stuff
try:
from nativeifc import ifc_status
ifc_status.toggle_lock(False)
except:
pass
# remove manipulator
if hasattr(Gui, "BIM_WBManipulator"):
Gui.removeWorkbenchManipulator(Gui.BIM_WBManipulator)
del Gui.BIM_WBManipulator
Gui.activeWorkbench().reloadActive()
Log("BIM workbench deactivated\n")
def ContextMenu(self, recipient):
"""Define an optional custom context menu."""
self.appendContextMenu("Utilities", self.draft_context_commands)
import DraftTools
translate = FreeCAD.Qt.translate
if recipient == "Tree":
groups = False
ungroupable = False
for o in FreeCADGui.Selection.getSelection():
if o.isDerivedFrom("App::DocumentObjectGroup") or o.hasExtension(
"App::GroupExtension"
):
groups = True
else:
groups = False
break
for o in FreeCADGui.Selection.getSelection():
for parent in o.InList:
if parent.isDerivedFrom(
"App::DocumentObjectGroup"
) or parent.hasExtension("App::GroupExtension"):
if o in parent.Group:
ungroupable = True
else:
ungroupable = False
break
if groups:
self.appendContextMenu("", ["Draft_SelectGroup"])
if ungroupable:
self.appendContextMenu("", ["BIM_Ungroup"])
if (len(FreeCADGui.Selection.getSelection()) == 1) and (
FreeCADGui.Selection.getSelection()[0].Name == "Trash"
):
self.appendContextMenu("", ["BIM_EmptyTrash"])
elif recipient == "View":
self.appendContextMenu(translate("BIM", "Snapping"), self.snapmenu)
if FreeCADGui.Selection.getSelection():
if FreeCADGui.Selection.getSelection()[0].Name != "Trash":
self.appendContextMenu("", ["BIM_Trash"])
self.appendContextMenu("", ["Draft_AddConstruction", "Draft_AddToGroup"])
allclones = False
for obj in FreeCADGui.Selection.getSelection():
if hasattr(obj, "CloneOf") and obj.CloneOf:
allclones = True
else:
allclones = False
break
if allclones:
self.appendContextMenu("", ["BIM_ResetCloneColors"])
if len(FreeCADGui.Selection.getSelection()) == 1:
obj = FreeCADGui.Selection.getSelection()[0]
if hasattr(obj, "Group"):
if obj.getTypeIdOfProperty("Group") == "App::PropertyLinkList":
self.appendContextMenu("", ["BIM_Reorder"])
if obj.isDerivedFrom("TechDraw::DrawView"):
self.appendContextMenu("", ["BIM_MoveView"])
def GetClassName(self):
"""Type of workbench."""
return "Gui::PythonWorkbench"
FreeCADGui.addWorkbench(ArchWorkbench)
FreeCADGui.addWorkbench(BIMWorkbench)
# Preference pages for importing and exporting various file formats
# are independent of the loading of the workbench and can be loaded at startup
import Arch_rc
from PySide.QtCore import QT_TRANSLATE_NOOP
FreeCADGui.addPreferencePage(":/ui/preferences-ifc.ui", QT_TRANSLATE_NOOP("QObject", "Import-Export"))
FreeCADGui.addPreferencePage(":/ui/preferences-ifc-export.ui", QT_TRANSLATE_NOOP("QObject", "Import-Export"))
FreeCADGui.addPreferencePage(":/ui/preferences-dae.ui", QT_TRANSLATE_NOOP("QObject", "Import-Export"))
def QT_TRANSLATE_NOOP(context, text):
return text
t = QT_TRANSLATE_NOOP("QObject", "Import-Export")
FreeCADGui.addPreferencePage(":/ui/preferences-ifc.ui", t)
FreeCADGui.addPreferencePage(":/ui/preferences-ifc-export.ui", t)
FreeCADGui.addPreferencePage(":/ui/preferences-dae.ui", t)
FreeCADGui.addPreferencePage(":/ui/preferencesNativeIFC.ui", t)
# Add unit tests
FreeCAD.__unit_test__ += ["TestArch"]
# The NativeIFC tests require internet connection and file download
# FreeCAD.__unit_test__ += ["nativeifc.ifc_selftest"]

View File

@@ -105,7 +105,7 @@ class CutPlaneTaskPanel:
def getStandardButtons(self):
from PySide import QtGui
return int(QtGui.QDialogButtonBox.Ok|QtGui.QDialogButtonBox.Cancel)
return QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel
def previewCutVolume(self, i):
import Arch