def removeFromComponent(compobject, subobject): '''removeFromComponent(compobject,subobject): subtracts subobject from the given component. If the subobject is already part of the component (as addition, subtraction, etc... it is removed. Otherwise, it is added as a subtraction.''' if compobject == subobject: return found = False attribs = [ "Additions", "Subtractions", "Objects", "Components", "Base", "Axes", "Fixtures", "Group" ] for a in attribs: if hasattr(compobject, a): if a == "Base": if subobject == getattr(compobject, a): setattr(compobject, a, None) subobject.ViewObject.show() found = True else: if subobject in getattr(compobject, a): l = getattr(compobject, a) l.remove(subobject) setattr(compobject, a, l) subobject.ViewObject.show() if Draft.getType(compobject) == "PanelSheet": subobject.Placement.move(compobject.Placement.Base) found = True if not found: if hasattr(compobject, "Subtractions"): l = compobject.Subtractions l.append(subobject) compobject.Subtractions = l if (Draft.getType(subobject) != "Window") and (not Draft.isClone( subobject, "Window", True)): ArchCommands.setAsSubcomponent(subobject)
def removeFromComponent(compobject, subobject): """removeFromComponent(compobject,subobject): subtracts subobject from the given component. If the subobject is already part of the component (as addition, subtraction, etc... it is removed. Otherwise, it is added as a subtraction.""" if compobject == subobject: return found = False attribs = ["Additions", "Subtractions", "Objects", "Components", "Base", "Axes", "Fixtures"] for a in attribs: if hasattr(compobject, a): if a == "Base": if subobject == getattr(compobject, a): setattr(compobject, a, None) subobject.ViewObject.show() found = True else: if subobject in getattr(compobject, a): l = getattr(compobject, a) l.remove(subobject) setattr(compobject, a, l) subobject.ViewObject.show() found = True if not found: if hasattr(compobject, "Subtractions"): l = compobject.Subtractions l.append(subobject) compobject.Subtractions = l if (Draft.getType(subobject) != "Window") and (not Draft.isClone(subobject, "Window", True)): ArchCommands.setAsSubcomponent(subobject)