Darkworld opened this issue on Jun 01, 2020 · 17 posts
structure posted Tue, 02 June 2020 at 10:25 PM Forum Coordinator
# -*- coding: utf-8 -*-
# ©copyright structure 2001 - 2020
# list image locations
# ================================
import os
import os.path
import poser
import re
import string
import sys
import wx
def getdir( start ):
# get working folder
style = ( wx.DD_DEFAULT_STYLE | wx.DD_NEW_DIR_BUTTON )
dialog = wx.DirDialog( None, 'Select a Folder ', start , style ) # prepare dialog
return dialog.GetPath() if dialog.ShowModal() == wx.ID_OK else False # test dialog response
def listoffiles(filepath):
return os.listdir(filepath)
def oFile(filename):
openfile = open(filename, 'r')
return openfile.readlines()
def strip(strippedline):
strippedline = strippedline.lstrip()
strippedline = strippedline.rstrip()
stripList = [ 'bumpMap ', 'file ', 'reflectionMap ', 'textureMap ', 'transparencyMap ' ]
for stripThis in stripList:
strippedline = strippedline.lstrip(stripThis)
return strippedline
def imageFileTypes():
return [ '.bmp','.gif','.tif','.tga','.jpg','.png','.PSD' ]
def file_exts():
return( ".mt5", ".mc6", ".pz2" )
fileexts = file_exts()
tlist = []
exts = imageFileTypes()
lastfolder_data = os.path.join(poser.PrefsLocation(), "structure", "listmats", "lastfolder.db" )
temp = os.path.join( poser.Libraries()[0], "Runtime", "libraries", "materials" )
if not os.path.exists( os.path.dirname( lastfolder_data ) ):
os.makedirs( os.path.dirname( lastfolder_data ) )
if not os.path.exists( lastfolder_data ):
with open( lastfolder_data, "w" ) as outfile:
outfile.write( temp )
with open( lastfolder_data, "r" ) as infile:
lastfolder = infile.read()
filepath = getdir( lastfolder )
temp = None
if filepath:
with open( lastfolder_data, "w" ) as outfile:
outfile.write( filepath )
for f in listoffiles( filepath ):
filename = os.path.join( filepath, f )
if filename.endswith( fileexts ):
lines = oFile(filename)
for line in lines:
if filename not in tlist:
tlist.append(filename)
for find in ( exts ):
if find in line.lower():
strippedline = strip(line)
if strippedline not in tlist:
tlist.append(strippedline)
for t in tlist:
print t
print "%sn" %("="*40)
tlist = []
print '©2014 justlastknight All Rights Reserved.'
you can run this on a folder - it will tell you the file name - and what texture maps it requires
Locked Out