Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 10 additions & 0 deletions SubstancePainterToMaya/UI.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
20 changes: 17 additions & 3 deletions SubstancePainterToMaya/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,26 @@ def before(value, a):
if pos_a == -1: return ""
return value[0:pos_a]

def withoutPrefix(ui):
# removing prefix from textureSet
textureSet = ui.textureSet.text().encode("ascii")
if ui.namePrefix.text().encode("ascii") is None:
return ''
else:
namePrefix = ui.namePrefix.text().encode("ascii")
if textureSet.startswith(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 = ui.textureSet.text().encode("ascii")
textureSet = withoutPrefix(ui)
map = ui.map.text().encode("ascii")

for texture in textures:
Expand Down Expand Up @@ -93,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
Expand Down Expand Up @@ -132,7 +146,7 @@ def listTextures(ui, renderer, foundFiles, allTextureSets):
nameStart += 1

mapName = name
textureSetName = textureSet
textureSetName = appendPrefix(ui, textureSet)

if mapName and textureSetName:

Expand Down