Page 1 of 44 12311 ... LastLast
Results 1 to 10 of 440
  1. #1
    Join Date
    May 2003
    Location
    Derby England
    Posts
    1,005

    MM: Developing Modular Rigging Systems with Python Help

    Well, this is embarrassing, it looks like I'm stuck already, I've gone through the blueprint_UI.py six times and cant see a single error, it did report that it was in the constructor, so the file is being referenced, but when trying to run the completed code to launch the window I get the error below. I cant find the syntax error anywhere

    # Error: ('invalid syntax', ('C:/Projects/RiggingTool/Modules\\System\\blueprint_UI.py', 8, 53, '\t\tif cmds.window("blueprint_UI_window", exists=True)\n'))
    # Traceback (most recent call last):
    # File "<maya console>", line 14, in <module>
    # File "C:/Projects/RiggingTool/Modules\System\blueprint_UI.py", line 8
    # if cmds.window("blueprint_UI_window", exists=True)
    #
    # ^
    # SyntaxError: invalid syntax #

    EDIT:

    Fixed it...
    Missing the colon after ("blueprint_UI_window", exists=True):
    Last edited by Pharion; 04-07-2010 at 05:39 PM.

  2. #2
    Join Date
    May 2003
    Location
    Derby England
    Posts
    1,005
    I now also know that the error "Error: ('non-keyword arg after keyword arg', " translates to, "Youv'e not put in the '=' you dumbass"

  3. #3
    Join Date
    May 2002
    Location
    UK
    Posts
    2,807
    Hehe, after a while you should become familiar with what most of the errors relate to. Takes a bit of getting used to

    Glad you solved your problem!

    Steve

  4. #4
    Join Date
    May 2003
    Location
    Derby England
    Posts
    1,005
    Hi Steve, I think you've Jinxed me great work by the way, this has got me really excited and I'd learning an amazing amount about scripting.

    Doing well up to here when I tested the script:

    UI = blueprint_UI.Blueprint_UI()
    C:/Projects/RiggingTool
    module_a
    module_b

    As soon as I added the

    for module in utils.findAllModules("Modules/Blueprint"):
    self.createModuleInstallButton(module)
    cmds.setParent(self.UIElements["moduleList_column"])
    cmds.separator()

    cmds.setParent(self.UIElements["moduleColumn"])
    cmds.separator()

    def createModuleInstallButton(self, module):
    print module

    I get the following error... been going at it for four hours now, and still haven't found where I've gone wrong?

    # Error: Blueprint_UI instance has no attribute 'createModuleInstallButton'
    # Traceback (most recent call last):
    # File "<maya console>", line 17, in <module>
    # File "C:/Projects/RiggingTool/Modules\System\blueprint_UI.py", line 28, in __init__
    # self.initialiseModuleTab(tabHeight, tabWidth)
    # File "C:/Projects/RiggingTool/Modules\System\blueprint_UI.py", line 51, in initialiseModuleTab
    # self.createModuleInstallButton(module)
    # AttributeError: Blueprint_UI instance has no attribute 'createModuleInstallButton' #

  5. #5
    Join Date
    May 2002
    Location
    UK
    Posts
    2,807
    Haha, I hope I haven't Jinxed ya!

    Glad to hear that you're enjoying the training and learning lots about Python scripting

    The error is suggesting that the method "createModuleInstallButton()" doesn't belong to the Blueprint_UI class. Now, obviously the class is supposed to have that method (and the code you posted includes a definition for the method that should be correct). That leads me to think that perhaps the indentation isn't quite right, and in Python the indentation is essential because it determines which code belongs to certain 'blocks' if you will (i.e. which code forms the class, which code belongs to a certain method definition, etc.).

    I'd recommend double checking to make sure the definition of createModuleInstallButton is such that it's nested inside the class definition, and that it's not being defined outside the class. If you're still having trouble, feel free to PM me (as I'm sure you're aware, small code snippets like the above are totally acceptible on the forums, but we'd like to avoid lengthy code getting posted, for obvious reasons ) the entire code for the file so far (you'll probably need to put it in code tags so as to preserve indentation) and I'll take a more detailed look at what seems to be the problem.

    All the best,
    Steve

  6. #6
    Join Date
    May 2003
    Location
    Derby England
    Posts
    1,005
    You sir are a gent amongst giants, and a frikin genius to boot deleted all the indentation, and stuck it back in again, all working... now know a new thing to look out for.... thanks again

  7. #7
    Join Date
    May 2002
    Location
    UK
    Posts
    2,807
    Hahaha awesome

    Glad I could help!

    Steve

  8. #8
    Join Date
    May 2003
    Location
    Derby England
    Posts
    1,005
    wow, indentation in python can really bite you in the ass, sometimes you dont even get an error, just strange results, here is an after and a before I found the bug: yep got the images backwards



    Attachment 70297
    Last edited by Pharion; 04-11-2010 at 04:45 PM.

  9. #9
    Join Date
    May 2002
    Location
    UK
    Posts
    2,807
    The attachment doesn't seem to work ... and I really wanted to see the crazy results you were getting!

    It's fairly easy for a line or two of code to slip into a different code block if you're not careful! You'll quickly get the hang of it, however, and then it shouldn't be a problem , it's just something to keep close attention on when coding, much like any other syntax. It helps to use an editor like Notepad++ that draws lines indicating different levels of indentation

    Steve

  10. #10
    Join Date
    May 2003
    Location
    Derby England
    Posts
    1,005
    [IMG]file:///C:/Users/Stephen/AppData/Local/Temp/moz-screenshot-6.png[/IMG]Hi Steve, this is what I got when messing up the indentation... been busy but just managed to complete vid 15 without any difficulty... but my god you say container allot




Page 1 of 44 12311 ... LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •