3D House in Blender using Python Scripts [ Help ]
Moderators: jesterKing, stiv
3D House in Blender using Python Scripts [ Help ]
Hi,
Can you please guide me to create a 3D house using Python Scripts?
I know little Python Scripts. But, its hard to think of a way to apply them in Blender to do this.
Thanks in advance.
/Pradeep
Can you please guide me to create a 3D house using Python Scripts?
I know little Python Scripts. But, its hard to think of a way to apply them in Blender to do this.
Thanks in advance.
/Pradeep
Here's a simple example:
Code: Select all
import bpy
verts = (4, 2, 0), (4, -2, 0), (-4, -2, 0), (-4, 2, 0), (4, 2, 4), (4, -2, 4), (-4, -2, 4), (-4, 2, 4), (4, 0, 6), (-4, 0, 6)
faces = (0, 1, 2, 3), (8, 9, 6, 5), (0, 4, 8, 5, 1), (1, 5, 6, 2), (2, 6, 9, 7, 3), (4, 0, 3, 7), (4, 7, 9, 8)
me = bpy.data.meshes.new("Simple House")
me.from_pydata(verts, [], faces)
me.validate()
me.update()
ob = bpy.data.objects.new("Simple House", me)
bpy.context.scene.objects.link(ob)
bpy.context.scene.update()
I'm sitting, waiting, wishing, building Blender in superstition...
Thank you very much...CoDEmanX wrote:Here's a simple example:
Code: Select all
import bpy verts = (4, 2, 0), (4, -2, 0), (-4, -2, 0), (-4, 2, 0), (4, 2, 4), (4, -2, 4), (-4, -2, 4), (-4, 2, 4), (4, 0, 6), (-4, 0, 6) faces = (0, 1, 2, 3), (8, 9, 6, 5), (0, 4, 8, 5, 1), (1, 5, 6, 2), (2, 6, 9, 7, 3), (4, 0, 3, 7), (4, 7, 9, 8) me = bpy.data.meshes.new("Simple House") me.from_pydata(verts, [], faces) me.validate() me.update() ob = bpy.data.objects.new("Simple House", me) bpy.context.scene.objects.link(ob) bpy.context.scene.update()
I will try with this.
Are there any documents/web links to read on this topic..?
Thanks again.
Here are the latest API docs:
http://www.blender.org/documentation/250PythonDoc/
You wanna check out the Add Mesh addons, especially the teapot example here:
https://svn.blender.org/svnroot/bf-exte ... a_objects/
There are many ways of mesh generation, you could perform many operators like you would do in 3d view to create a model. You could also model something first, take the result and make this a script (like i did). Or start from scratch and write formulas to compute shapes based on input parameters.
http://www.blender.org/documentation/250PythonDoc/
You wanna check out the Add Mesh addons, especially the teapot example here:
https://svn.blender.org/svnroot/bf-exte ... a_objects/
There are many ways of mesh generation, you could perform many operators like you would do in 3d view to create a model. You could also model something first, take the result and make this a script (like i did). Or start from scratch and write formulas to compute shapes based on input parameters.
I'm sitting, waiting, wishing, building Blender in superstition...
Please tell me the requirements to run & test this script.CoDEmanX wrote:Here's a simple example:
Code: Select all
import bpy verts = (4, 2, 0), (4, -2, 0), (-4, -2, 0), (-4, 2, 0), (4, 2, 4), (4, -2, 4), (-4, -2, 4), (-4, 2, 4), (4, 0, 6), (-4, 0, 6) faces = (0, 1, 2, 3), (8, 9, 6, 5), (0, 4, 8, 5, 1), (1, 5, 6, 2), (2, 6, 9, 7, 3), (4, 0, 3, 7), (4, 7, 9, 8) me = bpy.data.meshes.new("Simple House") me.from_pydata(verts, [], faces) me.validate() me.update() ob = bpy.data.objects.new("Simple House", me) bpy.context.scene.objects.link(ob) bpy.context.scene.update()
I have installed Blender.
Thanks for dedicating your time

Hi,CoDEmanX wrote:start blender
change to Scripting view
click + New button in text editor
paste the script
hit Alt + P or the Run Script button
Thanks for the reply.
I was trying to run this script & see it.
But, it gives me an error in the below code line.
me.from_pydata(verts, [], faces)
And it gives me an error below.
"python script fail look in the console for now"
Sir,
Can you please help me to fix this error & run this code.
Thanks in advance.
CoDEmanX wrote:can't help you, works fine here and you didn't post the error
run blender from terminal / command line or toggle console (windows only) inside of blender (Window > Toggle system console) and post the problem
Hi,
This is the error I get.

Hope it is clear in the image.
Do you have any idea why this error comes...?
Thanks in advance.
Thanks ... I updated it to 2.64. Its working now.CoDEmanX wrote:it works fine here in blender 2.64, your version is 2.62 so you should update to latest stable release
I hope I will have more questions to ask from you to clarify regarding Blender in the future.
Sir, your help is very helpful to me.
Thanks
-
- Posts: 0
- Joined: Tue May 28, 2013 7:17 am