Beispiel #1
0
def gear_Mirror_ExportRules_OnClicked():

    model = PPG.Inspected(0).Model
    cnx_grid = PPG.CnxGridHidden.Value
    connections = par.getDictFromGridData(cnx_grid)

    # Parse XML file --------------------------------
    path = uit.fileBrowser("Export Mirroring Templates", xsi.ActiveProject2.OriginPath, model.Name, ["xml"], True)
    if not path:
        return

    # Create Root structure
    xml_root = etree.Element("mirrorTemplates", version="1.0", comment="Mapping rules for gear_MirrorAnimation plugin")

    # Infos
    xml_infos = etree.SubElement(xml_root, "infos", model=model.Name, count=str(len(connections)))
    xml_cnxMap = etree.SubElement(xml_root, "mirrorCnxMap")

    # Export CnxMap
    keys = connections.keys()
    keys.sort()

    for k in keys:
        etree.SubElement(xml_cnxMap, "cnx", map_from=k, map_to=connections[k][0], inv=str(connections[k][1]))

    xmldom.indent(xml_root)
    tree = etree.ElementTree(xml_root)
    tree.write(path)
Beispiel #2
0
def gear_Mirror_ExportRules_OnClicked():

    model = PPG.Inspected(0).Model
    cnx_grid = PPG.CnxGridHidden.Value
    connections = par.getDictFromGridData(cnx_grid)

    # Parse XML file --------------------------------
    path = uit.fileBrowser("Export Mirroring Templates", xsi.ActiveProject2.OriginPath, model.Name, ["xml"], True)
    if not path:
        return

    # Create Root structure
    xml_root = etree.Element("mirrorTemplates", version="1.0", comment="Mapping rules for gear_MirrorAnimation plugin")


    # Infos
    xml_infos = etree.SubElement(xml_root, "infos", model=model.Name, count=str(len(connections)))
    xml_cnxMap = etree.SubElement(xml_root, "mirrorCnxMap")

    # Export CnxMap
    keys = connections.keys()
    keys.sort()

    for k in keys:
        etree.SubElement(xml_cnxMap, "cnx", map_from=k, map_to=connections[k][0], inv=str(connections[k][1]))

    xmldom.indent(root)
    tree = etree.ElementTree(xml_root)
    tree.write(path)
Beispiel #3
0
def gear_ImportEnvelope_Execute():

    if not xsi.Selection.Count:
        gear.log("No selection", gear.sev_error)
        return

    # -----------------------------------------------------
    # Getting the file path
    path = uit.fileBrowser("Import Envelope", xsi.ActiveProject2.OriginPath, "", ["xml"], False)
    if not path:
        return

    # -----------------------------------------------------
    xml_objs = io.getObjectDefinitions(path, xsi.Selection, True)
    if not xml_objs:
        return

    # -----------------------------------------------------
    for sel in xsi.Selection:

        if sel.Type in ["pntSubComponent"]:
            obj = sel.SubComponent.Parent3DObject
            pnt_selection = sel.SubComponent.ElementArray
        else:
            obj = sel
            pnt_selection = None

        if obj.Name not in xml_objs.keys():
            continue

        io.importEnvelope(xml_objs[obj.Name], obj, pnt_selection)
Beispiel #4
0
def gear_ImportSkin_Execute():

    if not xsi.Selection.Count:
        gear.log("No selection", gear.sev_error)
        return

    # -----------------------------------------------------
    # Getting the file path
    path = uit.fileBrowser("Import Skin", xsi.ActiveProject2.OriginPath, "",
                           ["xml"], False)
    if not path:
        return

    # -----------------------------------------------------
    xml_objs = io.getObjectDefinitions(path, xsi.Selection, True)
    if not xml_objs:
        return

    # -----------------------------------------------------
    for obj in xsi.Selection:

        if obj.Name not in xml_objs.keys():
            continue

        io.importSkin(xml_objs[obj.Name], obj)
Beispiel #5
0
def gear_ImportEnvelope_Execute():

    if not xsi.Selection.Count:
        gear.log("No selection", gear.sev_error)
        return

    # -----------------------------------------------------
    # Getting the file path
    path = uit.fileBrowser("Import Envelope", xsi.ActiveProject2.OriginPath,
                           "", ["xml"], False)
    if not path:
        return

    # -----------------------------------------------------
    xml_objs = io.getObjectDefinitions(path, xsi.Selection, True)
    if not xml_objs:
        return

    # -----------------------------------------------------
    for sel in xsi.Selection:

        if sel.Type in ["pntSubComponent"]:
            obj = sel.SubComponent.Parent3DObject
            pnt_selection = sel.SubComponent.ElementArray
        else:
            obj = sel
            pnt_selection = None

        if obj.Name not in xml_objs.keys():
            continue

        io.importEnvelope(xml_objs[obj.Name], obj, pnt_selection)
Beispiel #6
0
def gear_ImportGuide_Execute():

    path = uit.fileBrowser("Import Guide", xsi.ActiveProject2.OriginPath, "", ["xml"], False)
    if not path:
        return

    rg = RigGuide()
    rg.importFromXml(path)
Beispiel #7
0
def gear_BuildFromFile_Execute():

    path = uit.fileBrowser("Build From File", TEMPLATE_PATH, "", ["xml"], False)
    if not path:
        return

    # Build
    rig = Rig()
    rig.buildFromFile(path)

    return
Beispiel #8
0
def gear_ExportEnvelope_Execute():

    if not xsi.Selection.Count:
        gear.log("No selection", gear.sev_error)
        return

    # -----------------------------------------------------
    # Getting the file path
    path = uit.fileBrowser("Export Envelope", xsi.ActiveProject2.OriginPath, xsi.Selection(0).Model.Name+"_skin.xml", ["xml"], True)
    if not path:
        return

    io.exportEnvelope(path, xsi.Selection, False)
Beispiel #9
0
def gear_ExportObject_Execute():

    if not xsi.Selection.Count:
        gear.log("No selection", gear.sev_error)
        return

    # -----------------------------------------------------
    # Getting the file path
    path = uit.fileBrowser("Export Object", xsi.ActiveProject2.OriginPath, xsi.Selection(0).Name+"_skin.xml", ["xml"], True)
    if not path:
        return

    xsixmldom.resetOptions()
    xObject = xsixmldom.getObject(xsi.Selection(0))
    xObject.save(path)
Beispiel #10
0
def gear_ExportEnvelope_Execute():

    if not xsi.Selection.Count:
        gear.log("No selection", gear.sev_error)
        return

    # -----------------------------------------------------
    # Getting the file path
    path = uit.fileBrowser("Export Envelope", xsi.ActiveProject2.OriginPath,
                           xsi.Selection(0).Model.Name + "_skin.xml", ["xml"],
                           True)
    if not path:
        return

    io.exportEnvelope(path, xsi.Selection, False)
Beispiel #11
0
def gear_ExportObject_Execute():

    if not xsi.Selection.Count:
        gear.log("No selection", gear.sev_error)
        return

    # -----------------------------------------------------
    # Getting the file path
    path = uit.fileBrowser("Export Object", xsi.ActiveProject2.OriginPath,
                           xsi.Selection(0).Name + "_skin.xml", ["xml"], True)
    if not path:
        return

    xsixmldom.resetOptions()
    xObject = xsixmldom.getObject(xsi.Selection(0))
    xObject.save(path)
Beispiel #12
0
def gear_Mirror_ImportRules_OnClicked():

    cnx_grid = PPG.CnxGridHidden.Value

    # Parse XML file
    path = uit.fileBrowser("Import Mirroring Templates", xsi.ActiveProject2.OriginPath, "", ["xml"], False)
    if not path:
        return

    tree = etree.parse(path)
    root = tree.getroot()

    # Create Dictionary
    connections = {}
    for xml_cnx in root.findall("mirrorCnxMap/cnx"):
        connections[xml_cnx.get("map_to")] = [xml_cnx.get("map_from"), xml_cnx.get("inv")]

    par.setDataGridFromDict(cnx_grid, connections)
    PPG.Count.Value = len(connections)
Beispiel #13
0
def gear_Mirror_ImportRules_OnClicked():

    cnx_grid = PPG.CnxGridHidden.Value

    # Parse XML file 
    path = uit.fileBrowser("Import Mirroring Templates", xsi.ActiveProject2.OriginPath, "", ["xml"], False)
    if not path:
        return

    tree = etree.parse(path)
    root = tree.getroot()

    # Create Dictionary
    connections = {}
    for xml_cnx in root.findall("mirrorCnxMap/cnx"):
        connections[cnx.get("map_to")] = [xml_cnx.get("map_from"), xml_cnx.get("inv")]

    par.setDataGridFromDict(cnx_grid, connections)
    PPG.Count.Value = len(connections)
Beispiel #14
0
def gear_ExportGuide_Execute():

    if not xsi.Selection.Count:
        xsi.LogMessage("Select an object from the guide to export", c.siError)
        return

    if xsi.Selection(0).Type == "#model":
        model = xsi.Selection(0)
    else:
        model = xsi.Selection(0).Model

    options = model.Properties("options")
    if not options:
        gear.log("Invalid selection", gear.sev_error)
        return

    path = uit.fileBrowser("Export Guide", xsi.ActiveProject2.OriginPath, model.Name, ["xml"], True)
    if not path:
        return

    rg = RigGuide()
    rg.exportToXml(xsi.Selection(0), path)
Beispiel #15
0
def gear_GuideToolsUI_export_OnClicked():

    if not xsi.Selection.Count:
        xsi.LogMessage("Select an object from the guide to export", c.siError)
        return

    if xsi.Selection(0).Type == "#model":
        model = xsi.Selection(0)
    else:
        model = xsi.Selection(0).Model

    options = model.Properties("options")
    if not options:
        gear.log("Invalid selection", gear.sev_error)
        return

    path = uit.fileBrowser("Export Guide", TEMPLATE_PATH, model.Name, ["xml"], True)
    if not path:
        return

    rg = RigGuide()
    rg.exportToXml(xsi.Selection(0), path)

    gear_GuideToolsUI_OnInit()
Beispiel #16
0
def gear_ImportSkin_Execute():

    if not xsi.Selection.Count:
        gear.log("No selection", gear.sev_error)
        return

    # -----------------------------------------------------
    # Getting the file path
    path = uit.fileBrowser("Import Skin", xsi.ActiveProject2.OriginPath, "", ["xml"], False)
    if not path:
        return

    # -----------------------------------------------------
    xml_objs = io.getObjectDefinitions(path, xsi.Selection, True)
    if not xml_objs:
        return

    # -----------------------------------------------------
    for obj in xsi.Selection:

        if obj.Name not in xml_objs.keys():
            continue

        io.importSkin(xml_objs[obj.Name], obj)