From 21e1dff25ced926423cb6c0bb5b74326c99c0bcf Mon Sep 17 00:00:00 2001 From: Amritpal Singh Date: Wed, 23 Sep 2020 16:07:00 +0530 Subject: [PATCH] Adopted vocx-fc comment. --- src/Mod/Draft/draftutils/utils.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Mod/Draft/draftutils/utils.py b/src/Mod/Draft/draftutils/utils.py index 81d394d2ce..571eb4957e 100644 --- a/src/Mod/Draft/draftutils/utils.py +++ b/src/Mod/Draft/draftutils/utils.py @@ -526,7 +526,7 @@ def is_clone(obj, objtype, recursive=False): isClone = is_clone -def get_clone_base(obj, strict=False): +def get_clone_base(obj, strict=False, recursive=True): """Return the object cloned by this object, if any. Parameters @@ -539,6 +539,13 @@ def get_clone_base(obj, strict=False): If it is `True`, and this object is not a clone, this function will return `False`. + recursive: bool, optional + It defaults to `True` + If it is `True`, it call recursively to itself to + get base object and if it is `False` then it just + return base object, not call recursively to find + base object. + Returns ------- App::DocumentObject @@ -556,11 +563,14 @@ def get_clone_base(obj, strict=False): It will return `False` if `obj` is not a clone, and `strict` is `True`. """ - if hasattr(obj, "CloneOf"): - if obj.CloneOf: + if hasattr(obj, "CloneOf") and obj.CloneOf: + if recursive: return get_clone_base(obj.CloneOf) + return obj.CloneOf if get_type(obj) == "Clone" and obj.Objects: - return get_clone_base(obj.Objects[0]) + if recursive: + return get_clone_base(obj.Objects[0]) + return obj.Objects[0] if strict: return False return obj