Arch groups now use DocumentObjectGroupPython
This commit is contained in:
parent
41523af62c
commit
05823711ac
|
@ -21,7 +21,7 @@
|
|||
#* *
|
||||
#***************************************************************************
|
||||
|
||||
import ArchCell,FreeCAD,FreeCADGui,Draft,ArchCommands
|
||||
import FreeCAD,FreeCADGui,Draft,ArchCommands
|
||||
from PyQt4 import QtCore
|
||||
|
||||
__title__="FreeCAD Building"
|
||||
|
@ -31,14 +31,11 @@ __url__ = "http://free-cad.sourceforge.net"
|
|||
def makeBuilding(objectslist=None,join=False,name="Building"):
|
||||
'''makeBuilding(objectslist,[joinmode]): creates a building including the
|
||||
objects from the given list. If joinmode is True, components will be joined.'''
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
obj = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroupPython",name)
|
||||
_Building(obj)
|
||||
_ViewProviderBuilding(obj.ViewObject)
|
||||
if objectslist:
|
||||
obj.Components = objectslist
|
||||
for comp in obj.Components:
|
||||
comp.ViewObject.hide()
|
||||
obj.JoinMode = join
|
||||
obj.Group = objectslist
|
||||
return obj
|
||||
|
||||
class _CommandBuilding:
|
||||
|
@ -66,18 +63,32 @@ class _CommandBuilding:
|
|||
FreeCAD.ActiveDocument.commitTransaction()
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
|
||||
class _Building(ArchCell._Cell):
|
||||
class _Building:
|
||||
"The Building object"
|
||||
def __init__(self,obj):
|
||||
ArchCell._Cell.__init__(self,obj)
|
||||
self.Type = "Building"
|
||||
obj.Proxy = self
|
||||
|
||||
def execute(self,obj):
|
||||
pass
|
||||
|
||||
class _ViewProviderBuilding(ArchCell._ViewProviderCell):
|
||||
def onChanged(self,obj,prop):
|
||||
pass
|
||||
|
||||
class _ViewProviderBuilding:
|
||||
"A View Provider for the Building object"
|
||||
def __init__(self,vobj):
|
||||
ArchCell._ViewProviderCell.__init__(self,vobj)
|
||||
vobj.Proxy = self
|
||||
|
||||
def getIcon(self):
|
||||
return ":/icons/Arch_Building_Tree.svg"
|
||||
|
||||
def attach(self,vobj):
|
||||
self.Object = vobj.Object
|
||||
return
|
||||
|
||||
def claimChildren(self):
|
||||
return self.Object.Group
|
||||
|
||||
|
||||
FreeCADGui.addCommand('Arch_Building',_CommandBuilding())
|
||||
|
|
|
@ -39,12 +39,18 @@ def addComponents(objectsList,host):
|
|||
if not isinstance(objectsList,list):
|
||||
objectsList = [objectsList]
|
||||
tp = Draft.getType(host)
|
||||
if tp in ["Cell","Floor","Building","Site"]:
|
||||
if tp in ["Cell"]:
|
||||
c = host.Components
|
||||
for o in objectsList:
|
||||
if not o in c:
|
||||
c.append(o)
|
||||
host.Components = c
|
||||
elif tp in ["Floor","Building","Site"]:
|
||||
c = host.Group
|
||||
for o in objectsList:
|
||||
if not o in c:
|
||||
c.append(o)
|
||||
host.Group = c
|
||||
elif tp in ["Wall","Structure"]:
|
||||
a = host.Additions
|
||||
for o in objectsList:
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#* *
|
||||
#***************************************************************************
|
||||
|
||||
import ArchCell,FreeCAD,FreeCADGui,Draft,ArchCommands
|
||||
import FreeCAD,FreeCADGui,Draft,ArchCommands
|
||||
from PyQt4 import QtCore
|
||||
|
||||
__title__="FreeCAD Arch Floor"
|
||||
|
@ -32,14 +32,11 @@ def makeFloor(objectslist=None,join=True,name="Floor"):
|
|||
'''makeFloor(objectslist,[joinmode]): creates a floor including the
|
||||
objects from the given list. If joinmode is False, components will
|
||||
not be joined.'''
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
obj = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroupPython",name)
|
||||
_Floor(obj)
|
||||
_ViewProviderFloor(obj.ViewObject)
|
||||
if objectslist:
|
||||
obj.Components = objectslist
|
||||
for comp in obj.Components:
|
||||
comp.ViewObject.hide()
|
||||
obj.JoinMode = join
|
||||
obj.Group = objectslist
|
||||
return obj
|
||||
|
||||
class _CommandFloor:
|
||||
|
@ -67,20 +64,34 @@ class _CommandFloor:
|
|||
FreeCAD.ActiveDocument.commitTransaction()
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
|
||||
class _Floor(ArchCell._Cell):
|
||||
class _Floor:
|
||||
"The Cell object"
|
||||
def __init__(self,obj):
|
||||
ArchCell._Cell.__init__(self,obj)
|
||||
obj.addProperty("App::PropertyLength","Height","Base",
|
||||
"The height of this floor")
|
||||
self.Type = "Floor"
|
||||
obj.Proxy = self
|
||||
|
||||
def execute(self,obj):
|
||||
pass
|
||||
|
||||
class _ViewProviderFloor(ArchCell._ViewProviderCell):
|
||||
def onChanged(self,obj,prop):
|
||||
pass
|
||||
|
||||
|
||||
class _ViewProviderFloor:
|
||||
"A View Provider for the Cell object"
|
||||
def __init__(self,vobj):
|
||||
ArchCell._ViewProviderCell.__init__(self,vobj)
|
||||
vobj.Proxy = self
|
||||
|
||||
def getIcon(self):
|
||||
return ":/icons/Arch_Floor_Tree.svg"
|
||||
|
||||
def attach(self,vobj):
|
||||
self.Object = vobj.Object
|
||||
return
|
||||
|
||||
def claimChildren(self):
|
||||
return self.Object.Group
|
||||
|
||||
FreeCADGui.addCommand('Arch_Floor',_CommandFloor())
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#* *
|
||||
#***************************************************************************
|
||||
|
||||
import ArchCell,FreeCAD,FreeCADGui,Draft,ArchCommands
|
||||
import FreeCAD,FreeCADGui,Draft,ArchCommands
|
||||
from PyQt4 import QtCore
|
||||
|
||||
__title__="FreeCAD Site"
|
||||
|
@ -31,12 +31,11 @@ __url__ = "http://free-cad.sourceforge.net"
|
|||
def makeSite(objectslist=None,name="Site"):
|
||||
'''makeBuilding(objectslist): creates a site including the
|
||||
objects from the given list.'''
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
obj = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroupPython",name)
|
||||
_Site(obj)
|
||||
_ViewProviderSite(obj.ViewObject)
|
||||
if objectslist:
|
||||
obj.Components = objectslist
|
||||
obj.JoinMode = False
|
||||
obj.Group = objectslist
|
||||
return obj
|
||||
|
||||
class _CommandSite:
|
||||
|
@ -64,11 +63,11 @@ class _CommandSite:
|
|||
FreeCAD.ActiveDocument.commitTransaction()
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
|
||||
class _Site(ArchCell._Cell):
|
||||
class _Site:
|
||||
"The Site object"
|
||||
def __init__(self,obj):
|
||||
ArchCell._Cell.__init__(self,obj)
|
||||
self.Type = "Site"
|
||||
obj.Proxy = self
|
||||
|
||||
def execute(self,obj):
|
||||
pass
|
||||
|
@ -76,12 +75,19 @@ class _Site(ArchCell._Cell):
|
|||
def onChanged(self,obj,prop):
|
||||
pass
|
||||
|
||||
class _ViewProviderSite(ArchCell._ViewProviderCell):
|
||||
class _ViewProviderSite:
|
||||
"A View Provider for the Site object"
|
||||
def __init__(self,vobj):
|
||||
ArchCell._ViewProviderCell.__init__(self,vobj)
|
||||
vobj.Proxy = self
|
||||
|
||||
def getIcon(self):
|
||||
return ":/icons/Arch_Site_Tree.svg"
|
||||
|
||||
def attach(self,vobj):
|
||||
self.Object = vobj.Object
|
||||
return
|
||||
|
||||
def claimChildren(self):
|
||||
return self.Object.Group
|
||||
|
||||
FreeCADGui.addCommand('Arch_Site',_CommandSite())
|
||||
|
|
Loading…
Reference in New Issue
Block a user