Skip to content

Commit

Permalink
🌲 Override IDs should not be processed twice
Browse files Browse the repository at this point in the history
  • Loading branch information
javitonino committed Nov 22, 2022
1 parent a5f9ad9 commit 12c3a15
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions converter/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion converter/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion converter/shape_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
5 changes: 4 additions & 1 deletion figformat/fig2tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]:
Expand All @@ -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
Expand All @@ -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


Expand Down

0 comments on commit 12c3a15

Please sign in to comment.