Talk:Blender 3D: Noob to Pro/Advanced Tutorials/Python Scripting/Addon Anatomy

To run the Tetrahedron example on Win32 PC you need to add this code:

Please note: These registration and unregistration calls are not part of the class defined in this tutorial, and should be placed outside that classes indentation level.

Blank lines in python source code
I was getting an "indent error" trying to run the following from the Wikibook page https://en.wikibooks.org/wiki/Blender_3D:_Noob_to_Pro/Advanced_Tutorials/Python_Scripting/Addon_Anatomy:

"Complete Script"

=
============== import math import bpy import mathutils

class MakeTetrahedron(bpy.types.Operator) : bl_idname = "mesh.make_tetrahedron" bl_label = "Add Tetrahedron"

def invoke(self, context, event) :   <<<<<<<<<<<<<<<<<<<<<< INDENT ERROR DUE TO BLANK LINE PRECEEDING THIS LINE Vertices = \ [           mathutils.Vector((0, -1 / math.sqrt(3),0)), mathutils.Vector((0.5, 1 / (2 * math.sqrt(3)), 0)), mathutils.Vector((-0.5, 1 / (2 * math.sqrt(3)), 0)), mathutils.Vector((0, 0, math.sqrt(2 / 3))), ]       NewMesh = bpy.data.meshes.new("Tetrahedron") NewMesh.from_pydata \ (           Vertices,            [],            0, 2, 1], [0, 1, 3], [1, 2, 3], [2, 0, 3          ) NewMesh.update NewObj = bpy.data.objects.new("Tetrahedron", NewMesh) # Blender 2.79: context.scene.objects.link(NewObj) context.collection.objects.link(NewObj) return {"FINISHED"} #end invoke
 * 1) end MakeTetrahedron

bpy.utils.register_class(MakeTetrahedron)

=
==== So, I corrected the source script error by eliminating the blank line, which solved the error problem.

=
==== Further discussion: Please refer to   https://developer.blender.org/T79461 Near the bottom of the discussion, Robert Guetzkow (rjg) identifies the issue in the python console: Source code blank lines do not work in the python console Try this in the console:

print('Hello')

print('World')

print('Hello') print('World')

Cfpops (discuss • contribs) 17:05, 16 February 2022 (UTC)cfpops