2013-11-09 4 views
-4

Это скрипт python, над которым я работаю, я новичок в скриптах pyhton, это то, чему мы учимся в школе, мне нужна помощь. это ошибка, которую я продолжаю получать, я не понимаю, что такое недопустимый синтаксис. Спасибо за любую помощь. "Импорт maya.cmds как СКМЗ", это часть программы я работаю,Python Script недействительный синтаксический ответ

 #Error: line 1: invalid syntax 
     # File "<maya console>", line 27 
     #  transformInScene = cmds.ls(type='transform') 
     #     ^
     # SyntaxError: invalid syntax #   

cmds.file (новый = True, сила = True)

 import maya.cmds as cmds 
     def changeXtransformValue(myList, percentage=1.0): 
      """ 
      Changes the value of each transform in the scene by a percentange. 
      Parameters: 
      percentage - Percentange to change each transform's value. Default value is 1. 
      Returns: 
      Nothing. 
      """ 
      *# The ls command is the list command. It is used to list various nodes 
      # in the current scene. You can also use it to list selected nodes.* 
      transformInScene = cmds.ls(type='transform') 
      found = False 
      for thisTransform in transformInScene: 
       if i not in ['front','persp','side','top']: 
        found = True 
        break 
       else: 
        found = False 
      if found == False: 
        sphere1 = cmds.polySphere()[0] 
        cmds.xform(sphere1, t = (0.5, 0.5, 0.5) 
*#This is the line where I am having problems* 
      transformInScene = cmds.ls(type='transform') 
      sel =cmds.ls(sl=True) 
      if sel : 
       transformInScene = sel 
      # If there are no transforms in the scene, there is no point running this script 
      if not transformInScene: 
        raise RuntimeError, 'There are no transforms in the scene!' 
      badAttrs = list() 
      # Loop through each transform 
      for thisTransform in transformInScene: 
        if thisTransform not in ['front','persp','side','top']: 
        allAttrs = cmds.listAttr(thisTransform, keyable=True, scalar=True) 
        allAttrs = [ i for i in allAttrs if i = "visibility" ] 
        print allAttrs  
        for attr in myList: 
         if attr in allAttrs: 
          currentVal = cmds.getAttr(thisTransform + "." + attr) 
          newVal = currentVal * percentage 
          cmds.setAttr(thisTransform + "." + attr, newval) 
          print "Changed %s. %s from %s to %s" % (thisTransform,attr,currentVal,newVal) 
         else: 
          badAttrs.append(attr) 

      if badAttrs: 
       print "These attributes $s are not valid" % str() 

     myList = ["translateX", "translateY", "translateZ", "scaleX"] 
     changeXtransformVal(myList, percentage=1.0) 

Это часть школьного проекта и после фиксации отступа, я не могу показаться, чтобы найти проблему

ответ

2

линия выше ...

   cmds.xform(sphere1, t = (0.5, 0.5, 0.5) 

отсутствует закрывающий пар объединяется для вызова xform.

+0

Вы обнаружили, что в беглом взгляде? Дайюм, вы хорошо. И вот я смотрел только в первый раз, когда этот метод назывался: P –

+0

Почему этот вопрос получил так много downvote? – aIKid

+0

@GamesBrainiac В основном, это вопрос отслеживания назад от строки, указанной в ошибке. Указанная строка явно не имеет синтаксической ошибки, поэтому следующим потенциальным виновником является предыдущая строка. Через некоторое время вы попадаете в глаза для сопоставления паренов. – Amber

0

Вы забыли один ')' в строке "cmds.xform (sphere1, т = (0,5, 0,5, 0,5)"

посмотреть, что вы используете два '(', но только один ')'

просто добавить один в конце:

заменить cmds.xform (sphere1, т = (0,5, 0,5, 0,5) с cmds.xform (sphere1, т = (0,5, 0,5, 0,5))

Смежные вопросы