Start a new topic

Find Repeated Textures in DB

Original Post by: maruthi Tue Sep 30 06:28:44 2014


Hi All,


I wrote script for find the Repeated Textures in DB, It will help to find the Repeated Texture and replace with corresponding Polygon and finally it will Remove Repeated Texture. I hope it is useful to reduce unwanted load to DB


Thanks,

Maruthi


db =mgGetCurrentDb()


class indent:

pass


i =indent()

i.list =[]

i.list1 =[]

i.indexmain=-1

i.indexreplace=-1


def listTextures():

bool,index,name = mgGetFirstTexture(db)

while bool:

i.list.append(name)

i.list1.append(index)

bool,index,name = mgGetNextTexture(db)

def BeadWalk (db, parent, rec, userData):

if mgGetCode (rec) == fltPolygon:

localList = mgGetAttList(rec,fltPolyTexture)

if localList[2] ==i.indexreplace:

mgSetAttList(rec,fltPolyTexture,i.indexmain)

return MG_TRUE


def findTextures():

listTextures()

for x in range(len(i.list)):

for s in range(x+1,len(i.list)):

if i.list[x] == i.list[s]:

if mgIsTextureInPalette(db,i.list[x]) and mgIsTextureInPalette(db,i.list[s]):

i.indexmain =i.list1[x]

i.indexreplace = i.list1[s]

mgWalk (db, BeadWalk , None, None, MWALK_NOREADONLY)

print "Repeated Texture Removed: "+ mgGetTextureName(db,i.indexreplace)

mgDeleteTexture(db,i.indexreplace)

findTextures()




1 person has this problem
1 Comment

Original Post by: SteveThompson Tue Sep 30 16:19:09 2014


Thanks for sharing :coolsmile:

Login to post a comment