Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bpy
- import os, subprocess, sys, re
- class extractUV():
- def __init__(self):
- self.view_layer = bpy.context.view_layer
- self.mFilePath = None
- #scene = bpy.data.scenes.new("Scene")
- bpy.ops.object.select_all()
- bpy.ops.object.delete() # Delete the default stuff
- pass
- def parseModel(self):
- #bpy.ops.object.select_all(action='SELECT')
- selection = bpy.context.selected_objects
- bpy.ops.object.select_all(action='DESELECT')
- if self.mFilePath is None:
- return
- for obj in selection:
- self.obj = obj
- obj.select_set(True)
- self.view_layer.objects.active = obj
- self.extractUV()
- bpy.ops.object.delete()
- def extractUV(self):
- if not bpy.context.object.data.uv_layers:
- print(self.obj.name + " does not have UV map, skipping")
- else:
- exportPath = self.mFilePath + "_UV"
- exportPath = "C:/Users/Azrael/Desktop/blender test stuff/" + obj.name
- bpy.ops.uv.export_layout(filepath=exportPath, mode='PNG', opacity=45)
- def addModel(self, modelFilePath):
- self.mFilePath = modelFilePath
- bpy.ops.import_scene.obj(filepath=self.mFilePath) # maybe replace with glob
- uv = extractUV()
- os.chdir("C:/Users/Azrael/Desktop/Toontown/resources/")
- allFiles = []
- selectedPhases = ['5']
- inputFile = ".obj"
- for phase in selectedPhases:
- if not os.path.exists('phase_%s' % phase):
- continue
- for root, _, files in os.walk('phase_%s' % phase):
- for file in files:
- if not file.endswith(inputFile): # Input file
- continue
- file = os.path.join(root, file)
- allFiles.append(file)
- for file in allFiles:
- uv.addModel(file)
- uv.parseModel()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement