ADD Mesh : QR Code for 2.49b

Hi, I made a QR grid mesh script. it works on 2.49b and python 2.6x

and you need pyqrcode.py script and QR code data. to run this script.
pyqrcode.py Script > http://libpanda.s18.xrea.com/qr/pyqrcode.py
QR code data >http://www.venus.dti.ne.jp/~swe/program/qrcode_rb0.50beta8.tar.gz
(oji minami-san and swetake-san ,thanks for sharing these resources!!)

1.Check your blender install directory
> ex. C:\blender
2.Copy pyqrcode.py to bpymodules dir
${blenderdir}.blender\scripts\bpymodules
3.extract qrcode_rb0.50beta8.tar.gz ,copy “qrcode_data” dir
4.Change the path for QRdata in pyqrcode.py
if you copy “qrcode_data” to “C:” , you can change like this:
self.path = r"c:\qrcode_data" # <- change path
5.copy this script to texteditor in blender
6.press [Alt+P] , and input text , then QR grid is appeared at (0,0,0)

I hope you enjoy it!!

#!BPY
"""
Name: 'qrgrid'
Blender: 248
Group: 'AddMesh'
Tooltip: 'Add qrgrid.'
"""

__author__ = "MITSUDA Tetsuo(Manda)"
__url__ = ("Author's homepage,http://rock.sannet.ne.jp/lab1092/")
__version__ = "0.01"
__bpydoc__ = """\
Add Mesh: QR code
"""

#  AddMesh&gt; QR Code V0.01
#  This script should copy to .blender/scripts/

from Blender import *
from math import sqrt
import bpy
import BPyMessages
import pyqrcode


DEFAULTOBJNAME = 'qrgrid'

def addQRGrid(st,bd):

    editmode = Window.EditMode()
    if editmode: Window.EditMode(0)


    a = pyqrcode.Qrcode()
    s = a.make_qrcode(st) 
    s = s.replace("
","")

    size = int( sqrt( len(s) ))

    w = 1.0 * 2
    offs = -(w/2)
    border = 4 + bd *6
    width = size + (border *2)
    d = w / width

    # make vertex
    coords=[]  
    for y in range( width +1):
        vy = offs + d * y
        for x in range( width +1):
            vx = offs + d * x
            coords.append( [vx,vy,0] )

    # add face
    faces= []

    for y in range( width):
        for x in range( width):
            idx = y * ( width +1 ) + x
            faces.append( [ idx , idx+1 , idx + width +1 +1 , idx + width+1 ])

    # add mesh
    me = bpy.data.meshes.new('qrmesh')
    me.verts.extend(coords)
    me.faces.extend(faces)

    # link ob and me
    scn = bpy.data.scenes.active
    ob = scn.objects.new(me, 'qrgrid')

    # add material
    matb = Material.New('qrbk') 
    matb.rgbCol = [0.0,0.0,0.0]
    matb.mode |= Material.Modes.SHADELESS

    matw = Material.New('qrwh') 
    matw.rgbCol = [1.0,1.0,1.0]
    matw.mode |= Material.Modes.SHADELESS

    # set Material
    ob.setMaterials([matw,matb])
    ob.colbits = (1&lt;&lt;0) +(1&lt;&lt;1)

    # color
    faces = me.faces

    c = 0
    for f in faces:
        x =( c % width ) - border
        y =( c / width ) - border

        if((( x &gt;= 0 )&( x &lt;size ))&(( y &gt;= 0 )&( y &lt;size ))):
            if(s[ (size - y -1 ) * size + x ]=='1'):
                f.mat = 1
            else:
                f.mat = 0
        else:
            f.mat = 0
          
        c = c + 1


    if editmode: Window.EditMode(1)

def main():
    TEXT_STRING= Draw.Create('')
    CFG_BORDER= Draw.Create(False)

    # Get USER Options
    pup_block= [\
    ('Text:', TEXT_STRING, 0, 50, 'QR string'),\
    ('Border', CFG_BORDER, 'BORDER')
    ]

    if not Draw.PupBlock('ADD Mesh QRGrid', pup_block):
        return

    addQRGrid(TEXT_STRING.val,CFG_BORDER.val)
    
if __name__ == '__main__':
    main()

youtube

thanks

I downloaded this from the blender scripts wiki page. I put in in the addon folder of Blender 2.68a. I enabled it. But when I press add—>QR Code I get this error in the console window

Read new prefs: C:\Users\DD\AppData\Roaming\Blender Foundation\Blender\2.68\conf
ig\userpref.blend
RuntimeError: class MESH_OT_primitive_qrcode, function execute: incompatible ret
urn value , str(, Function.result expected a set, not a str)

Can someone please tell me what the problem is. I really need this script

Sorry wrong script. The one I tried was for 2.69 this is a different script made for 2.49