From 22ddb58cca40a320af68688e073cf98bb9e73fbc Mon Sep 17 00:00:00 2001 From: Toke Stuart Jepsen Date: Mon, 30 Jan 2023 17:20:58 +0000 Subject: [PATCH] Refactor to lib --- openpype/hosts/maya/api/lib.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/openpype/hosts/maya/api/lib.py b/openpype/hosts/maya/api/lib.py index dd5da275e8..65f39270f5 100644 --- a/openpype/hosts/maya/api/lib.py +++ b/openpype/hosts/maya/api/lib.py @@ -3446,3 +3446,17 @@ def iter_visible_nodes_in_range(nodes, start, end): def get_attribute_input(attr): connections = cmds.listConnections(attr, plugs=True, destination=False) return connections[0] if connections else None + + +def write_xgen_file(data, filepath): + lines = [] + with open(filepath, "r") as f: + for line in [line.rstrip() for line in f]: + for key, value in data.items(): + if line.startswith("\t{}".format(key)): + line = "\t{}\t\t{}".format(key, value) + + lines.append(line) + + with open(filepath, "w") as f: + f.write("\n".join(lines))