Beispiel #1
0
Datei: io.py Projekt: jeanim/gear
def exportSkin(path, objects, compression=False):

    xml_doc = etree.Element("skin")
    xml_doc.set("user", getpass.getuser())
    xml_doc.set("date", str(datetime.datetime.now()))
    xml_doc.set("version", str(xsixmldom.VERSION))

    # -----------------------------------------------------
    for obj in objects:

        envelope_op = ope.getOperatorFromStack(obj, "envelopop")
        if not envelope_op:
            gear.log("%s has no envelope skipped"%obj.Name, gear.sev_warning)
            continue

        xsixmldom.setOptions(X3DObject_children=False,
                                    X3DObject_primitive=False,
                                    X3DObject_kinematics=False,
                                    X3DObject_properties=[],
                                    Geometry_operators=["envelopop"],
                                    Compression=compression)
        xObject = xsixmldom.getObject(obj)
        xml_doc.append(xObject.xml)

    # -----------------------------------------------------
    # Save to file
    xmldom.indent(xml_doc)

    tree = etree.ElementTree(xml_doc)
    tree.write(path)

    return True
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(xml_root)
    tree = etree.ElementTree(xml_root)
    tree.write(path)
Beispiel #3
0
    def exportToXml(self, model, path):

        self.model = model

        self.setFromHierarchy(self.model, True)

        # root
        xml_guide = etree.Element("guide")
        xml_guide.set("name", model.Name)
        xml_guide.set("user", getpass.getuser())
        xml_guide.set("date", str(datetime.datetime.now()))
        xml_guide.set("version", str(xsixmldom.VERSION))
        xml_guide.set("description", str(self.values["comments"]))

        # options
        xml_options = self.getParametersAsXml("options")
        xml_guide.append(xml_options)

        # controlers
        xml_controlers = etree.SubElement(xml_guide, "controlers")
        for name, ctl in self.controlers.items():
            xml_ctl = ctl.getAsXml()
            xml_controlers.append(xml_ctl)

        # components
        for name in self.componentsIndex:
            comp_guide = self.components[name]
            xml_comp = comp_guide.getAsXml()
            xml_guide.append(xml_comp)

        xmldom.indent(xml_guide)

        tree = etree.ElementTree(xml_guide)
        tree.write(path)
Beispiel #4
0
    def exportToXml(self, model, path):

        self.model = model

        self.setFromHierarchy(self.model, True)

        # root
        xml_guide = etree.Element("guide")
        xml_guide.set("name", model.Name)
        xml_guide.set("user", getpass.getuser())
        xml_guide.set("date", str(datetime.datetime.now()))
        xml_guide.set("version", str(xsixmldom.VERSION))
        xml_guide.set("description", str(self.values["comments"]))

        # options
        xml_options = self.getParametersAsXml("options")
        xml_guide.append(xml_options)

        # controlers
        xml_controlers = etree.SubElement(xml_guide, "controlers")
        for name, ctl in self.controlers.items():
            xml_ctl = ctl.getAsXml()
            xml_controlers.append(xml_ctl)

        # components
        for name in self.componentsIndex:
            comp_guide = self.components[name]
            xml_comp = comp_guide.getAsXml()
            xml_guide.append(xml_comp)

        xmldom.indent(xml_guide)

        tree = etree.ElementTree(xml_guide)
        tree.write(path)
Beispiel #5
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)