Homemaker


(!Rocky) #1

This is my first Python script ever, and as such it may be rather primitive. Also, it was inspired by a dream, so do not expect anything extraordinary. It just generates 9-faced house-like meshes.

Many thanks to Timmo – without his courtain generating script for inspiration, this one would not have existed. Thanks, man :slight_smile:

So, here it is:

#!BPY

"""
Name: 'Homemaker'
Blender: 237
Group: 'Mesh'
Tip: 'Creates VERY simple house-like meshes'
"""

from Blender import *
import math
import sys

mesh = NMesh.New()

###
# valori
###

x = Mathutils.Rand (-5,5)
y = Mathutils.Rand (-5,5)
hp = Mathutils.Rand (0,5)
hs = Mathutils.Rand (1,2)
w = Mathutils.Rand (2,4)
l = Mathutils.Rand (2,6)
semi = x + (w/2)

###
# vertecsi
###

a = NMesh.Vert (x,y,0)
b = NMesh.Vert ((x+w),y,0)
c = NMesh.Vert ((x+w),(y+l),0)
d = NMesh.Vert (x,(y+l),0)
e = NMesh.Vert (x,y,hp)
f = NMesh.Vert ((x+w),y,hp)
g = NMesh.Vert ((x+w),(y+l),hp)
h = NMesh.Vert (x,(y+l),hp)
i = NMesh.Vert (semi,y,(hp+hs))
j = NMesh.Vert (semi,(y+l),(hp+hs))

mesh.verts.append (a)
mesh.verts.append (b)
mesh.verts.append (c)
mesh.verts.append (d)
mesh.verts.append (e)
mesh.verts.append (f)
mesh.verts.append (g)
mesh.verts.append (h)
mesh.verts.append (i)
mesh.verts.append (j)

###
# poligoane
###

abcd = NMesh.Face ([a,b,c,d])
abfe = NMesh.Face ([a,b,f,e])
bcgf = NMesh.Face ([b,c,g,f])
cdhg = NMesh.Face ([c,d,h,g])
daeh = NMesh.Face ([d,a,e,h])
efi = NMesh.Face ([e,f,i])
ghj = NMesh.Face ([g,h,j])
fgji = NMesh.Face ([f,g,j,i])
heij = NMesh.Face ([h,e,i,j])

mesh.faces.append (abcd)
mesh.faces.append (abfe)
mesh.faces.append (bcgf)
mesh.faces.append (cdhg)
mesh.faces.append (daeh)
mesh.faces.append (efi)
mesh.faces.append (ghj)
mesh.faces.append (fgji)
mesh.faces.append (heij)

###
# creare
###

obj = Object.New ("Mesh", "Casa")
obj.link (mesh)

Scene.GetCurrent().link(obj)

###
# magick
###

Redraw ()

Crits, comments and death threats appreciated :slight_smile:

[EDIT]
Could someone please write a small GUI? I’m thinking something along the lines of a big button that you push, and it creates a house… I’ve no idea how to do that.

[EDIT 2]
Yes, I realise the name’s retarded. I’m open to suggestions :slight_smile:

[EDIT 3 OMG]
This is what the updated version of the script does (in Edit mode, so you can see the verts/edges):

http://img.photobucket.com/albums/v234/professor_destiny/demo_script.jpg

Scroll down for the new version :slight_smile:


(Crouch) #2

It’s nice for a first script. It seems to be working ok, and the random placement of the houses, size and shape of them is a good feature.
About the GUI; I suggest you try to create it yourself. Search an easy little script with a GUI and have a look what part of the code takes care of the interface. In this way you’ll learn most of it.
If you can’t figure it out, or don’t want to do it this way, just tell and I’ll try to help with it (I’m quite a noob at python myself actually).

PS: since you asked for it; if you don’t react to this message, you’d better start training to dodge bullets. :stuck_out_tongue:


(!Rocky) #3

After looking through other scripts, I think I have the right code (link here); however, the Redraw thing doesn’t work – ie, I only see the result if I switch the view.

So, um… help?


(Crouch) #4

I get an error trying that link. Even when I try to access it from the directory it is in, or type the url directly into my browser I get an error.


(serendipiti) #5

Hi.

That code link produces a “500 Internal Server Error” message so the code is inaccessable.

As for the Redraw problem, you know that there are two Redraw functions .

Blender.Redraw() redraws all the 3d windows, as in your first script.
Draw.Redraw() redraws the current script window, the one with your gui.

It’s just a guess, but adding a gui may have mixed them up. You may need to specify them by name to get the result you want.

A fun script, keep going.

andy


(!Rocky) #6

Hey guys! Thanks for the comments :slight_smile:

First off – weird, the link works for me o__O I’ll attach the code, anyway.

Now, I’ve added another import, and surprisingly enough, it worked o_O No idea why, tho.

Enough, here’s the code:

#!BPY

"""
Name: 'Homemaker'
Blender: 237
Group: 'Mesh'
Tip: 'Creates VERY simple house-like meshes'
"""

import Blender
from Blender import *
from Blender.Draw import *

def buton ():
	Button ('Generate', 1, 50, 50, 100, 25, '')

def exit (evt, val):
	if (evt == QKEY and not val):
		Exit()

def event (ev):
	if ev == 1:
		mesh = NMesh.New()

		x = Mathutils.Rand (-5,5)
		y = Mathutils.Rand (-5,5)
		hp = Mathutils.Rand (0,5)
		hs = Mathutils.Rand (1,2)
		w = Mathutils.Rand (2,4)
		l = Mathutils.Rand (2,6)
		semi = x + (w/2)

		a = NMesh.Vert (x,y,0)
		b = NMesh.Vert ((x+w),y,0)
		c = NMesh.Vert ((x+w),(y+l),0)
		d = NMesh.Vert (x,(y+l),0)
		e = NMesh.Vert (x,y,hp)
		f = NMesh.Vert ((x+w),y,hp)
		g = NMesh.Vert ((x+w),(y+l),hp)
		h = NMesh.Vert (x,(y+l),hp)
		i = NMesh.Vert (semi,y,(hp+hs))
		j = NMesh.Vert (semi,(y+l),(hp+hs))

		mesh.verts.append (a)
		mesh.verts.append (b)
		mesh.verts.append (c)
		mesh.verts.append (d)
		mesh.verts.append (e)
		mesh.verts.append (f)
		mesh.verts.append (g)
		mesh.verts.append (h)
		mesh.verts.append (i)
		mesh.verts.append (j)

		abcd = NMesh.Face ([a,b,c,d])
		abfe = NMesh.Face ([a,b,f,e])
		bcgf = NMesh.Face ([b,c,g,f])
		cdhg = NMesh.Face ([c,d,h,g])
		daeh = NMesh.Face ([d,a,e,h])
		efi = NMesh.Face ([e,f,i])
		ghj = NMesh.Face ([g,h,j])
		fgji = NMesh.Face ([f,g,j,i])
		heij = NMesh.Face ([h,e,i,j])

		mesh.faces.append (abcd)
		mesh.faces.append (abfe)
		mesh.faces.append (bcgf)
		mesh.faces.append (cdhg)
		mesh.faces.append (daeh)
		mesh.faces.append (efi)
		mesh.faces.append (ghj)
		mesh.faces.append (fgji)
		mesh.faces.append (heij)

		obj = Object.New ("Mesh", "Casa")
		obj.link (mesh)

		Scene.GetCurrent().link(obj)

		Blender.Redraw()

Register (buton, exit, event)

(Crouch) #7

Congratulations on getting it to work! Now the fun part starts; adding extra functionality. For example adding buttons to the GUI to define minimum and maximum deviations of size and location.

Here are some suggestions to clean up the code a bit (even though it is already very clean):

  • remove ‘import math’ (line 13), it serves no function
  • remove ‘import sys’ (line 14), it serves no function
  • line 18: change 500 to 50. 500 counting from the bottom is quite high to place a button. At first it was even invisible for me.

Have fun with scripting and continue to help the community by creating great scripts for everybody!


(reaper) #8

Can you also post a screenshot or rendered image at the beginning of this thread to let people know exactly what it does?


(!Rocky) #9

Crouch: Removed those, thanks :slight_smile:

reaper: For some reason I thought I’d posted one o__O I need coffee.


(timmeh) #10

i’m glad i can be so inspirational :smiley:

most people dont realise how useful python can be for automating a tedious task like making curtains or a house model.

anyway i think this script could be turned into something very cool if you had it create an entire neighbourhood.

timmeh


(!Rocky) #11

Actually, I was thinking about that earlier today :slight_smile: Well, actually, about creating several houses at once. However, I have no idea how to make sure no two houses overlap. Nor, for that matter, how to create integers.

Any tips?


(cryptic) #12

hey !Rocky

i realy liek your script , i want to add onto what is there , already

but im new to python

as it is i would like to either have the user enter the random numbers to generate the house or they can random generate a house.

would you think its possible to add some detailed comments within your codeto help me follow what you were trying to do.

Thanks


(cryptic) #13

hey guys .

I have been working on this script for a few hours now. im very new to python but i do know other languages.

I have added a debug consol to the script and a form which the user should be able to select there x,y and other values to generate a more custom house.

as you will be able to see the script works the same as above .
when i do run the input from the form i get error :

Traceback (most recent call last):
File “<string>” , line 113, in event
TypeError: float() argument must be a string or a number

%|
From this i assume i must convery my input froom the number button to a float like the ones sean in the debug made from the random number function.
please help me sort this bug out , i want to make this script ausome.


#!BPY

"""
Name: 'HomeMaker'
Blender: 237
Group: 'Mesh'
Tip: 'Creates VERY simple house-like meshes'
"""
# basic source - url - http://www.elysiun.com/forum/viewtopic.php?t=45593
import Blender
from Blender import *
from Blender.Draw import *

# Define the action buttons here
# Must start with a E_ 
E_DEBUG    = 1 # 1 for debug to be on.0 for off.
E_EXIT     = 10	# also set to QKEY
E_RANDOM   = 1
E_CUSTOM   = 2
E_CUSTOM_NAME = 'Create a custom building.'
E_RANDOM_NAME = 'Click to generate a Random sized house.'
print " HomeMaker 0.2"
if (E_DEBUG == 1):
  print "&gt;&gt; Debug Mode ON" # [ you can switch this by the debug button in your GUI ]"
#size=Buffer(GL_FLOAT, 4)
#  glGetFloatv(GL_SCISSOR_BOX, size)
#size= size.list
# Create the action buttons here
def buton ():
  global xC, yC, hpC, hsC, wC, lC
  # Button functions.
  # Button(label, event, x, y, width, height, [tooltip])
  # Number(label, event, x, y, width, height, initial, min, max, [tooltip])
  # Scrollbar(event, x, y, width, height, initial, min, max, [update, tooltip])
  # Slider(label, event, x, y, width, height, initial, min, max, [update, tooltip])
  # String(label, event, x, y, width, height, initial, length, [tooltip])
  # Toggle(label, event, x, y, width, height, default, [tooltip])

  Button ('Custom House', E_CUSTOM, 50, 410, 160, 25, E_CUSTOM_NAME)
  # House Values for your Custom House.
  xC  = Number('X', 6, 50, 390, 100, 15, 1, -5, 5, 'X Value')
  yC  = Number('Y', 6, 50, 375, 100, 15, 1, -5, 5, 'Y Value')
  hpC = Number('HP', 6, 50, 360, 100, 15, 1, 0, 5, 'HP Value')
  hsC = Number('HS', 6, 50, 345, 100, 15, 1, 1, 2, 'HS Value')
  wC  = Number('W', 6, 50, 330, 100, 15, 2, 2, 4, 'W Value')
  lC  = Number('L', 6, 50, 315, 100, 15, 2, 2, 6, 'L Value')
  #Scrollbar('Height', 100, 100, 50, 30, 1, 0, 10, 'Select Height of your House')
  #Slider('Height', 1, 150, size[3]-n0-198 , 200, 100, 5, 1, 10, 'Select house value')
  #Slider("offset", 1, 40 , size[3]-n0-198 , 175, 20 , offsetBout.val, -5.0,+5.0,0,)
  #String('String', 5, 50, 150, 200, 20, 10, 250, 'String tip')
  Toggle('Debug', 4, 50, 120, 100, 20, 1, 'toggle tip')
  Button ('Generate', E_RANDOM, 50, 50, 100, 25, E_RANDOM_NAME)
  #Number('Number', 6, 50, 180, 200, 20, 1, 0, 10, 'Number tip')
  #Scrollbar('Scrollbar', 50, 240, 200, 20, 1, 0, 10, 'Update','Tip')


def exit (evt, val):
  if (evt == QKEY and not val):
    Exit()

def event (ev):
  global xC
  global yC
  global hpC
  global hsC
  global wC
  global lC
  
  if ev == 6:
    # event called when a user selects the number values.
    if (E_DEBUG == 1):
      print "&gt;&gt; Button selected"
      print "x  = ",xC
      print "y  = ",yC
      print "hp = ",hpC
      print "hs = ",hsC
      print "w  = ",wC
      print "l  = ",lC

  if ev == 2:
    # Draw a custom house selected by the user.
    if (E_DEBUG == 1):
      print "&gt;&gt; Create a Custom house with the following cordinates."
      print "x  = ",xC
      print "y  = ",yC
      print "hp = ",hpC
      print "hs = ",hsC
      print "w  = ",wC
      print "l  = ",lC
    
    # could add a cheeky hack here to try get the floats correct 
    # select a random from the point the user chose to 1 int above it.
    
    # TODO : figure out adding numbers to a int or make the float correctly
    # if i can do this the form section will work correctly
    # built-in functions int(), long(), and float() convert inputs
    # int(float('0.0123456789'))
    #xC2  = int(xC)+1
    #yC2  = int(yC)+1
    #hpC2 = int(hpC)+1
    #hsC2 = int(hsC)+1
    #wC2  = int(wC)+1
    #lC2  = int(lC)+1
    #x    = Mathutils.Rand (xC,xC2)
    #y    = Mathutils.Rand (yC,yC2)
    #hp   = Mathutils.Rand (hpC,hpC2)
    #hs   = Mathutils.Rand (hsC,hsC2)
    #w    = Mathutils.Rand (wC,wC2)
    #l    = Mathutils.Rand (lC,lC2)
    #semi = xC2 + (wC2/2)
    
    x  = float(xC)
    y  = float(yC)
    hp = float(hpC)
    hs = float(hsC)
    w  = float(wC)
    l  = float(lC)
    
    if (E_DEBUG == 1):
      print " &gt;&gt; new values"
      print "x  = ",x
      print "y  = ",y
      print "hp = ",hp
      print "hs = ",hs
      print "w  = ",w
      print "l  = ",l
      print "semi  = ",semi
    #x = int(xC)
    #y = int(yC)
    #hp = int(hpC)
    #hs = int(hsC)
    #w = int(wC)
    #l = int(lC)
    #semi = xC + (wC/2)
    #CreateHouse(xC, yC, hpC, hsC, wC, lC, 3.99604322016)
    CreateHouse(x, y, hp, hs, w, l, semi)
    #CreateHouse(-1.67735946365, -2.92192997411, 2.13155810256, 1.29031124152, 2.51938086469, 5.95548190922, 3.99604322016)
    return
  elif ev == 1:
    # user does not know what he wants so draw a random house.
    # Draw a random size house for the user.
    # Returns a random number eg: 2.03430345967
    x = Mathutils.Rand (-5,5)
    y = Mathutils.Rand (-5,5)
    hp = Mathutils.Rand (0,5)
    hs = Mathutils.Rand (1,2)
    w = Mathutils.Rand (2,4)
    l = Mathutils.Rand (2,6)
    semi = x + (w/2)
    if (E_DEBUG == 1):
      print "&gt;&gt; Random House Generated."
      print "x  = ",x
      print "y  = ",y
      print "hp = ",hp
      print "hs = ",hs
      print "w  = ",w
      print "l  = ",l
      print "semi = ",semi
    CreateHouse(x, y, hp, hs, w, l, semi)
    return
Register (buton, exit, event)


# Main Function to use when drawing a simple block house.
def CreateHouse(x, y, hp, hs, w, l, semi):
  if (E_DEBUG == 1):
    print "&gt;&gt; Inside CreateHouse"
    print "x  = ",x
    print "y  = ",y
    print "hp = ",hp
    print "hs = ",hs
    print "w  = ",w
    print "l  = ",l
    print "semi = ",semi
  mesh = NMesh.New()
  # Method: NMesh.Vert([x, y, z])
  # Returns a new NMVert object, created from the given x,y,and z coordinates. If any of the coordinates are not passed they default to 0.0.

  a = NMesh.Vert (x,y,0)
  b = NMesh.Vert ((x+w),y,0)
  c = NMesh.Vert ((x+w),(y+l),0)
  d = NMesh.Vert (x,(y+l),0)
  e = NMesh.Vert (x,y,hp)
  f = NMesh.Vert ((x+w),y,hp)
  g = NMesh.Vert ((x+w),(y+l),hp)
  h = NMesh.Vert (x,(y+l),hp)
  i = NMesh.Vert (semi,y,(hp+hs))
  j = NMesh.Vert (semi,(y+l),(hp+hs))

  mesh.verts.append (a)
  mesh.verts.append (b)
  mesh.verts.append (c)
  mesh.verts.append (d)
  mesh.verts.append (e)
  mesh.verts.append (f)
  mesh.verts.append (g)
  mesh.verts.append (h)
  mesh.verts.append (i)
  mesh.verts.append (j)

  # Method: NMesh.Face()
  # Face() Return a new NMCol object created from the given r,g,b, and a color components. If any of the components are not passed they default to 255.
  
  abcd = NMesh.Face ([a,b,c,d])
  abfe = NMesh.Face ([a,b,f,e])
  bcgf = NMesh.Face ([b,c,g,f])
  cdhg = NMesh.Face ([c,d,h,g])
  daeh = NMesh.Face ([d,a,e,h])
  efi = NMesh.Face ([e,f,i])
  ghj = NMesh.Face ([g,h,j])
  fgji = NMesh.Face ([f,g,j,i])
  heij = NMesh.Face ([h,e,i,j])

# these dimensions are taken from the frount camera view.
# These are each pannel that will be placed and put together.
  mesh.faces.append (abcd)		# Floor
  mesh.faces.append (abfe)		# Frount Wall
  mesh.faces.append (bcgf)		# Right Wall
  mesh.faces.append (cdhg)		# Back Wall
  mesh.faces.append (daeh)		# Left Wall
  mesh.faces.append (efi)		# Frount Roof Triangle
  mesh.faces.append (ghj)		# Back Roof Triangle
  mesh.faces.append (fgji)		# Right Roof 
  mesh.faces.append (heij)		# Left Roof

  # New Mesh Object will be created from the values set in our mesh object.
  obj = Object.New ("Mesh", "AidansHome")
  obj.link (mesh)

  Scene.GetCurrent().link(obj)
# Method: Blender.Redraw()
# This function forces an immediate redraw of all 3D windows in the current screen. It can be used to force display of updated information (for example when an IPO curve for an Object has been changed).
  Blender.Redraw()

Register (buton, exit, event)


(cryptic) #14

Hey gusy any ideas on what we can do here?
:expressionless:


(BlenderMan2) #15

cool i was thinkg about ideas like (i forget whos) random landscape genrator you could make like sheds cars roads houes and all other things and make them randomly genrate them or give settings like how much trees or somehting LOL but i guess thats a LONG way away GREAT WORK!

and

Is there any way to copy and paste a script into python LOL i hate writing out scripts that big unless i’m writing them from my own ideas lol i will wirte them out but i wisht there was a way to copy and paste or maybe someone could post a .blend witht he script allready written


(Fligh) #16

Copy it as usual and paste into notepad. Use “All files” and save it with a “.py” extension.

%<


(BlenderMan2) #17

Thx

Sorry for spamming lol :stuck_out_tongue:


(cryptic) #18

i was thinking of changing the buttons from a number button to a slider button.
this might do the trick i think.


(Calvin) #19

Shift+Ctrl+C
Shift+Ctrl+V


(cryptic) #20

I have managed to modifie the script to include a button style and a slider style interface to creating a house,

this is sothat you dont have to mod a randomly generated one. the random one is still in this script.


#!BPY

"""
Name: 'Home Designer'
Blender: 237
Group: 'Mesh'
Tip: 'Creates VERY simple house-like meshes'
"""
# basic source - url - http://www.elysiun.com/forum/viewtopic.php?t=45593
import Blender
from Blender import *
from Blender.Draw import *

# Define the action buttons here
# Must start with a E_ 
E_DEBUG    = 1 # 1 for debug to be on.0 for off.
E_EXIT     = 10	# also set to QKEY
E_RANDOM   = 1
E_CUSTOM   = 2
E_CUSTOM_SLIDER   = 3
E_CUSTOM_NAME = 'Create a custom building'
E_CUSTOM_NAME2 = 'Create a custom building [sliders]'
E_RANDOM_NAME = 'Click to generate a Random sized house.'
dist = Create(0.2)
dist1 = Create(1.2)
dist2 = Create(2.2)
dist3 = Create(3.2)

negfive = Create(-5.0)
zero = Create(0.0)
one = Create(1.0)
two = Create(2.0)
three = Create(3.0)
four = Create(4.0)
five = Create(5.0)
six = Create(6.0)
print " Home Designer 0.3"
if (E_DEBUG == 1):
  print "&gt;&gt; Debug Mode ON" # [ you can switch this by the debug button in your GUI ]"
#size=Buffer(GL_FLOAT, 4)
#  glGetFloatv(GL_SCISSOR_BOX, size)
#size= size.list
# Create the action buttons here
def buton ():
  global xC, yC, hpC, hsC, wC, lC, xC2, yC2, hpC2, hsC2, wC2, lC2, Toggle
  # Button functions.
  # Button(label, event, x, y, width, height, [tooltip])
  # Number(label, event, x, y, width, height, initial, min, max, [tooltip])
  # Scrollbar(event, x, y, width, height, initial, min, max, [update, tooltip])
  # Slider(label, event, x, y, width, height, initial, min, max, [update, tooltip])
  # String(label, event, x, y, width, height, initial, length, [tooltip])
  # Toggle(label, event, x, y, width, height, default, [tooltip])

  Button ('Custom House', E_CUSTOM, 50, 410, 160, 25, E_CUSTOM_NAME)
  Button ('Custom House 2', E_CUSTOM_SLIDER, 50, 160, 160, 25, E_CUSTOM_NAME2)
  # House Values for your Custom House.
  xC  = Number('X', 6, 50, 390, 100, 15, 1, -5, 5, 'X Value')
  yC  = Number('Y', 6, 50, 375, 100, 15, 1, -5, 5, 'Y Value')
  hpC = Number('HP', 6, 50, 360, 100, 15, 1, 0, 5, 'HP Value')
  hsC = Number('HS', 6, 50, 345, 100, 15, 1, 1, 2, 'HS Value')
  wC  = Number('W', 6, 50, 330, 100, 15, 2, 2, 4, 'W Value')
  lC  = Number('L', 6, 50, 315, 100, 15, 2, 2, 6, 'L Value')
  
  #slider = Slider("slider",12,20,170,200,18,slider.val,-10,10,0,"X Value")
  xC2 = Slider("xC ",7,50,290,150,20,dist.val,negfive.val,five.val,0,"Size of value X")
  yC2 = Slider("yC ",7,50,270,150,20,dist.val,negfive.val,five.val,0,"Size of value Y")
  hpC2 = Slider("hpC ",7,50,250,150,20,dist1.val,zero.val,five.val,0,"Size of value HP")
  hsC2 = Slider("hsC ",7,50,230,150,20,dist1.val,one.val,two.val,0,"Size of value HS")
  wC2 = Slider("wC ",7,50,210,150,20,dist3.val,two.val,four.val,0,"Size of value W")
  lC2 = Slider("lC ",7,50,190,150,20,dist3.val,two.val,four.val,0,"Size of value L")

  
  #lacunarityBout=Slider("lacunarity", E_NOISELAC ,40  ,size[3]-n0-158 ,175,20, lacunarityBout.val, -4.0,+4.0,0,)
  #lacunarityBout=Slider("lacunarity", E_NOISELAC ,40  ,size[3]-n0-158 ,175,20, lacunarityBout.val, -4.0,+4.0,0,)
  #octavesBout=Slider("octave",        E_NOISEOCT  ,40  ,size[3]-n0-178 ,175,20, octavesBout.val, -10.0,+10.0,0,)
  #offsetBout=Slider("offset",         E_NOISEOFF  ,40  ,size[3]-n0-198 ,175,20, offsetBout.val, -5.0,+5.0,0,)

  #Scrollbar('Height', 100, 100, 50, 30, 1, 0, 10, 'Select Height of your House')
  #Slider('Height', 1, 150, size[3]-n0-198 , 200, 100, 5, 1, 10, 'Select house value')
  #Slider("offset", 1, 40 , size[3]-n0-198 , 175, 20 , offsetBout.val, -5.0,+5.0,0,)
  #String('String', 5, 50, 150, 200, 20, 10, 250, 'String tip')
  Toggle('Debug', 4, 50, 120, 100, 20, 1, 'toggle tip')
  Button ('Generate', E_RANDOM, 50, 50, 100, 25, E_RANDOM_NAME)
  #Number('Number', 6, 50, 180, 200, 20, 1, 0, 10, 'Number tip')
  #Scrollbar('Scrollbar', 50, 240, 200, 20, 1, 0, 10, 'Update','Tip')


def exit (evt, val):
  if (evt == QKEY and not val):
    Exit()

def event (ev):
  global xC, yC, hpC, hsC, wC, lC, xC2, yC2, hpC2, hsC2, wC2, lC2, Toggle

  if ev == 7:
    # event called when a user selects the number values.
    if (E_DEBUG == 1):
      print "&gt;&gt; Slider selected"
      print "x  = ",xC2
      print "y  = ",yC2
      print "hp = ",hpC2
      print "hs = ",hsC2
      print "w  = ",wC2
      print "l  = ",lC2

  if ev == 6:
    # event called when a user selects the number values.
    if (E_DEBUG == 1):
      print "&gt;&gt; Button selected"
      print "x  = ",xC
      print "y  = ",yC
      print "hp = ",hpC
      print "hs = ",hsC
      print "w  = ",wC
      print "l  = ",lC

  if ev == 3:
    # Draw a custom house selected by the user.
    xC2  = eval(str(xC2))
    yC2  = eval(str(yC2))
    hpC2 = eval(str(hpC2))
    hsC2 = eval(str(hsC2))
    wC2  = eval(str(wC2))
    lC2  = eval(str(lC2))
    
    if (E_DEBUG == 1):
      print "&gt;&gt; Create a Custom house with the following cordinates.[Slider style]"
      print "x  = ",xC2
      print "y  = ",yC2
      print "hp = ",hpC2
      print "hs = ",hsC2
      print "w  = ",wC2
      print "l  = ",lC2
    #x = eval(xC2)
    #w = eval(wC2)
    #x = Float(xC2)
    #w = Float(wC2)
    

    
    #x = Mathutils.Rand (-4,4)
    #w = Mathutils.Rand (2,4)
    semiC2 = xC2 + (wC2/2)
    if (E_DEBUG == 1):
      print "semi = ",semiC2
    CreateHouse(xC2, yC2, hpC2, hsC2, wC2, lC2, semiC2)
  if ev == 2:
    # Draw a custom house selected by the user.
    if (E_DEBUG == 1):
      print "&gt;&gt; Create a Custom house with the following cordinates.[button style]"
      print "x  = ",xC
      print "y  = ",yC
      print "hp = ",hpC
      print "hs = ",hsC
      print "w  = ",wC
      print "l  = ",lC
    
    # could add a cheeky hack here to try get the floats correct 
    # select a random from the point the user chose to 1 int above it.
    
    # TODO : figure out adding numbers to a int or make the float correctly
    # if i can do this the form section will work correctly
    # built-in functions int(), long(), and float() convert inputs
    # int(float('0.0123456789'))
    #xC2  = int(xC)+1
    #yC2  = int(yC)+1
    #hpC2 = int(hpC)+1
    #hsC2 = int(hsC)+1
    #wC2  = int(wC)+1
    #lC2  = int(lC)+1
    #x    = Mathutils.Rand (xC,xC2)
    #y    = Mathutils.Rand (yC,yC2)
    #hp   = Mathutils.Rand (hpC,hpC2)
    #hs   = Mathutils.Rand (hsC,hsC2)
    #w    = Mathutils.Rand (wC,wC2)
    #l    = Mathutils.Rand (lC,lC2)
    #semi = xC2 + (wC2/2)
    
    x  = eval(str(xC))
    y  = eval(str(yC))
    hp = eval(str(hpC))
    hs = eval(str(hsC))
    w  = eval(str(wC))
    l  = eval(str(lC))
    semi = x + (w/2)
    
    if (E_DEBUG == 1):
      print " &gt;&gt; new values"
      print "x  = ",x
      print "y  = ",y
      print "hp = ",hp
      print "hs = ",hs
      print "w  = ",w
      print "l  = ",l
      print "semi  = ",semi
    #x = int(xC)
    #y = int(yC)
    #hp = int(hpC)
    #hs = int(hsC)
    #w = int(wC)
    #l = int(lC)
    #semi = xC + (wC/2)
    #CreateHouse(xC, yC, hpC, hsC, wC, lC, 3.99604322016)
    CreateHouse(x, y, hp, hs, w, l, semi)
    #CreateHouse(-1.67735946365, -2.92192997411, 2.13155810256, 1.29031124152, 2.51938086469, 5.95548190922, 3.99604322016)
    return
  elif ev == 1:
    # user does not know what he wants so draw a random house.
    # Draw a random size house for the user.
    # Returns a random number eg: 2.03430345967
    x = Mathutils.Rand (-5,5)
    y = Mathutils.Rand (-5,5)
    hp = Mathutils.Rand (0,5)
    hs = Mathutils.Rand (1,2)
    w = Mathutils.Rand (2,4)
    l = Mathutils.Rand (2,6)
    semi = x + (w/2)
    if (E_DEBUG == 1):
      print "&gt;&gt; Random House Generated."
      print "x  = ",x
      print "y  = ",y
      print "hp = ",hp
      print "hs = ",hs
      print "w  = ",w
      print "l  = ",l
      print "semi = ",semi
    CreateHouse(x, y, hp, hs, w, l, semi)
    return
Register (buton, exit, event)


# Main Function to use when drawing a simple block house.
def CreateHouse(x, y, hp, hs, w, l, semi):
  if (E_DEBUG == 1):
    print "&gt;&gt; Inside CreateHouse"
    print "x  = ",x
    print "y  = ",y
    print "hp = ",hp
    print "hs = ",hs
    print "w  = ",w
    print "l  = ",l
    print "semi = ",semi
  mesh = NMesh.New()
  # Method: NMesh.Vert([x, y, z])
  # Returns a new NMVert object, created from the given x,y,and z coordinates. If any of the coordinates are not passed they default to 0.0.

  a = NMesh.Vert (x,y,0)
  b = NMesh.Vert ((x+w),y,0)
  c = NMesh.Vert ((x+w),(y+l),0)
  d = NMesh.Vert (x,(y+l),0)
  e = NMesh.Vert (x,y,hp)
  f = NMesh.Vert ((x+w),y,hp)
  g = NMesh.Vert ((x+w),(y+l),hp)
  h = NMesh.Vert (x,(y+l),hp)
  i = NMesh.Vert (semi,y,(hp+hs))
  j = NMesh.Vert (semi,(y+l),(hp+hs))

  mesh.verts.append (a)
  mesh.verts.append (b)
  mesh.verts.append (c)
  mesh.verts.append (d)
  mesh.verts.append (e)
  mesh.verts.append (f)
  mesh.verts.append (g)
  mesh.verts.append (h)
  mesh.verts.append (i)
  mesh.verts.append (j)

  # Method: NMesh.Face()
  # Face() Return a new NMCol object created from the given r,g,b, and a color components. If any of the components are not passed they default to 255.
  
  abcd = NMesh.Face ([a,b,c,d])
  abfe = NMesh.Face ([a,b,f,e])
  bcgf = NMesh.Face ([b,c,g,f])
  cdhg = NMesh.Face ([c,d,h,g])
  daeh = NMesh.Face ([d,a,e,h])
  efi = NMesh.Face ([e,f,i])
  ghj = NMesh.Face ([g,h,j])
  fgji = NMesh.Face ([f,g,j,i])
  heij = NMesh.Face ([h,e,i,j])

# these dimensions are taken from the frount camera view.
# These are each pannel that will be placed and put together.
  mesh.faces.append (abcd)		# Floor
  mesh.faces.append (abfe)		# Frount Wall
  mesh.faces.append (bcgf)		# Right Wall
  mesh.faces.append (cdhg)		# Back Wall
  mesh.faces.append (daeh)		# Left Wall
  mesh.faces.append (efi)		# Frount Roof Triangle
  mesh.faces.append (ghj)		# Back Roof Triangle
  mesh.faces.append (fgji)		# Right Roof 
  mesh.faces.append (heij)		# Left Roof

  # New Mesh Object will be created from the values set in our mesh object.
  obj = Object.New ("Mesh", "AidansHome")
  obj.link (mesh)

  Scene.GetCurrent().link(obj)
# Method: Blender.Redraw()
# This function forces an immediate redraw of all 3D windows in the current screen. It can be used to force display of updated information (for example when an IPO curve for an Object has been changed).
  Blender.Redraw()

Register (buton, exit, event)

if you can find something that can help me get this app a bit further please post it here.

there is one thing about the app thats bugging me, after each house you make from the slider or button the slider values reset back to the defaults.

how can i fix this sothat it does not???