Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- WIP: 15_0927
- Script By: Dr. Gravitas
- Given a set of edges, construct an exportable dataset for use in auto cutting UVs.
- Format:
- [ [ edgeID number , Edge Length ] , [ vertexID number, vertex Position Point ]... ]
- '''
- import pymel.core as pm
- from maya import OpenMaya as om
- import os
- import fileinput
- import pickle
- '''
- Builds a list of Points
- '''
- def buildPointsList(selected):
- output = []
- for edges in selected:
- #Selection may include lists of edges. Maya is funny like that.
- for edge in edges:
- #Type Check If any selected node is not actually an edge, throw an error.
- if not isinstance(edge, pm.MeshEdge):
- pm.error(edge + ' is Type: ' + type(edge).__name__ + '. Not the required Type: '+pm.MeshEdge.__name__)
- edgeId = [ edge.index(), edge.getLength() ]
- edgeDef = []
- vertDef = []
- for vertex in edge.connectedVertices():
- vertDef.append( [ vertex.index(), vertex.getPosition(space='world') ] )
- output.append( [ edgeId, vertDef ] )
- return output
- def writeToFile(filename, output):
- fileout = open( filename, 'w' )
- #fileout.write( str(output) )
- pickle.dump( output, fileout )
- return
- '''
- Export list of edges to a location format is as follows:
- [ [ edgeID number , Edge Length ] , [ vertexID number, vertex Position Point ]... ]
- TODO: turn this into a dialog box that lets you configure this but auto-populates with standardDefaults
- '''
- def exportEdges(selected):
- output = buildPointsList(selected)
- # TODO: Replace this with the correct PyMel means of workspace file IO
- dirPath = os.path.dirname( 'C:\\[Fill in the path to your project's scripts here]\\Scripts\\StoredData\\UV Cut Edges\\' )
- filename = pm.date( format='YY_MMDD' ) + '_UVCutEdges' #Creates a filename based on the date and _UVCutEdges
- outputFile = os.path.abspath( os.path.join( dirPath, filename ) )
- writeToFile( outputFile, output )
- '''
- Main Body
- '''
- selected = pm.selected()
- exportEdges(selected)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement