Batch script python

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  03 March 2013
Batch script python

Hi,

I am trying to run a batch script over scenes. I run mayapy.exe and paste my script :


 import maya.standalone
 maya.standalone.initialize(name='python')
 
 import maya.cmds as cmds
 import os
 
 # The top argument for walk
 topdir = 'D:\\DeleteVraySettingsBatch_PY'
 # The extension to search for
 exten = '.ma'
 # What will be logged
 results = str()
 myFiles = [] 
 for dirpath, dirnames, files in os.walk(topdir):
 	for name in files:
 		if name.lower().endswith(exten):
 			# Save to results string instead of printing
 			results = '%s' % os.path.join(dirpath, name)
 			myFiles.append(results)
 
 for i in myFiles:
 	cmds.file(i, force=True, open=True)
 	# Get all meshes in the scene
 	cmds.polySphere( n='mySphere', sx=5, sy=5, n="Youpi")
 	# Save the file	   
 	cmds.file(save=True, force=True)
 


But when I execute it, it returned : "SyntaxError: keyword argument repeated"

As it is the first time I used this kind of script, I'm not sure what I'm doing bad...
__________________
DrWeeny
My Blog
My Vimeo
LinkedIn
 
  03 March 2013
Without giving the rest of the code a read, the error you specified originates from:

cmds.polySphere( n='mySphere', sx=5, sy=5, n="Youpi")


because "n" is given twice.

See the Python tutorial on keyword arguments -> http://docs.python.org/2.7/tutorial...yword-arguments
 
  03 March 2013
x.x, hitting my head on the keyboard....

Thanks anyway....
__________________
DrWeeny
My Blog
My Vimeo
LinkedIn
 
  03 March 2013
What is it that you intend the script to do?

It currently appears to find all ".ma" files in the given directory and attempts to create a polySphere in them.
 
  03 March 2013
At the moment, it was just for a test.

I want to delete all node "vraySettings" in Assets (to avoid crash when you reference them)


  import maya.standalone
 maya.standalone.initialize(name='python')
 
 import maya.cmds as cmds
 import os
 
 """List all .ma files in current directory and sub-directories"""
 # The top argument for walk
 topdir = 'D:\\DeleteVraySettingsBatch_PY'
 # The extension to search for
 exten = '.ma'
 # Append maya scene pathes in a variable "myFiles"
 results = str()
 myFiles = [] 
 for dirpath, dirnames, files in os.walk(topdir):
 	for name in files:
 		if name.lower().endswith(exten):
 			
 			results = '%s' % os.path.join(dirpath, name)
 			myFiles.append(results)
 
 """For all files run commands"""
 for i in myFiles:
 	cmds.file(i, force=True, open=True)
 	# Maya Commands : delete vraySettings
 	DelVraySet = cmds.ls('vraySettings')
 	if len(DelVraySet) != 0:
 		cmds.delete('vraySettings')
 	# Save the file	   
 	cmds.file(save=True, force=True)
  
__________________
DrWeeny
My Blog
My Vimeo
LinkedIn
 
  03 March 2013
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 03:52 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.