Esempio n. 1
0
def convertBabylonMultiExporterData():
    log = ""
    root = getSceneRootNode()
    print("Converting")
    if userprop.getUserProp(root,"babylonjs_ExportItemListBackup") is None: # Only convert if we didn't before
        exportItemList = userprop.getUserPropList(root, "babylonjs_ExportItemList")
        rawExportItemList = userprop.getUserProp(root, "babylonjs_ExportItemList")
        if exportItemList is not None:
            for exportItem in exportItemList:
                try:
                    itemProp = userprop.getUserProp(root, exportItem)
                    itemProp = str(itemProp).replace(";;", ";-;")
                    item = userprop.parseUserPropAsList(itemProp)
                    if (item is not None):
                        expPath = item[1]
                        serialLayers = item[3]
                        print(serialLayers)
                        layerNames = [x for x in item[3].split("~")]
                        absPath = convertRelativePathToAbsolute(expPath, rt.maxfilepath)
                        relPath = convertAbsolutePathToRelative(absPath, rt.pathConfig.getCurrentProjectFolder())
                        presetName = os.path.splitext(os.path.split(relPath)[1])[0]
                        presetUtils.createNewPreset(presetName, None, relPath, layerNames)
                        log += "{0}\n".format(presetName)
                except Exception as error:
                    log += "Couldn't convert " + exportItem + " of the path because " + error
                    print(error)
            # Uncomment if you want to destroy the original Babylon Preset
            userprop.setUserProp(root, "babylonjs_ExportItemListBackup", rawExportItemList)
            # userprop.removeUserProp(root, "babylonjs_ExportItemList")
    return log
Esempio n. 2
0
def is_double_unique_ID(nodes):
    UniqueIds = []
    result = False
    MatchnodeNunIDList = []
    for n in nodes:
        UnID = userprop.getUserProp(n, "flightsim_uniqueID")
        for n2 in nodes:
            UnID2 = userprop.getUserProp(n2, "flightsim_uniqueID")
            if UnID == UnID2 and n != n2:
                if UnID != None:
                    #print("FoundMatch on nodes ({0}/{1}) with Unique ID ({2})".format(n,n2,UnID))
                    a, pos = is_uniqueIDExist(MatchnodeNunIDList, UnID)
                    if a:
                        if not is_NodesExists(MatchnodeNunIDList, n.name):
                            MatchnodeNunIDList[pos].Nodes.append(n.name)
                        if not is_NodesExists(MatchnodeNunIDList, n2.name):
                            MatchnodeNunIDList[pos].Nodes.append(n2.name)
                    else:
                        temNodeList = []
                        temNodeList.append(n.name)
                        temNodeList.append(n2.name)
                        MatchnodeNunIDList.append(
                            MatchnodeNunID(UnID, temNodeList))
                    result = True
    return result, MatchnodeNunIDList
Esempio n. 3
0
    def initializeWidgets(self, dictObj=None):
        """
        Initialize each widgets in the option menu by doing this:
        - Get corresponding UserProperty of a widget in the self.widgetToProperty dictionary
        - Using this userProperty get the value in the input dictObj.
        - if it isn't in the dictObj look in the root node
        - if it isn't stored in the root then get the default value from BabylonPYMXS
        - if it isn't in BabylonPYMXS default values use the type default (False, 0, 0.0, "")
        - finally set this value in the widget

        \nin:
        dictObj=dict[str] var
        """
        sceneRoot = sceneUtils.getSceneRootNode()
        for widget in self.widgetToProperty.keys():
            prop = self.widgetToProperty[widget]
            state = None
            if dictObj is not None:
                if dictObj.has_key(prop):
                    state = dictObj[prop]
            if state is None:
                state = userprop.getUserProp(sceneRoot, prop)
            #INITIALIZE
            if (state == None):
                state = getPropertyDefaultValue(prop)
            if (isinstance(widget, QCheckBox)):
                widget.setCheckState(Qt.Checked if state else Qt.Unchecked)
            elif (isinstance(widget, QGroupBox)):
                if (state is None):
                    state = False
                widget.setChecked(state)
            elif (isinstance(widget, QComboBox)):
                if state is None:
                    state = 0
                widget.setCurrentIndex(state)
            elif (isinstance(widget, QLineEdit)):
                widget.setText(str(state))
        for special in self.specialWidgetToProperty.keys():
            prop = self.specialWidgetToProperty[special]
            state = userprop.getUserProp(sceneRoot, prop)
            #INITIALIZE
            if dictObj is not None:
                if dictObj.has_key(prop):
                    state = dictObj[prop]
            if (state is None):
                state = getPropertyDefaultValue(prop)
            if isinstance(special, QComboBox):
                if state is None:
                    state = special.itemText(0)
                special.setCurrentText(state)
            if isinstance(special, QLineEdit):
                if state is None:
                    state = special.text()
                special.setText(state)

        self.appliedOption()
Esempio n. 4
0
def updateObsoleteExportPath():
    log = ""
    roots = getAllRoots(getAllObjects())
    for r in roots:
        oldPath = userprop.getUserProp(r, constants.PROP_OLD_EXPORT_PATH)
        newPath = userprop.getUserProp(r, constants.PROP_EXPORT_PATH)
        if oldPath is not None and newPath is None:
            newPath = convertRelativePathToAbsolute(
                oldPath, rt.maxFilePath)
            newPath = convertAbsolutePathToRelative(
                newPath, rt.pathConfig.getCurrentProjectFolder())
            userprop.setUserProp(r, constants.PROP_EXPORT_PATH, newPath)
            log += "{0}\n".format(r.name)
    return log
Esempio n. 5
0
 def __init__(self):
     QtWidgets.QWidget.__init__(self)
     self.setupUi(self)
     self.retranslateUi(self)
     self.defaultMsg = self.info_lbl.text()
     self.texturePath = userprop.getUserProp(
         rt.rootNode, "FlightSim_ConvertTextureToMesh")
     state = userprop.getUserProp(
         rt.rootNode, "FlightSim_ConvertTextureToMesh_useMaterialAlpha")
     self.useAlpha_chb.setChecked(True if state == None else state)
     self.path_lbl.setText(self.texturePath)
     self.browse_btn.clicked.connect(self.loadTexture)
     self.convertToMesh_btn.clicked.connect(self.convertToMesh)
     self.useAlpha_chb.stateChanged.connect(self.onUseAlphaStateChanged)
Esempio n. 6
0
def checkSavedMaxFilePath():  # UNUSED
    sceneRoot = getSceneRootNode()
    if rt.maxFilePath == "" or rt.maxFilePath is None:
        qtUtils.popup(title="Scene File is not saved.",
                      text="You need to save your Max scene to use the exporter.")
        return False
    savedFilePath = userprop.getUserProp(
        sceneRoot, constants.PROP_SAVED_MAXFILE_PATH)
    if (savedFilePath is None):
        userprop.setUserProp(
            sceneRoot, constants.PROP_SAVED_MAXFILE_PATH, rt.maxFilePath)
        return True
    else:
        if (savedFilePath != rt.maxFilePath):
            qtUtils.popup(
                title="Max File path changed",
                text="The scene .max file path changed since last time you used the Multi-Exporter.\n\n"
                "If you changed the path of your Max file please make sure all the export path in the Multi-Exporter are still correct.\n\n"
                "NOTE : This can be caused by having different workspaces working on the same file, "
                "it will not be a problem if the .max file didn't change relative to the project.\n\n"
                "If you didn't change the Max file path please ignore this message."
            )
            userprop.setUserProp(
                sceneRoot, constants.PROP_SAVED_MAXFILE_PATH, rt.maxFilePath)
            return True
        else:
            return True
Esempio n. 7
0
 def _load(self):
     sceneRoot = sceneUtils.getSceneRootNode()
     propList = userprop.getUserPropList(sceneRoot, self.listStorage)
     if propList is not None:
         if self.identifier in propList:
             preset = userprop.getUserProp(sceneRoot, self.identifier)
             self.name = preset
Esempio n. 8
0
def getCurrentSettingsAsDict():
    """
    Returns the current babylon parameters saved in the root node as a dict

    \nout:
    dictionary  key: pymxs user property string 
                value: var
    """
    sceneRoot = sceneUtils.getSceneRootNode()
    newDict = dict()
    for val in babylonParameters:
        newDict[val] = userprop.getUserProp(sceneRoot, val)
    return newDict
Esempio n. 9
0
def writeDefaultBabylonParametersInRootNode():
    sceneRoot = getSceneRootNode()
    for prop in propertyToDefault.keys():
        value = userprop.getUserProp(
            sceneRoot, prop, propertyToDefault[prop])
        userprop.setUserProp(sceneRoot, prop, value)