Previous Thread  Next Thread

chat icon 3D House in Blender using Python Scripts [ Help ]

spgun

Posted: Tue Nov 27, 2012 2:58 pm
Joined: 18 Mar 2012
Posts: 13
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
Reply with quote


CoDEmanX

Posted: Tue Nov 27, 2012 6:28 pm
Joined: 05 Apr 2009
Posts: 687
Here's a simple example:

Code:

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...
Reply with quote


spgun

Posted: Tue Nov 27, 2012 7:01 pm
Joined: 18 Mar 2012
Posts: 13
CoDEmanX wrote:
Here's a simple example:

Code:

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()


Thank you very much...
I will try with this.
Are there any documents/web links to read on this topic..?

Thanks again.
Reply with quote


CoDEmanX

Posted: Tue Nov 27, 2012 9:25 pm
Joined: 05 Apr 2009
Posts: 687
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-extensions/trunk/py/scripts/addons/add_mesh_extra_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...
Reply with quote


spgun

Posted: Sun Dec 02, 2012 6:18 pm
Joined: 18 Mar 2012
Posts: 13
CoDEmanX wrote:
Here's a simple example:

Code:

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()


Please tell me the requirements to run & test this script.
I have installed Blender.
Thanks for dedicating your time Smile
Reply with quote


CoDEmanX

Posted: Mon Dec 03, 2012 12:18 am
Joined: 05 Apr 2009
Posts: 687
start blender

change to Scripting view

click + New button in text editor

paste the script

hit Alt + P or the Run Script button
_________________
I'm sitting, waiting, wishing, building Blender in superstition...
Reply with quote


spgun

Posted: Tue Dec 04, 2012 6:10 pm
Joined: 18 Mar 2012
Posts: 13
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


Hi,
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.
Reply with quote


CoDEmanX

Posted: Tue Dec 04, 2012 10:53 pm
Joined: 05 Apr 2009
Posts: 687
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
_________________
I'm sitting, waiting, wishing, building Blender in superstition...
Reply with quote


spgun

Posted: Sat Dec 08, 2012 12:14 am
Joined: 18 Mar 2012
Posts: 13
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.
Reply with quote


CoDEmanX

Posted: Sun Dec 09, 2012 3:51 pm
Joined: 05 Apr 2009
Posts: 687
it works fine here in blender 2.64, your version is 2.62 so you should update to latest stable release
_________________
I'm sitting, waiting, wishing, building Blender in superstition...
Reply with quote


spgun

Posted: Sun Dec 09, 2012 5:23 pm
Joined: 18 Mar 2012
Posts: 13
CoDEmanX wrote:
it works fine here in blender 2.64, your version is 2.62 so you should update to latest stable release


Thanks ... I updated it to 2.64. Its working now.
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
Reply with quote


spgun

Posted: Wed Dec 12, 2012 7:54 pm
Joined: 18 Mar 2012
Posts: 13
Hi sir,
Again a question..
I'm practicing with Python scripts basics... Smile
The above house was really well.
I like to study how to create a house like below.
( ex : rooms, doors, windows, etc )






Can you please help me..?
Reply with quote


spgun

Posted: Thu Dec 20, 2012 3:12 am
Joined: 18 Mar 2012
Posts: 13
Sir,
Can you please help me..?
Reply with quote


 
Jump to:  
Powered by phpBB © 2001, 2005 phpBB Group