This is a simple script I wrote for making a documentaion system of in blender docs. It’s not as good as html but this is a whole lot easier to render. This script takes text files and renders them in a better than text style.
This supports a few tags so far.
title: #makes the following text the title.
ex: #Executes this as part of the program and runs anything after the # sign.
back: index: fwd: # These are for links to other documents
Any line without a tag will just be printed as text.
Here is a small example file.
title:The Index
akjdhasdf
ex:apply(glColor3f, [0,1,0]) #Is it green
back:backfile.txt
index:indexfile.txt
fwd:fwdfile.txt
And the entire script
#**** BlendDoc ****
path = 'h:/'
file = 'BlendDoc.txt'
import sys
import Blender
from Blender.BGL import *
from Blender.Draw import *
f = ""
back = ""
fwd = ""
index = ""
def getWindowSize():
if (Blender.Get('version')<173):
size= Buffer(GL_FLOAT, None, 4)
glGetFloat(GL_SCISSOR_BOX, size)
size= BufList(size)
else:
size= Buffer(GL_FLOAT, 4)
glGetFloatv(GL_SCISSOR_BOX, size)
size= size.list
return size
def draw():
global f
global index
global fwd
global back
size = getWindowSize()
textpos = size[3]-35
f = open(path+file, "r")
glClearColor(0.333, 0.45, 0.620, 0.0)
glClear(GL_COLOR_BUFFER_BIT)
for line in f.readlines():
if line[:6] == "title:":
apply(glColor3f, [0,0,0])
glRectf(0,size[3],size[2],size[3]-20)
apply(glColor3f, [1,.62,.45])
glRectf(0+3,size[3]-3,size[2]-3,size[3]-17)
apply(glColor3f, [0,0,0])
glRasterPos2f(5,size[3]-15)
Text(line[6:])
elif line[:3] == "ex:":
exec(line[3:])
if "#" in line:
glRasterPos2f(3, textpos)
Text(line[line.index("#")+1:])
textpos = textpos - 15
elif line[:4] == "fwd:":
fwd = line[4:]
if fwd[len(fwd)-1] == "\012":
fwd = fwd[0:len(fwd)-1]
elif line[:5] == "back:":
back = line[5:]
if back[len(back)-1] == "\012":
back = back[0:len(back)-1]
elif line[:6] == "index:":
index = line[6:]
if index[len(index)-1] == "\012":
index = index[0:len(index)-1]
else:
apply(glColor3f, [1,1,.25])
glRasterPos2f(3, textpos)
Text(line)
textpos = textpos - 15
apply(glColor3f, [0,0,0])
glRectf(0,20,size[2],0)
apply(glColor3f, [1,.62,.45])
glRectf(0+3,17,size[2]-3,3)
if back != "":
Button("<< Back", 3, 3, 3, 60, 14)
if index != "":
Button("Index", 1, size[2]/2-20, 3, 40, 14)
if fwd != "":
Button("Fwd >>", 2, size[2]-60, 3, 60, 14)
def event(evt, val):
if (evt == QKEY):
f.close()
Exit()
def bevent(evt):
global file
global back
global index
global fwd
if evt == 3:
f.close()
file = back
print back
Redraw()
elif evt == 1:
f.close()
file = index
Redraw()
elif evt == 2:
f.close()
file = fwd
Redraw()
Register(draw, event, bevent)
Hope you enjoy. asdf_46