From 41510771ce9dd5adaab41bfc7702d4ee0423edfe Mon Sep 17 00:00:00 2001 From: Jake Law <34706661+jakelawcheukwun@users.noreply.github.com> Date: Fri, 27 Dec 2019 08:06:12 +0000 Subject: [PATCH 1/3] fix test --- SubstancePainterToMaya/UI.py | 10 ++++++++++ SubstancePainterToMaya/helper.py | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/SubstancePainterToMaya/UI.py b/SubstancePainterToMaya/UI.py index 6b8bb85..a2c0ea4 100644 --- a/SubstancePainterToMaya/UI.py +++ b/SubstancePainterToMaya/UI.py @@ -107,6 +107,16 @@ def createUI(self): ) self.namingConventionSubLayoutValue.addWidget(self.textureSet) + # new feature: choose the prefix to ignore + self.namePrefixLabel = QtWidgets.QLabel('namePrefix') + self.namingConventionSubLayoutLabel.addWidget(self.namePrefixLabel) + + self.namePrefix = QtWidgets.QLineEdit('Type your namePrefix') + self.namePrefix.setToolTip( + 'The namePrefix you want to ignore in the naming convention' + ) + self.namingConventionSubLayoutValue.addWidget(self.namePrefix) + self.mapLabel = QtWidgets.QLabel('map') self.namingConventionSubLayoutLabel.addWidget(self.mapLabel) self.mapLabel.resize(200,200) diff --git a/SubstancePainterToMaya/helper.py b/SubstancePainterToMaya/helper.py index 603d7ca..5139faa 100644 --- a/SubstancePainterToMaya/helper.py +++ b/SubstancePainterToMaya/helper.py @@ -29,6 +29,16 @@ def splitNamingConvention(ui, textures): textureSetSeparator = '_' mapSeparator = '_' textureSet = ui.textureSet.text().encode("ascii") + + # removing prefix from textureSet + if ui.namePrefix.text().encode("ascii") is None: + namePrefix = '' + else: + namePrefix = ui.namePrefix.text().encode("ascii") + if textureSet.startswith(namePrefix): + textureSet = textureSet[(len(namePrefix)):] + + map = ui.map.text().encode("ascii") for texture in textures: From 3421335e43e45e7769fc25036a4285a4fc26435a Mon Sep 17 00:00:00 2001 From: Jake Law <34706661+jakelawcheukwun@users.noreply.github.com> Date: Fri, 27 Dec 2019 09:20:40 +0000 Subject: [PATCH 2/3] quick fix --- SubstancePainterToMaya/helper.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/SubstancePainterToMaya/helper.py b/SubstancePainterToMaya/helper.py index 5139faa..d937431 100644 --- a/SubstancePainterToMaya/helper.py +++ b/SubstancePainterToMaya/helper.py @@ -23,22 +23,26 @@ def before(value, a): if pos_a == -1: return "" return value[0:pos_a] -def splitNamingConvention(ui, textures): - - construction = [] - textureSetSeparator = '_' - mapSeparator = '_' - textureSet = ui.textureSet.text().encode("ascii") - +def withoutPrefix(ui): # removing prefix from textureSet + textureSet = ui.textureSet.text().encode("ascii") if ui.namePrefix.text().encode("ascii") is None: - namePrefix = '' + return '' else: namePrefix = ui.namePrefix.text().encode("ascii") if textureSet.startswith(namePrefix): - textureSet = textureSet[(len(namePrefix)):] + return textureSet[(len(namePrefix)):] + +def appendPrefix(ui, input_str): + namePrefix = ui.namePrefix.text().encode("ascii") + return ''.join([namePrefix, input_str]) +def splitNamingConvention(ui, textures): + construction = [] + textureSetSeparator = '_' + mapSeparator = '_' + textureSet = withoutPrefix(ui) map = ui.map.text().encode("ascii") for texture in textures: @@ -103,7 +107,7 @@ def listTextures(ui, renderer, foundFiles, allTextureSets): for texture in foundFiles: if not allTextureSets: - if not ui.textureSet.text().encode("ascii") in texture: + if not withoutPrefix(ui) in texture: continue # Create the texture path @@ -142,7 +146,7 @@ def listTextures(ui, renderer, foundFiles, allTextureSets): nameStart += 1 mapName = name - textureSetName = textureSet + textureSetName = appendPrefix(ui, textureSet) if mapName and textureSetName: From f5d73cd1b506b846e7e2c24e3e023a3c542f614e Mon Sep 17 00:00:00 2001 From: Jake Law <34706661+jakelawcheukwun@users.noreply.github.com> Date: Fri, 27 Dec 2019 09:44:03 +0000 Subject: [PATCH 3/3] minor style fix on README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 10c57e7..4b9aca7 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,11 @@ Supported render engines and materials: Here the text version for copy+paste : +``` from SubstancePainterToMaya import main reload(main) main.SPtoM() +``` ## New