Blender room constructor

Hi guys,

I realised that blender hasn’t got 3D max’s tools for constructing rooms
and houses. So i decided to do something for Blender. However, my
knowledge with blender is really limited, so I decided to do it in two steps:

(1) Step 1: write an easy GUI system that can draw the rooms, doors and
windows easily and be able save the room information in a format that
can be easily loaded into blender.

(2) Step 2: write code that converts the room constructed in step 1 into
blender.

Since I’m very short on time, I used jython http://www.jython.org/
to do the GUI. Then I save the room information into python pickle files, then
construct blender meshes from the saved python pickle file.

You can download the code from:

www.cs.mu.oz.au/~jingy/download/blenderRoomConstructor.tar

This tar archive consists of the following files:

(1) BlenderRoomConstructor.py – the blender interface code, you need to
load this file into blender to construct the rooms.

(2) StageConstructor.py – this is the jython file, you run it using jython to
construct the 2D version of the room.

(3) GeometryInfo.py – some code that connects (1) and (2)

(4) megabool_r12.py – the code writtne by one of the gurus on this forum
that does binary operations between meshes, I use his great code to cut
doors and windows out of the walls.

(5) 0001_complex_multi_room_apartment.room , 0002_my_home.room –
2 example rooms.

Here is the screen shot of the first room:

http://img105.imageshack.us/img105/9255/room3xs.jpg

Here is the screen shot of the first room as constructed in the jython gui.

http://img181.imageshack.us/img181/1830/gui6gm.jpg

Please feel free to use or modify my code, but please also let me know if
you add any new features or fix any bugs.

Thanks a lot.

Very Nice I have been doing all this by hand and its tedious. Keep developing this and if you need help with the docs or tutes for it let me know.

Thanks!! I doubt I’d work on it anymore in the forseeable future because it
already does what I want it to do. That’s why I thought that other people
might be interested and could make use of it.

The obvious extensions would be adding the actual windows and doors
into the walls, instead of having just holes in the walls. The geometry
information for the doors and windows are all there in the code anyway.

didu I just tried this script. I will give step by step description on what I did.

#1 Untarted the .tar into C:\Program Files\Blender Foundater\Blender237.blender\scripts\ directory.
#2 Opened blender 237
#3 Turned one 3d Window into a text window.
#4 Opened BlenderRoomContructo.py
#5 Alt-p in that text window.
#6 got a script error popup

Here is the error:

Using Python version 2.3
Loading from: /home/jingy/workspaces/blenderMovieMaker/room ...Traceback (most r
ecent call last):
  File "BlenderRoomConstructo", line 705, in ?
  File "BlenderRoomConstructo", line 682, in blenderTest1
  File "BlenderRoomConstructo", line 44, in loadRoomInfo
IOError: [Errno 2] No such file or directory: '/home/jingy/workspaces/blenderMov
ieMaker/room'

I have no idea what this means. But I know I have no directory named “/home/jingy/workspaces/blenderMovieMaker/room” on my hard drive

Ok thinking that maybe I was suppose to run one of the other scripts also I went into the text window and opened “StageContructor.py”
#7 Pressed ALT-P with 'StageConstructor.py" in the text window.

Here is the other error I got

Traceback (most recent call last):
  File "C:\Program Files\Blender Foundation\Blender237\.blender\scripts\StageCon
structor.py", line 2, in ?
    import java.awt
ImportError: No module named java.awt

Now I know I have the Sun Java 1.4.1 VM on my computer and that the class path is set correctly.

You never did answer the question is the jython2.1 class file need to be in the same directory as your .py files.

Sorry for not replying soon enough.

The first error you received:


Using Python version 2.3 
Loading from: /home/jingy/workspaces/blenderMovieMaker/room ...Traceback (most r 
ecent call last): 
  File "BlenderRoomConstructo", line 705, in ? 
  File "BlenderRoomConstructo", line 682, in blenderTest1 
  File "BlenderRoomConstructo", line 44, in loadRoomInfo 
IOError: [Errno 2] No such file or directory: '/home/jingy/workspaces/blenderMov 
ieMaker/room'

This error is caused by precisely the reason that you don’t have the
path: /home/jingy/workspaces/blenderMovieMaker/room

The file “room” should be in the same directory in which you untarred the
files. Therefore, on line 44 of BlenderRoomConstructor.py, you should
modify the path “/home/jingy/workspaces/blenderMovieMaker/room” to the
actual path of the file “room” .

It looks like you are running windows. Have you actually got jython installed?
If not, you first have to go to http://www.jython.org/download.html to get
jython, then install jython, then do the following:

jython StageConstructor.py

This will load the second gui in my first post. What you do is drawing the
walls of the room in this gui, then save it to a file, then you start blender
and load BlenderConstructor.py, then on line 44, put in the path of the file
you created using jython, then press ALT-P to create the 3D representation
of the room you just created.

If you’ve installed jython correctly, I don’t think you need to put any of the
java class files in the same directory as jython or StageConstructor.py.

Hope this helps.

Ok didu. After some effort, I got the StageConstructor.py interface to appear. BUT you still need to explan the procedures on how to use it. I got it to make a basic box shape. But trying to get windows and doors in to appear was a sometimes it worked and sometimes it did not situation.
sometimes when I checked the choice add windows or door a seperate very thin box came up and the orignal box(room??) was gone. Sometimes I could click and drag out a solid red colored box and it would ask me if it was a window or door. Sometimes nothing happened. Some step by step instructions would be helpful. In other words it is “NOT intuitively obvious to the casual observer” <------ Something my college differential equations professor would say after he put up a long proof on the board and left 90% of the students looking glassy eyed and totally lost.

As far as BlenderRoomConstructor.py. I tried changing every instance of “/home/jingy/workspaces/blenderMovieMaker/…” with “…/” I got and access denied error. Then I tired using “./” I got the same error. Why not just code some lines where the blender file directory box comes up. I mean I am not a python expert and niether are many of the people here. Having to manually change a directory in a script is something non coders should have to do.

Oh gosh, documentation — the one thing I dread most. Ok, here is how you
use the StageConstructor.py.

When you start up the gui, you get an empty construction area, and the GUI
should in the “Add Wall” state – as indicated by the ticked checkbox in the
Options menu. In this state, you are supposed to draw the bird-eye-view
of the room, you can start by left clicking on a random position in the
drawing area to draw the start of a new wall, and move your mouse
to determine the end position of this new wall, the second left click will
determine the beginning and ending position of that wall AND THE START
POSITION OF THE NEXT NEW WALL, once you’ve drawn all the walls you want,
just right click the mouse to stop adding walls.

If you are not satisfied with the precision of your walls, you can manually
edit the position of the wall or the start or end points of the wall. You do so
by ticking the “Edit wall” checkbox in the options menu. There are three ways
for you to change a wall:

(1) If you just left click on the wall, the wall will become blue, and its start
and end positions will be displayed in the text fields just below the menu,
you can manually change these values then click the “Done” button to update
the values of the wall.

(2) If you left click the wall, then drag the wall NEAR ITS CENTRE USING THE
MIDDLE BUTTON, you will be able to move the entire wall.

(3) If you left click the wall, then drag the wall NEAR ITS START OR END
POSITION USING THE MIDDLE BUTTON, you will be able to only change the wall’s start or end position.

If you are ready to add windows and doors to a wall, then you need to tick
the “Add wall opening” box in the Options menu, this would first bring back
the bird-eye-view of the room, then you just left click on the wall to which
you want to draw windows and doors. As soon as you select the wall, the
GUI will enter the single wall mode – it will display the wall you selected
in propotion to the entire editing area, and the wall will be displayed as if
you are looking straight at it standing up. This is when you can start drawing
doors and windows inside the wall, You do this by clicking the left mouse
button to select the first corner of your door/window, then move your
mouse until it points to precise location of the opposite corner of your door/window. When you click the left mouse button again, the opening will be
drawn and you will be asked whether the new opening is a door or window.
You can cacncel the drawing before the second left click by right clicking the
mouse.

Hope this explains it.

Sure, I should have released the newer version of the code, here is the
code that you should add at the end of the code to fix that problem


def bBlenderTest1():
    """                                                                                                                                       
    """
    import Blender
    Blender.Window.FileSelector(blenderTest1, 'Import Room')
    pass
#============================================================================                                                      

if __name__ == '__main__':
    #testSingleWall(sys.argv[1])  
    bBlenderTest1()

Remember to change the last line from “blenderTest1()” to
“bBlenderTest1()”.

thanks didu: finally somebody makes it real: to convert blender in a potential CAD tool. Do you know about Blender Cad? it was an italian proyect, it had only one version (pre-alpha) but now is dead. (no notice about it). I hope that “Blender Constructor” :smiley: would be the alternative for Acad users, specially for architecture proyects.
best wishes

OK here we go again.

didu do not take this the wrong way but why not just release the script in a zip or even a tar with all these changes included. You will find that you get bugged a lot less by people that do not know python(like me) if you submit a completely ready to use script in zip format that can be downloaded unzipped into somone blender script directory.

Ok as far as your response.

Sure, I should have released the newer version of the code, here is the
code that you should add at the end of the code to fix that problem

Code:

def bBlenderTest1():
“”"
“”"
import Blender
Blender.Window.FileSelector(blenderTest1, ‘Import Room’)
pass
#============================================================================

if name == ‘main’:
#testSingleWall(sys.argv[1])
bBlenderTest1()

Remember to change the last line from “blenderTest1()” to
“bBlenderTest1()”.

#1 What “lastline” in the code you just posted or in the code that I already downloaded into the scripts directory?

#1 Did you mean paste the bBlenderTest1(1) function at the end of BlenderConstrustor.py.??

#2 Where do I put the “if__name__” lines?? What do I do with those “/home/jingy” lines the I replaced with “./” if I do paste the those lines to the end of the script ?

#3 Why is the function definition bBlenderTest1() and then in the “Blender.Window.FileSelector” you have “blenderTest1” ?

Do you see what I mean. These are all question that came to mine when I read your response. I know they are apparent to you. But you wrote the script!! They are not that apparent to someone just trying to use the script.

Let me say once again I REALLY appreciate this script. I will make what I am trying to accomplish with blender a LOT easier. I just hope you take this as constructive criticism

Ok after redownload and saving JUST BlenderRoomConstructor.py In order to get rid of all the changes I made in and attempt to get this to work I did this:

#============================================================================
def bBlenderTest1(): 
    """                                                                                                                                        
    """ 
    import Blender 
    Blender.Window.FileSelector(blenderTest1, 'Import Room') 
    pass 
#============================================================================
if __name__ == '__main__':
	#testSingleWall(sys.argv[1])
	bBlenderTest1()
	#saveAllMeshesFromBlender()
	#loadFromCombinedMeshFile('/home/jingy/workspaces/blenderMovieMaker/newOff.off.separated')
	#saveAllMyModels()
	#sandBox()

I got this error:

TypeError: blenderTest1() takes no arguments (1 given)

This is starting to get frustrating.

Sorry, but you got it wrong again, I guess my comments was a bit confusing
to people who have no programming backgrounds. But not to worry, I’ve
uploaded the latest version of BlenderRoomConstructor onto the same URL
in my first post, and it should not have any of the problems that you’ve been
experiencing, please have a look at it and tell me what you think.

Did you find my instructions to StageConstructor helpful?

[quote=“wrlcks”]

thanks didu: finally somebody makes it real: to convert blender in a potential CAD tool. Do you know about Blender Cad? it was an italian proyect, it had only one version (pre-alpha) but now is dead. (no notice about it). I hope that “Blender Constructor” :smiley: would be the alternative for Acad users, specially for architecture proyects.
best wishes[/quote]

Oh, thanks for that. But I hope you won’t be too disappointed with the
very limited functionality for provided by this quick hack of mine. This code
was specifically designed to allow quick constructions of walls, doors and
windows, I didn’t design it to accommendate things like stairs, rails and
other real CAD stuff. Even the doors and windows are only implemented
as holes in the walls. Although all the information about doors and windows
are preseved in the code, so it shouldn’t be too hard for someone to come
along and add a functionality for incorporating doors and windows.

Please re-download the code as I’ve made some changes to the original
release.

You might want to look at this one:

http://www.zoo-logique.org/3D.Blender/zip/ArchiMause05c228a.zip

Looks quite advanced, does lots of things and has a nice graphical interface.
Use Blender 2.25 or 2.28 at first. For Blender 2.3+ you need two change two python commands in the script (see messages in console, its trivial to adapt).

Sometimes it freaks up some normals, but its fun to play with.

I found them very helpful. In fact I printed them out an will try to follow them when I get the time. Just been a busy few days for me so I have not been able to get on my computer for anything other then work for the last three days.

I tried the new BlenderConstructor.py It works just fine. I added the menu code to it in my version so that it shows up in the script menu. I even colored the walls from one of your examples and exported it to a vrml file for viewing in blaxxun contact just so see it if would work. It worked fine. Only two question.

In the StageConstructor are the numbers that one puts in the text box in blender units. I ASSume they are :slight_smile: Is there any way of making the doorways not have that small lip a the bottom. That is unrealistic. I could always subdivide the wall in blender then delete that part but that leads to trianglation which I then have to get rid of when I export.

Was there any special reason why you coded StageConstructor.py in Jython? Could this not have been down within blender with its python interperter or having someone download the full install of python2.3. Most people that run blender script do that anyway since a lot of the scripts required the full installation. It just seems kind of redundant to me to have to download jython,install it,then run StageConstructor.py to make the 2d plan of the rooms. Then go into blender to run RoomConstructor.py to get what you made into 3d. I mean I can do it but its just seems inefficent.

This would be nice if I remebered my high school french well enough.

[edit] Ok same problem here as with didu’s script intitally. I have to go into the text editor and figure out how to change some of the code around. Well as I said before not all of us blender heads are python programmers. I do have some basic python knowledge and I know how to look up things on www.python.org or in the blender API reference. BUT I would NOT consider myself a python programmer(YET). If you are going to post a script make it so that the general blender population can just run it by going ALT-P or better yet using the scripts menu.

This one had and errosr that said something about invalid single qouted string at line 7. I think that is has to do with how I put in the windows path to where the blend file is stored. That is what I could somewhat deduce from the french comments.

Excuse me if this seems OT, but wouldn’t it be simpler to draw shapes in a 2d vector program like Inkscape then import the svg files as curves? JMS’s latest updates on the svg2obj import script works great.
I am not a coder, but would it be possible to link the two programs (Blender and Inkscape) together temporarily via Python? Then perhaps one could draw a shape in Inkscape, click save and the curve updates in Blender. Or create a curve in Blender, click edit and the curve opens in Inkscape… :expressionless: It might be easier than trying to reinvent the wheel since the tools available in Inkscape (like booleans, shapes and guidelines) is better than what you have in Blender…

I’m not sure what you mean by “small lip”, I assume you mean the part of
the wall that’s under the door? It’s very easy to get rid of them, just draw
your door all the way to the bottom of the wall.

For the units, NOOOOOO!!! First of all, Blender doesn’t really have a unit,
there is a parameter called “scaleFactor” in BlenderConstructor.py that
reduces the units to 10% of what they are in the jython gui. You can change
it if you want to. The units in the jython gui are the width and length of the
editing area in number of pixels.

Nothing special, it’s just that I found the java 2D classes extremly easy
to use compared with all the python gui libraries, I was able to write the
gui in less than 3 days and there is no reason why other people should
not be able to redo the gui in pure python.

You are absolutely right, I didn’t search very hard for these things and I also
wanted to know the precise locations of the doors and windows, that’s why
I decided to quickly hack up something of my own.

Yeah but that would require someone like me to download,install,learn and run ANOTHER program. I am already ticked that I have to use aqsis just to use the MAKEHAIR plugin. Which is why I will be sticking with Ripstring’s Fiber2.03 script for now. Its “native” to blender and there is no need to download and install anything else other then the package that comes with the script zip file. Even though it might be inferior to MakeHair. Its simpler for me. I believe in the K.I.S.S princple of doing things on a computer unless I the value returned FAR out wieghs the amount of effort required.

Hi SHABA1, i did correct the script and had already partially translated it until i realised, that it has a commercial origin. So question: Does make the use of python automatically open source, even if they dont state anything? The correction however was made ape-like without ANY knowledge of python. I simply realized that two commands have been renamed in the new API-Doc. Apart from that i did not post from home.

The script has numerous other bugs which do not keep it from running but from working with it:
i.e.:

Index error: It screws up the indices when you go forth and back between the different items.
Normals : As i already said, thy are somewhat screwed with some objects.

As this script can be found on Zoo-logique.org i guess there are some other issues with it, otherwise people which hang out there (JMS for example) would have already corrected it.
However,I am not able to correct the indices bug, reason above.

This was mentioned cause you can use the routines to build the objects after a review in some other script. I dont think its worth to correct this one, cause its organisation seems to be a dead end.