Python-howto, Python-Scripts and Plug-Ins

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Display Modes
  04 April 2005
i'm using mac osx 10.3 and blender 2.36 for this os and have been successfully running python scripts having put a file path in my preferences pane. recently i came back to blender after a 4 or 5 week lay off to find that it no longer works (!!). i get error messages such as

Traceback (most recent call last):

File "globLoc", line 7, in ?

ImportError: No module named Rasterizer

my python path (printed in the console as result of print sys.path) is:

['/System/Library/Frameworks/Python.framework/Versions/2.3/lib/', '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/', '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/lib-dynload', '/Applications/blender236/', '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages', '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/site-python', '/Users/andygracie/Library/Python/2.3/site-packages', '/System/Library/Frameworks/Python.framework/Versions/2.3/', '/Applications/blender236/']

i have not changed anything in my system or installed any other software or updates. could it be possible that my python installation is somehow 'broken'?? i have run disk/file maintenance software which has not cleared up the problem either.

any pointers very gratefully received.


andy g
  05 May 2005
Originally Posted by andy_g: Traceback (most recent call last):

File "globLoc", line 7, in ?

ImportError: No module named Rasterizer

which script? version? the script might not be for 2.36 + 2.3.x
bebo birras
  05 May 2005
well i was trying to make some tutorials for myself based on others i'd seen on the web. this is the first few lines i was running from starblenders tutorial at

import Rasterizer
import GameLogic
l = Rasterizer.getWindowWidth()
L = Rasterizer.getWindowHeight()
Print I, L

the funny thing is that when i was doing this originally it was working. that was a while ago and since i came back to it i'm getting all these errors. i HAVE just checked the website again and it states that the script is for 2.12 - though i did have it working succesfully when i was going through it with 2.36. i've checked other scripts such as and the l-system one that both work fine.

maybe i need to be looking at syntax not python problems... so what would be the correct syntax to make this simple bit of script work...?


andy g
  05 May 2005
Question Python 2.4?

I believe Python 2.3 is built into the current Blender release. I don't watn to install 2.3 just for Blender sicne I use 2.4 on WIndows and OS X now. Any problems with using 2.4 as long as I stay away from 2.4-only features?
  05 May 2005
You can install both, Blender will work without 2.3 but some scripts won't.

  05 May 2005
Originally Posted by surfingmarmot: I believe Python 2.3 is built into the current Blender release. I don't watn to install 2.3 just for Blender sicne I use 2.4 on WIndows and OS X now. Any problems with using 2.4 as long as I stay away from 2.4-only features?

I have both installed (on pc, not mac), and they sit quite peacefully side by side and support whichever application requires them. (they don't take up much space, either). Hopefully, that should be ok for macs too.

I have added a number of python scripts for blender (offered at the Blender site) and they all work quite nicely too.
नमस्ते Namasté
  06 June 2005
cant you please do one of these foe YAFRAY?!?! mine just doesnt want to work!

gogo gadget education.

  06 June 2005
Interactive Cylinder Generator

Hi Folks.

This script can be used to make cylinders interactively,

* As in changing parameters in the gui will update the mesh.

* You can also make quarter cylinders, half cylinders with variable segments.

* They can be tapered, so that some settings lead to cones and other interesting models.

* New Object is created at 3d cursor location.

* You can select/deselect top and bottom capping and if the cylinder is closed or not.

* The settings are temporarily saved in blender's registry, so that you can re-edit the selected object.

I have to make some low-level changes, but do report any bugs in this thread and features that you would like.

You can see the script in action in this video demonstration.

Copy this code into a blender text-window and ALT+P

 # Blender Cylinder Generator
 # Author: Satish Goda (
 # Date: June 22, 2005
 # License: None.
 # Tested using Blender 2.37. The text editor had a tabspacing of 2
 # Usage: Press ALT+P in the text window and play with the sliders
 import Blender
 from Blender import Text, Object, NMesh, Scene, Window, Draw, Registry
 from Blender.BGL import glColor3f, glRectf, glRasterPos2i
 from math import cos, sin, tan, fabs, radians
 # function pointers to module functions
 Keys = Registry.Keys
 GetKey = Registry.GetKey
 SetKey = Registry.SetKey
 Face = NMesh.Face
 Button = Draw.Button
 DrawText = Draw.Text
 NewText = Text.New
 GetText = Text.Get
 Slider = Draw.Slider
 Toggle = Draw.Toggle
 # dictionary of all widgets and some of their properties
 dwidget = {
 	'h': 		[None, 5.0, "The height of the cylinder."],
 	'ang':	[None, 0.0, "Taper angle. If angle = 0.0, its a cylinder."],
 	'seg': 	[None, 5, "Number of segments in the object"], 
 	'brad': [None, 5.0, "The base radius of the cylinder."],
 	'turn': [None, 360.0, "Sweep angle of the cylinder."],
 	'tface': [None, 1, "Chose if the cylinder has a top face"],
 	'bface': [None, 1, "Choose if the cylinder has a bottom face"],
 	'closed': [None, 1, "Choose if the solid is closed or not if sweep < 360 degrees.", "Warning%t|Since turn == 360, toggle does not affect."],
 	'newob': [None, 0, "Create a new object"],
 	'selob': [None, 0, "Modify the selected object."],
 	'copyfrom': [None, 0, "Apply settings from the selected object."],
 	'quit': [None, 0, "Quit this script"],	
 datum = ['h', 'ang', 'seg', 'brad', 'turn', 'tface', 'bface', 'closed']
 newline, tab = '\n', '\t'
 skname = "BICG"
 selobname = None
 ob, me, sc, dBICG  = None, None, None, None
 def InitDataFile():
 	global dBICG
 	dBICG = GetKey(skname)
 	if not dBICG:
 		dBICG = d = {}
 		SetKey(skname, d)
 def DeselectAllObjects():
 	for object in Object.GetSelected():
 def GenerateVertices(me, rad, isegs, h, turn):
 	fanglestep = turn /float(isegs)
 	fangle = 0.0
 	while fangle < turn:
 		x = rad * cos(radians(fangle))
 		y = rad * sin(radians(fangle))
 		vert = NMesh.Vert(x, y, h)
 		fangle += fanglestep
 def AddFace(me, fil):	
 	vl = me.verts
 	facelist = [vl[index] for index in fil]
 def GenerateFaces(me, turn, tface, bface, closed):
 	vl = me.verts
 	length = len(me.verts)
 	offset = 2
 	segs = int((length-offset)/2)	
 	# get the index of the top and bottom vertices
 	if tface or bface:	tvi, bvi = length-2, length-1
 	ra = range(0, segs)
 	for index in ra:
 		if turn < 360.0 and closed:
 			if index == ra[0]:
 		    	vi1, vi2, vi3, vi4 = index, length-2, length-1, index+segs
 				AddFace(me, [vi1, vi2, vi3, vi4])
 			if index == ra[-1]:
 		    	vi1, vi2, vi3, vi4 = index, index+segs, length-1, length-2
 				AddFace(me, [vi1, vi2, vi3, vi4])
 		if (turn == 360.0) or ((turn < 360.0) and (not closed) and (index != ra[-1])) or (closed and (index != ra[-1])):
 			vi1, vi4, vi2, vi3 = index, index+1, index+segs, index+segs+1
 			if vi4 == segs: vi4 = vi4 % segs
 			if vi3 == segs*2: vi3 = (vi3 % segs) + segs
 			AddFace(me, [vi1, vi2, vi3, vi4])
 			if tface:	AddFace(me, [tvi, vi1, vi4])
 			if bface:	AddFace(me, [bvi, vi2, vi3])
 # Function to generate any isolated vertices
 def GenerateVertex(me, x, y, z):
 	vert = NMesh.Vert(x, y, z)
 # clear vertex and face lists of the mesh from last update
 def ClearMeshGeometry(me):
 	del me.verts[:]
 	del me.faces[:]	
 # update the settings of the widgets
 def SetData(sdata, ui):
 	global datum
 	for ddata in datum:
 		ui[ddata][1] = sdata[index]
 		index += 1
 # retrieve settings from the user-interface elements
 def GetData(ui):
 	return [ ui[data][1] for data in datum]
 # Called whenever user-settings change 	
 # and at script start with default settings
 def UpdateMesh():
 	global ob, me, sc, dwidget
 	# get input parameters to generate the cylinder
 	h, angle, isegs, baserad, turn, tface, bface, closed = GetData(dwidget)
 	toprad = baserad - (h * tan(radians(angle)))
 	# NOTE: to avoid getting weird shapes, uncomment the line below
 	toprad = fabs(toprad)
 	# generate the vertices of the top circle and base circle
 	GenerateVertices(me, toprad, isegs, h, turn)
 	GenerateVertices(me, baserad, isegs, 0.0, turn)
 	# make a vertex at top-center and bottom-center
 	GenerateVertex(me, 0.0, 0.0, h)
 	GenerateVertex(me, 0.0, 0.0, 0.0)
 	# Generate face list
 	GenerateFaces(me, turn, tface, bface, closed)
 	# update the mesh
 def DrawWidgets():
 	global dwidget
 	dwidget['newob'][0]   = Button("New", 10009, 10, 10, 200/4, 20, dwidget['newob'][2])
 	dwidget['copyfrom'][0]   = Button("Copy", 10011, 200/4+10, 10, 200/4, 20, dwidget['copyfrom'][2])
 	dwidget['selob'][0]   = Button("Sel", 10010, 400/4+10, 10, 200/4, 20, dwidget['selob'][2])
 	dwidget['quit'][0]	= Button("Quit", 10008, 600/4+10, 10, 200/4, 20, dwidget['quit'][2])
 	dwidget['h'][0]     	  =  Slider("height : ", 10000, 10, 10+25, 200, 20, dwidget['h'][1], 2.0, 10.0, 1, dwidget['h'][2])
 	dwidget['ang'][0]	 = Slider("angle : ", 10001, 10, 10+25*2, 200, 20, dwidget['ang'][1], 0.0, 89.0, 1, dwidget['ang'][2])
 	dwidget['seg'][0] 	  = Slider("segments : ", 10002, 10, 10+25*3, 200, 20, dwidget['seg'][1], 3, 200, 1, dwidget['seg'][2])		
 	dwidget['brad'][0]	  = Slider("base radius : ", 10003, 10, 10+25*4, 200, 20, dwidget['brad'][1], 3.0, 15.0, 1, dwidget['brad'][2])
 	dwidget['turn'][0]	  = Slider("turn : ", 10004, 10, 10+25*5, 200, 20, dwidget['turn'][1], 5.0, 360.0, 1, dwidget['turn'][2])	
 	dwidget['tface'][0]   = Toggle("top", 10005, 10, 10+25*6, 200/3, 20, dwidget['tface'][1], dwidget['tface'][2])
 	dwidget['bface'][0]   = Toggle("bottom", 10006, 200/3 + 10, 10+25*6, 200/3, 20, dwidget['bface'][1], dwidget['bface'][2])
 	dwidget['closed'][0]  = Toggle("closed", 10007, 400/3 + 10, 10+25*6, 200/3, 20, dwidget['closed'][1], dwidget['closed'][2])	
 def DrawBanner():
 	x, y = 10.0, float(10+25*7)
 	w, h = 200.0, 50.0
 	glColor3f(0.3, 0.3, 0.3)
 	glRectf(x, y, x+w, y+h)
 	glColor3f(1.0, 1.0, 1.0)		
 	glRasterPos2i(int(x+5), int(y+5))
 	DrawText("by Satish 'iluvblender' Goda",'small')		
 	glRasterPos2i(int(x+5), int(y+20))
 	DrawText("Blender 2.37")
 	glRasterPos2i(int(x+5), int(y+35))
 	DrawText("Interactive Cylinder Generator")
 def ManageDisplay():
 # Save the name of the object and its data
 def DumpData():
 	global ob, dBICG, dwidget
 	if ob:
 		dBICG[] = GetData(dwidget)
 		SetKey(skname, dBICG)
 def Terminate():
 def ManageEvent(evt, val): 
 	if evt == Draw.QKEY: Terminate()
 def UpdateSlider(slider):
 	slider[1] = slider[0].val
 def UpdateToggle(toggle):
 	toggle[1] = toggle[0].val
 def NewObject(flag):
 	global ob, me, sc
 	if flag == 1: DumpData()
 	sc = Scene.GetCurrent()
 	cursorpos = Window.GetCursorPos()
 	ob = Object.New('Mesh', 'Cyl_')
 	me = NMesh.New('MyCylMesh')
 # Load the settings of the selected object into the GUI
 def LoadSettings(targetob):
 	notloaded = 0
 		data = dBICG[targetob]
 		SetData(data, dwidget)
 		return not notloaded
 	except KeyError:
 		Draw.PupMenu("ERROR: OOPS. This objects data does not exist in the registry.")	
 		return notloaded
 def CheckSelection():
 	selob = Object.GetSelected()
 	if not selob: 
 		Draw.PupMenu("Warning%t|Please make a selection.")
 	elif ob and selob[0].name == 
 		Draw.PupMenu("Warning%t|Object already selected.")
 		return selob[0]
 	return None
 def CopyFromObject():
 	sob = CheckSelection()
 	if sob: LoadSettings(
 def SelectedObject():
 	global ob, me
 	sob = CheckSelection()
 	if sob:
 		if LoadSettings(
 			ob, me = sob,		
 def ManageWidgets(evt):
 	global dwidget, ob, me
 	if evt == 10000: UpdateSlider(dwidget['h'])
 	if evt == 10001: UpdateSlider(dwidget['ang'])
 	if evt == 10002: UpdateSlider(dwidget['seg'])
 	if evt == 10003: UpdateSlider(dwidget['brad'])
 	if evt == 10004: UpdateSlider(dwidget['turn'])	
 	if evt == 10005: UpdateToggle(dwidget['tface'])	
 	if evt == 10006: UpdateToggle(dwidget['bface'])
 	if evt == 10007:
 		if dwidget['turn'][1] == 360.0: Draw.PupMenu(dwidget['closed'][3])
 		else: UpdateToggle(dwidget['closed'])
 	if evt == 10008: Terminate()
 	if evt == 10009: NewObject(1)
 	if evt == 10010: SelectedObject()
 	if evt == 10011: CopyFromObject()	
 	if ob and me: UpdateMesh()
 # called at script start
 Draw.Register(ManageDisplay, ManageEvent, ManageWidgets)
My Free Blender Training Modules

Last edited by iluvgfx : 06 June 2005 at 04:02 PM. Reason: bugfixed code
  06 June 2005

People, I'm sorry my previous post was ambiguous.. when I said I added some plugins, I meant that I downloaded them and added them to my blender! I can't program Python!
sooo sorry if I mislead you ... (blushing furiously)

iluvgfx ... that looks so cool! a plugin that could be very useful...

arbzervor .... nice photography!
नमस्ते Namasté

Last edited by butterpaw : 06 June 2005 at 04:04 PM.
  06 June 2005
Thank you butterpaw.

I will be extending this to all primitives. I just added the bug-fixed code.
My Free Blender Training Modules
  07 July 2005
rasterizer & gamelogic work only in game engine so it can be your error
 ImportError: No module named Rasterizer

  09 September 2005
7 seq plugins

edit: I decided to just link to the elysiun threads for my plugins as the versions have changed so much that it was hard to keep the individual links up to date...

zutilz: zbuffer utilities...mask by z, easy depth maps, insert a zbuffer into a previously rendered pic

framestamp:stamp an image with frame #, time, image name, added text

chromakey-hsv: hsv based chromakey with a few basic compositing features

my yasp (yet another seq plugin) thread...4 so far:
filter: simple 3x3 filter plugin
adjust-hsv: adjust color, brightness, contrast and gamma
layer: gimp like layer blending modes
g-blur: gaussian blur for the seq editor

Last edited by paprmh : 12 December 2005 at 03:36 AM.
  01 January 2006
Originally Posted by bbirras: Now open a new text window in blender and ...

How do I do this?
  01 January 2006
Each window header has a Window-Menu icon on the left. One of the options is the Text Editor. Or you can open it with Shft-F11 with your Mouse Cursor in the relevant window.
  01 January 2006
Ok, so how do I type in that?
reply share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 08:15 PM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.