导入语句中的Python缩进错误?

时间:2014-09-09 00:45:47

标签: python-2.7 maya

我正在为应用程序maya编写一个python脚本。在控制台中我收到此错误:

# Error: IndentationError: file <maya console> line 2: expected an indented block # 

然而,这是一个简单的import语句。我不知道为什么我会得到它,它只发生在声明“import neoARLLF”上。如果它拿出来,它就不再给它了。该模块肯定在其余脚本的文件夹中,否则我认为我会收到导入错误。此外,脚本的所有其余部分都正确缩进,我没有混合制表符和空格,所有这些都缩进了4个空格。

import maya.cmds as mc
import neoARLLF
import neoARnameConv
reload(neoARnameConv)
reload(neoARLF)

seg = neoARLLF.MidLvlFunc()
nameC = neoARnameConv.NameConv()

def jntSegTest():
    jointRad = mc.joint("joint1", q=True, rad=True)
    jnts = 2
    names = []

    for i in xrange(1, 2, 1):
        name = nameC.curConv("test", "AuxKnee", "right", "joint", "01")
        names.append(name)

    seg.segmentJnt("joint1", "joint2", jnts, "y", jointRad, names)

jntSegTest()

任何人都知道这个代码是什么?我已经搜索了很长时间,我发现的所有缩进错误都涉及将制表符与空格混合,或者在分号(定义,类,for循环等)之后没有正确缩进。所以我不知所措。

如果它有帮助,那么继承neoARLLF模块的代码。我认为这段代码中有很多错误,但我不能测试代码来修复它,直到我可以让import语句在前一个模块中工作

# Filename: neoARLLF.py
# Created By: Gregory Smith
# Last Edited: 8/20/14
# Description: Neo Auto Rig - Low Level Functions
# Purpose: The classes in this script house all of the low level functions that will be carried out in
# external scripts.

import maya.cmds as mc
import neoARnameConv
from pymel.core import dt

nameC = neoARnameConv.NameConv()

class LowLvlFunc:

    def __init__(self):


    def reverseList(self, givenList):
        """Reverses the given list (eg. [1, 2, 3] would turn into [3, 2, 1]

        Keyword Args
        givenList - list that you want reversed
        """

        newList = givenList[:: - 1]
        return newList


    def copyTranslate(self, source, target):
        """Copies the world-space translate values from one object to another

        Keyword Args
        source - object you want values copied from
        target - object you want values copied to
        """

        translate = mc.xform(source, q=True, ws=True, t=True)
        rotPiv = mc.xform(target, q=True, rp=True)
        newVec = [sum(i) for i in zip(translate, rotPiv)]

        mc.xform(target, a=True, ws=True, t=(newVec[0], newVec[1], newVec[2]))

    def copyRotate(self, source, target):
        """Copies the world-space rotate values from one object to another

        Keyword Args
        source - object you want values copied from
        target - object you want values copied to
        """
        rotate = mc.xform(source, q=True, ws=True, ro=True)

        mc.xform(target, ws=True, ro=(rotate[0], rotate[1], rotate[2]))

    def lockProtectedAttrs (self, control, lock):
        """Locks or unlocks all attributes in custom attributes text file

        Keyword Arguments
        control -- the control you want the attributes locked/unlocked on
        lock -- if you want the control unlocked or locked (0 or 1)
        """

        filePath = (mc.internalVar(usd=True)+"neo_ikFkSnapAttrs")
        attrFile = open(filePath, "r")
        nextLine = f.readLines()
        attrList = []
        while (len(nextLine)>0):
            cleanLine = line.strip(nextLine)
            attrList[len(attrList)] = cleanLine
            print cleanLine
            nextLine = f.readlines()
        f.close()

        def unlock:
            for curAttr in attrList:
                if mc.attributeExists(control, curAttr):
                    mc.setAttr((control+"."+curAttr), lock=False)
        def lock:
            for curAttr in attrArray:
                if mc.attributeExists(control, curAttr):
                    mc.setAttr((control+"."+curAttr), lock=True)

        lockOpt = {
                0 : unlock,
                1 : lock
        }

        lockOpt[lock]()

    def zeroOutCustomAttr(self, control):
        """Zeroes out all user defined, custom attributes on given control

        Keyword Arguments
        control -- control you want attributes zeroed out on
        """
        lockProtectedAttrs(control,1)
        customAttrs = [mc.listAttr(control, ud=True, k=True, u=True)]
        lockProtectedAttrs(control, 0)
        for curAttr in customAttrs:
            mc.setAttr((control+"."+curAttr), 0)
            print ("Resettings attribute "+curAttr)
        print ("Custom Attributes on "+control+" have been zeroed out")

class MidLvlFunc:

    def __init__(self):


    def segmentJnt(self, startJnt, endJnt, jointNum, primAxis, radius, name):

        """Creates 3 evenly spaced joints between 2 given joints

        Keyword Args
        startJnt - first joint, (ex, knee or elbow joint)
        endJnt - second joint, (ex. ankle or wrist joint)
        jointNum - number of segments in the chain
        primAxis - primary axis of joint chain
        radius - radius of other joints
        name - name of auxillary joints
        """

        startVec = mc.xform(q=True, ws=True, t=True, endJnt)
        endVec = mc.xform(q=True, ws=True, t=True, startJnt)
        startAux = mc.joint(n=name[0], p=(dt.Vector(startVec))
        endAux = mc.joint(n=name[(len(name)-1)], p=(dt.Vector(endVec))
        returnList = [startAux]

        for i in xrange(1, jointNum, 1):
            jointAux = mc.joint(n=name[i], o=(0, 0, 0), rad=radius)
            if primAxis = "x":
                mc.move(((endJnt.tx) / jointNum), 0, 0, joint, r=True, ls=True)
            elif primAxis = "y":
                mc.Move(0, ((endJnt.ty) / jointNum), 0, joint, r=True, ls=True)
            else
                mc.Move=(0, 0, ((endJnt.tz) / jointNum), joint, r=True, ls=True)
            returnList.append(jointAux)

        returnList.append(endAux)

        return returnList

1 个答案:

答案 0 :(得分:3)

问题出在班级__init__

def __init__(self):

下面没有代码,所以下一行会出错。要删除该函数,请添加pass语句,如下所示:

def __init__(self):
    pass