Building.py
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 import Cell,FreeCAD,FreeCADGui
00025 from PyQt4 import QtCore
00026
00027 __title__="FreeCAD Building"
00028 __author__ = "Yorik van Havre"
00029 __url__ = "http://free-cad.sourceforge.net"
00030
00031 def makeBuilding(objectslist,join=False,name="Building"):
00032 '''makeBuilding(objectslist,[joinmode]): creates a building including the
00033 objects from the given list. If joinmode is True, components will be joined.'''
00034 obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
00035 Building(obj)
00036 ViewProviderBuilding(obj.ViewObject)
00037 obj.Components = objectslist
00038 for comp in obj.Components:
00039 comp.ViewObject.hide()
00040 obj.JoinMode = join
00041 return obj
00042
00043 class CommandBuilding:
00044 "the Arch Building command definition"
00045 def GetResources(self):
00046 return {'Pixmap' : 'Arch_Building',
00047 'MenuText': QtCore.QT_TRANSLATE_NOOP("Arch_Building","Building"),
00048 'Accel': "B, U",
00049 'ToolTip': QtCore.QT_TRANSLATE_NOOP("Arch_Building","Creates a building object including selected objects.")}
00050
00051 def Activated(self):
00052 FreeCAD.ActiveDocument.openTransaction("Building")
00053 makeBuilding(FreeCADGui.Selection.getSelection())
00054 FreeCAD.ActiveDocument.commitTransaction()
00055
00056 class Building(Cell.Cell):
00057 "The Building object"
00058 def __init__(self,obj):
00059 Cell.Cell.__init__(self,obj)
00060 self.Type = "Building"
00061
00062 class ViewProviderBuilding(Cell.ViewProviderCell):
00063 "A View Provider for the Building object"
00064 def __init__(self,vobj):
00065 Cell.ViewProviderCell.__init__(self,vobj)
00066
00067 def getIcon(self):
00068 return """
00069 /* XPM */
00070 static char * Arch_Building_xpm[] = {
00071 "16 16 9 1",
00072 " c None",
00073 ". c #160E0A",
00074 "+ c #C10007",
00075 "@ c #FF0006",
00076 "# c #8F3F00",
00077 "$ c #5E5F5D",
00078 "% c #7F817E",
00079 "& c #A0A29F",
00080 "* c #F4F6F3",
00081 " ",
00082 " ........ ",
00083 " ..#@@@@@. ",
00084 " .&&.+@@@@@. ",
00085 " .&**%.@@@@@+. ",
00086 " .&****..@@@+...",
00087 ".%******.##..$$.",
00088 ".&******&.$&**%.",
00089 ".%*...$**.****% ",
00090 ".%*..#.**.****% ",
00091 " %*..#.**.****$ ",
00092 " $*..#.**.***$. ",
00093 " $*..#$**.**.. ",
00094 " .$...$**.&. ",
00095 " . .$%.. ",
00096 " .. "};
00097 """
00098
00099 FreeCADGui.addCommand('Arch_Building',CommandBuilding())