From 361e88672fc0ec29439b2768aae42f2dfcf6af11 Mon Sep 17 00:00:00 2001 From: Ehsan Iran-Nejad Date: Wed, 21 Dec 2022 15:48:14 -0800 Subject: [PATCH] Fixed super constructor calls --- python3/rhinoscript/selection.py | 3 +++ tools/convert_py2to3.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/python3/rhinoscript/selection.py b/python3/rhinoscript/selection.py index 1dfa13f..8d3e3a4 100755 --- a/python3/rhinoscript/selection.py +++ b/python3/rhinoscript/selection.py @@ -237,6 +237,7 @@ def GetObject(message=None, filter=0, preselect=False, select=False, custom_filt class CustomGetObject(Rhino.Input.Custom.GetObject): def __init__(self, filter_function): + super().__init__() self.m_filter_function = filter_function def CustomGeometryFilter( self, rhino_object, geometry, component_index ): rc = True @@ -268,6 +269,7 @@ def CustomGeometryFilter( self, rhino_object, geometry, component_index ): class __CustomGetObjectEx(Rhino.Input.Custom.GetObject): def __init__(self, allowable_geometry): + super().__init__() self.m_allowable = allowable_geometry def CustomGeometryFilter(self, rhino_object, geometry, component_index): for id in self.m_allowable: @@ -406,6 +408,7 @@ def GetObjects(message=None, filter=0, group=True, preselect=False, select=False objects = rhutil.coerceguidlist(objects) class CustomGetObject(Rhino.Input.Custom.GetObject): def __init__(self, filter_function): + super().__init__() self.m_filter_function = filter_function def CustomGeometryFilter( self, rhino_object, geometry, component_index ): if objects and not rhino_object.Id in objects: return False diff --git a/tools/convert_py2to3.py b/tools/convert_py2to3.py index c72e0cc..6ad7e33 100644 --- a/tools/convert_py2to3.py +++ b/tools/convert_py2to3.py @@ -386,6 +386,34 @@ def selection_fixes(item): sf.replace("def __FilterHelper(filter):", "def __FilterHelper(input_filter):") sf.replace("if filter &", "if input_filter &") + sf.replace( + """ + class CustomGetObject(Rhino.Input.Custom.GetObject): + def __init__(self, filter_function): + self.m_filter_function = filter_function +""".strip(), + """ + class CustomGetObject(Rhino.Input.Custom.GetObject): + def __init__(self, filter_function): + super().__init__() + self.m_filter_function = filter_function +""".strip(), + ) + + sf.replace( + """ +class __CustomGetObjectEx(Rhino.Input.Custom.GetObject): + def __init__(self, allowable_geometry): + self.m_allowable = allowable_geometry +""".strip(), + """ +class __CustomGetObjectEx(Rhino.Input.Custom.GetObject): + def __init__(self, allowable_geometry): + super().__init__() + self.m_allowable = allowable_geometry +""".strip(), + ) + def surface_fixes(item): """Fix misc items in rhinoscript/surface.py"""