def packageScripts( scriptFilesToPackage, destPackageFilepath, dependencyTree ): ''' will package all given files and import dependencies into a single zip file ''' destPackageFilepath = Path( destPackageFilepath ).setExtension( 'zip' ) if destPackageFilepath.exists: destPackageFilepath.delete() filesToPackage = map( Path, scriptFilesToPackage ) for f in scriptFilesToPackage: filesToPackage += dependencyTree.findDependencies( f, None, False ) if not filesToPackage: return None #remove any duplicate files... filesToPackage = removeDupes( filesToPackage ) #this is a little hacky - but we don't want to re-distribute wingdbstub so lets check to see if its in the list of files for f in filesToPackage: if f.name() == 'wingdbstub': filesToPackage.remove( f ) break #now build the zip file import zipfile with zipfile.ZipFile( str( destPackageFilepath ), 'w' ) as thePackage: for f in filesToPackage: thePackage.write( str( f ), str( makeScriptPathRelative( f ) ) ) return destPackageFilepath
def convexifyObjects( objs ): noUndo = vs.CDisableUndoScopeGuard() dmxedit = vs.dmxedit tmpFile = Path( '%TEMP%/tmp.dmx' ) cmd.vsdmxio( objs, export=True, sl=True, ascii=True, filename=tmpFile ) #now load the file root = dmxedit.LoadDmx( tmpFile ) for dag in root.model.dagWalk(): shape = dag.shape if isinstance( shape, vs.movieobjects.CDmeMesh ): convexHull = dmxedit.ComputeConvexHull3D( shape ) convexHull.name = dag.name dag.SetShape( convexHull ) dmxedit.SaveDmx( root, tmpFile ) importedNodes = cmd.vsdmxio( i=True, filename=tmpFile ) tmpFile.delete() toReturn = [] toDelete = set() for n in importedNodes: if cmd.nodeType( n ) == 'mesh': p = cmd.listRelatives( n, pa=True, p=True )[ 0 ] pp = cmd.listRelatives( p, pa=True, p=True )[ 0 ] toDelete.add( pp ) p = cmd.parent( p, world=True )[ 0 ] p = cmd.rename( p, n.split( '|' )[ -1 ] ) toReturn.append( p ) cmd.delete( list( toDelete ) ) return toReturn
def convexifyObjects(objs): noUndo = vs.CDisableUndoScopeGuard() dmxedit = vs.dmxedit tmpFile = Path('%TEMP%/tmp.dmx') cmd.vsdmxio(objs, export=True, sl=True, ascii=True, filename=tmpFile) #now load the file root = dmxedit.LoadDmx(tmpFile) for dag in root.model.dagWalk(): shape = dag.shape if isinstance(shape, vs.movieobjects.CDmeMesh): convexHull = dmxedit.ComputeConvexHull3D(shape) convexHull.name = dag.name dag.SetShape(convexHull) dmxedit.SaveDmx(root, tmpFile) importedNodes = cmd.vsdmxio(i=True, filename=tmpFile) tmpFile.delete() toReturn = [] toDelete = set() for n in importedNodes: if cmd.nodeType(n) == 'mesh': p = cmd.listRelatives(n, pa=True, p=True)[0] pp = cmd.listRelatives(p, pa=True, p=True)[0] toDelete.add(pp) p = cmd.parent(p, world=True)[0] p = cmd.rename(p, n.split('|')[-1]) toReturn.append(p) cmd.delete(list(toDelete)) return toReturn