From a8c6f1b647339fce74a4735f0570f7f164b85d95 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Fri, 11 May 2018 23:14:41 -0300 Subject: [PATCH] Arch: Added convenience function ArchComponent.convertOldComponents to convert the Role property to IfcRole --- src/Mod/Arch/ArchComponent.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Mod/Arch/ArchComponent.py b/src/Mod/Arch/ArchComponent.py index 34bf68855b..ff25f40fad 100644 --- a/src/Mod/Arch/ArchComponent.py +++ b/src/Mod/Arch/ArchComponent.py @@ -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