In this quick Blender 2.5 tip we show you a few examples of common bugs while scripting and show you how to fix them.

You must be logged in to upload images. Register

Discussion

14 Responses to “Tip: Script Bug Fixing 101”
  1. Posts: 256

    This tutorial may not be about something “sexy” but definitely a necessary one. You have any recommendations on where the best place to go for help on scripts your working on? Isn’t there a Blender coders’s IRC chat?

    #
    1
    Aug 12, 2011 at 7:39 am
    • Crouch
      Posts: 3

      #blendercoders and #blenderpython. Both at freenode.

      #
      1.1
      Aug 12, 2011 at 7:42 am
    • Posts: 225

      If you’re looking for ‘long-term help’, like advice on the progress of an add-on, or a complicated script you’ll be working on for sometime, I’d suggest making a topic at BlenderArtists. If it’s just a small/ one-time question then you’d probably indeed want to go to IRC. The channel is #BlenderCoders on irc.feenode.net. =)

      #
      1.2
      Aug 12, 2011 at 8:00 am
  2. Crouch
    Posts: 3

    Good tutorial. Very useful for people new to scripting. Especially the tip on scopes with an explanation of the difference between self.myVar and myVar.

    “If you’re getting errors than it’s probably better than not having any errors at all.”
    Quoted for agreement. It’s horrible when your 1000+ lines script isn’t working, but isn’t giving errors either.

    #
    2
    Aug 12, 2011 at 7:41 am
    • Posts: 225

      Thanks! Haha, yeah, throwing in a couple dozen prints just to know -where- the error is can get quite boring after the first few. =P

      #
      2.1
      Aug 12, 2011 at 5:30 pm
  3. dddjef
    Posts: 1

    very interesting and well done. Thanks a lot!

    #
    3
    Aug 12, 2011 at 8:51 am
  4. Posts: 71

    Thanks Patrick. Very good tut, well explained.

    #
    4
    Aug 12, 2011 at 9:28 am
  5. Posts: 28

    thnx for yours awesome tips

    #
    5
    Aug 12, 2011 at 12:48 pm
  6. Posts: 3

    Hi Patrick,

    This was exactly what I was looking for, I just started python and was playing with blender and got that horrible message check the console for now.. :( . But now I know which console to use :)

    Thanks

    Bram

    #
    6
    Aug 12, 2011 at 4:46 pm
    • Posts: 7

      Thanks Patrick! Your tutorial was excellent! I learned a lot about Blender python plus your great debugging tips.
      Could you do a tutorial about creating user interfaces with Blender python?

      #
      6.1
      Aug 13, 2011 at 10:45 am
  7. Posts: 71

    Hey Patrick, in the Blender Python console, it says “Convenience Imports: from mathutils import * ; from math import *

    Does this mean those modules are already imported and does not need to import them?
    Just curious.
    Thanks

    #
    7
    Aug 13, 2011 at 12:46 pm
    • Posts: 256

      They aren’t imported already. It is just saying those are convenient modules that you may want to use. He had to import math in this example for the math.pi constant. Hope that helps. Happy blending/scripting!

      #
      7.1
      Aug 13, 2011 at 1:08 pm
      • Posts: 225

        Actually, those modules are imported, but only in the console. There’s also a difference in how they’re imported. The usual way in scripts is to use “import math”, so that you can then use “math.pi” for instance. In this case “from math import *” is used, which puts all members of math in the global namespace. What this means is that instead of “math.pi” you can use just “pi”.

        #
        7.1.1
        Aug 15, 2011 at 7:11 am
  8. Hello Patrick and thanks for that tips.

    I was wondering, Is there no way to redirect the error output to the internal blender python console? I mean, can use something like the import sys and some sys.stderr = ?

    #
    8
    Aug 30, 2011 at 8:12 am

Leave a Comment

You must be logged in to post a comment.