Arch: Added convenience function ArchComponent.convertOldComponents to convert the Role property to IfcRole
This commit is contained in:
@@ -93,6 +93,24 @@ else:
|
||||
# This module provides the base Arch component class, that
|
||||
# is shared by all of the Arch BIM objects
|
||||
|
||||
def convertOldComponents(objs=[]):
|
||||
"""converts Arch Objects with a Role property to the new IfcRole.
|
||||
if no object is given, all object sof the active document are converted"""
|
||||
if not objs:
|
||||
objs = FreeCAD.ActiveDocument.Objects
|
||||
if not isinstance(objs,list):
|
||||
objs = [objs]
|
||||
for obj in objs:
|
||||
if "Role" in obj.PropertiesList:
|
||||
obj.addProperty("App::PropertyEnumeration","IfcRole","Component",QT_TRANSLATE_NOOP("App::Property","The role of this object"))
|
||||
obj.IfcRole = IfcRoles
|
||||
if obj.Role in IfcRoles:
|
||||
obj.IfcRole = obj.Role
|
||||
else:
|
||||
FreeCAD.Console.PrintMessage("Role "+obj.Role+" cannot be mapped for object "+obj.Label+"\n")
|
||||
obj.removeProperty("Role")
|
||||
|
||||
|
||||
def addToComponent(compobject,addobject,mod=None):
|
||||
'''addToComponent(compobject,addobject,mod): adds addobject
|
||||
to the given component. Default is in "Additions", "Objects" or
|
||||
|
||||
Reference in New Issue
Block a user