From 12c3a15ff0f4e2d87a91248c134aace712cd04b6 Mon Sep 17 00:00:00 2001 From: Javier Torres Date: Tue, 22 Nov 2022 12:24:33 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=B2=20Override=20IDs=20should=20not=20?= =?UTF-8?q?be=20processed=20twice?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- converter/context.py | 2 ++ converter/instance.py | 5 ++++- converter/shape_path.py | 2 +- figformat/fig2tree.py | 5 ++++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/converter/context.py b/converter/context.py index a730b17..f5cb00a 100644 --- a/converter/context.py +++ b/converter/context.py @@ -80,6 +80,8 @@ def used_fonts(self) -> Dict[Tuple[str, str], Tuple[IO[bytes], str]]: def find_symbol(self, sid: Sequence[int]) -> dict: symbol = self.fig_node(sid) + sid = symbol["guid"] + if not self._component_symbols.get(sid, True): # The symbol is in the component page and has not been converted yet, do it now from . import tree diff --git a/converter/instance.py b/converter/instance.py index 025103e..e585cf3 100644 --- a/converter/instance.py +++ b/converter/instance.py @@ -26,9 +26,12 @@ def convert(fig_instance): else: utils.log_conversion_warning("SYM002", fig_instance, props=unsupported) + # Use always the GUID of the master for the symbolID + # The instance symbolID can refer to the overrideKey instead + fig_master = context.find_symbol(fig_instance["symbolData"]["symbolID"]) obj = SymbolInstance( **base.base_styled(fig_instance), - symbolID=utils.gen_object_id(fig_instance["symbolData"]["symbolID"]), + symbolID=utils.gen_object_id(fig_master["guid"]), overrideValues=sketch_overrides, ) # Replace style diff --git a/converter/shape_path.py b/converter/shape_path.py index 4bbc0bd..091f22b 100644 --- a/converter/shape_path.py +++ b/converter/shape_path.py @@ -164,7 +164,7 @@ def use_segment(i: int) -> int: if unused_segments: regions += [ { - "style": {"fillPaints": []}, + "style": {}, "windingRule": "NONZERO", "loops": reorder_segments( [vector_network["segments"][i] for i in unused_segments] diff --git a/figformat/fig2tree.py b/figformat/fig2tree.py index 771d55a..57b81ce 100644 --- a/figformat/fig2tree.py +++ b/figformat/fig2tree.py @@ -20,6 +20,7 @@ def convert_fig(path: str, output: ZipFile) -> Tuple[dict, Dict[Sequence[int], d # Load all nodes into a map id_map = {} + override_map = {} root = None for node in fig["nodeChanges"]: @@ -28,7 +29,7 @@ def convert_fig(path: str, output: ZipFile) -> Tuple[dict, Dict[Sequence[int], d id_map[node_id] = node if "overrideKey" in node: - id_map[node["overrideKey"]] = node + override_map[node["overrideKey"]] = node if not root: root = node_id @@ -45,6 +46,8 @@ def convert_fig(path: str, output: ZipFile) -> Tuple[dict, Dict[Sequence[int], d for node in id_map.values(): node["children"].sort(key=lambda n: n["parent"]["position"]) + id_map.update(override_map) + return tree, id_map