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

新康克

我正在为应用程序Maya编写python脚本。在控制台中,我得到此错误:

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

但这是一个简单的导入语句。我不确定为什么要得到它,它仅发生在“ 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()

有人知道这段代码是怎么回事吗?我已经搜索了很长时间,发现的所有缩进错误都涉及到将制表符与空格混合,或者在分号(定义,类,循环等)之后无法正确缩进。所以我很茫然。

如果有帮助,请在此提供模块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
赫斯特

问题出在你的课上__init__

def __init__(self):

您下面没有代码,因此在下一行会出错。要存根函数,请添加一条pass语句,如下所示:

def __init__(self):
    pass

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章