import maya.cmds as cmds
import json
def create_hierarchy(parent, data):
for item in data:
name = None
if cmds.objExists(item["name"]):
name = item["name"]
else:
null = cmds.group(empty=True, name=item["name"])
if parent:
cmds.parent(null, parent)
if "children" in item and item["children"]:
create_hierarchy(null, item["children"])
def main():
param_path = r"C:/users/BT/Desktop/layers_hierarchy.json"
with open(param_path, "r") as read_file:
data = json.load(read_file)
create_hierarchy(None, data)
main()