3D House in Blender using Python Scripts [ Help ]

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

spgun
Posts: 13
Joined: Sun Mar 18, 2012 6:31 am

3D House in Blender using Python Scripts [ Help ]

Postby spgun » Tue Nov 27, 2012 2:58 pm

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

CoDEmanX
Posts: 894
Joined: Sun Apr 05, 2009 7:42 pm
Location: Germany

Postby CoDEmanX » Tue Nov 27, 2012 6:28 pm

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...

spgun
Posts: 13
Joined: Sun Mar 18, 2012 6:31 am

Postby spgun » Tue Nov 27, 2012 7:01 pm

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


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

Thanks again.

CoDEmanX
Posts: 894
Joined: Sun Apr 05, 2009 7:42 pm
Location: Germany

Postby CoDEmanX » Tue Nov 27, 2012 9:25 pm

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.
I'm sitting, waiting, wishing, building Blender in superstition...

spgun
Posts: 13
Joined: Sun Mar 18, 2012 6:31 am

Postby spgun » Sun Dec 02, 2012 6:18 pm

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


Please tell me the requirements to run & test this script.
I have installed Blender.
Thanks for dedicating your time :)

CoDEmanX
Posts: 894
Joined: Sun Apr 05, 2009 7:42 pm
Location: Germany

Postby CoDEmanX » Mon Dec 03, 2012 12:18 am

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...

spgun
Posts: 13
Joined: Sun Mar 18, 2012 6:31 am

Postby spgun » Tue Dec 04, 2012 6:10 pm

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.

CoDEmanX
Posts: 894
Joined: Sun Apr 05, 2009 7:42 pm
Location: Germany

Postby CoDEmanX » Tue Dec 04, 2012 10:53 pm

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...

spgun
Posts: 13
Joined: Sun Mar 18, 2012 6:31 am

Postby spgun » Sat Dec 08, 2012 12:14 am

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.
Image

Hope it is clear in the image.
Do you have any idea why this error comes...?

Thanks in advance.

CoDEmanX
Posts: 894
Joined: Sun Apr 05, 2009 7:42 pm
Location: Germany

Postby CoDEmanX » Sun Dec 09, 2012 3:51 pm

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...

spgun
Posts: 13
Joined: Sun Mar 18, 2012 6:31 am

Postby spgun » Sun Dec 09, 2012 5:23 pm

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

spgun
Posts: 13
Joined: Sun Mar 18, 2012 6:31 am

Postby spgun » Wed Dec 12, 2012 7:54 pm

Hi sir,
Again a question..
I'm practicing with Python scripts basics... :)
The above house was really well.
I like to study how to create a house like below.
( ex : rooms, doors, windows, etc )



Image


Can you please help me..?

spgun
Posts: 13
Joined: Sun Mar 18, 2012 6:31 am

Postby spgun » Thu Dec 20, 2012 3:12 am

Sir,
Can you please help me..?

RainKiller27
Posts: 3
Joined: Tue May 28, 2013 7:17 am

Postby RainKiller27 » Tue May 28, 2013 7:30 am

spgun wrote:Sir,
Can you please help me..?


I can help you with that, if you'd like. i know the post was over a year ago but if you still haven't found a way to make a house i'm willing to help.

mjmlms19
Posts: 2
Joined: Sun Nov 03, 2013 1:32 am
Location: United States

Postby mjmlms19 » Sun Nov 03, 2013 1:44 am

RainKiller27 wrote:
spgun wrote:Sir,
Can you please help me..?


I can help you with that, if you'd like. i know the post was over a year ago but if you still haven't found a way to make a house i'm willing to help.


Can you help me model the inside of a house?


Return to “Python”

Who is online

Users browsing this forum: No registered users and 0 guests