# learned from Povray, building a house and ???!!!

Hi
From building a tree in Blender I got to arabaro (java) form there to povray and
very nice in Blender 2.5.8 there is a Povray-addon using Povray 3.7 (not lower!) and
works nicely!

Got interested in Povray ans saw lots of examples available!

This povray-code e.g (main part, lighting camera etc. left off):

#declare Hx = 2.00;
#declare Hy = 3.50;
#declare Hz = 4.00;
#declare Roof_Angle = 25;//38;

difference{
box { &lt;-Hx,0,0&gt;,&lt; Hx,Hy,Hz&gt;
texture { pigment{ color Green}
finish { phong 1}
} // end of texture
scale &lt;1,1,1&gt; rotate&lt;0,0,0&gt; translate&lt;0,0,0&gt;
} // end of box --------------------------------------

plane{ &lt;0,-1,0&gt;,0
texture { pigment{ color rgb&lt;1,0,0&gt;}
finish { phong 1}
} // end of texture
rotate&lt;0,0,Roof_Angle&gt;
translate&lt;0,Hy,0&gt;
}

plane{ &lt;0,-1,0&gt;,0
texture { pigment{ color rgb&lt;1,1,1&gt;}
finish { phong 1}
} // end of texture
rotate&lt;0,0,-Roof_Angle&gt;
translate&lt;0,Hy,0&gt;
}

}// end of difference

Showing how to use ‘difference’ ==> inspiring me to use a boolean Modifier

import bpy
#van de kubus schuine stukken afsnijden
#NL huis = EN house = DE Haus = FR maison
#NL neiging (an het dak)  = EN .. = DE Neigungg (des Daches)
def maakHuis(neigingLinks = 30, neigingRechts = 30):
cube = bpy.context.active_object

huis = bpy.context.active_object
huis.name = "Huis"

bpy.ops.transform.resize(value=(2, 2, 2))
bpy.ops.transform.translate(value=(0, 0, 0.5))

mod = huis.modifiers[-1]
print(mod.operation)
mod.object = cube
bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Boolean")

bpy.ops.object.select_all(action='TOGGLE')
cube.select = True
bpy.ops.object.delete()

#  deel 1  klaar   herhalen met tweede 'plane'

bpy.ops.transform.resize(value=(2, 2, 2))
bpy.ops.transform.translate(value=(0, 0, 0.5))
bpy.ops.transform.rotate(value=(-radians(neigingRechts),), axis=(1, 0, 0), constraint_axis=(True, False, False))
mijnhuis = bpy.context.active_object
mijnhuis.name = "mijn huis"
modmijnhuis = mijnhuis.modifiers[-1]
modmijnhuis.object = huis
bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Boolean")

bpy.ops.object.select_all(action='TOGGLE')
huis.select = True
bpy.ops.object.delete()
mijnhuis.select = True
bpy.ops.transform.translate(value=(0, 0, 1))
return mijnhuis
maakHuis()

Nice, isn’t it?
Consequence, learn building objects from Povray!

A box in Povray needs lower left corner and upper right corner …
used in imitating building a truck :

def add_box(lowerLeft = [-1,-1,-1],upperRight = [1,1,1]):
#under #0 - #3, upper #4 - #7 #4 above #0
height = abs(lowerLeft[2] - upperRight[2])
width = abs(lowerLeft[1] - upperRight[1])
vertices = [lowerLeft[0], lowerLeft[1], lowerLeft[2], #0
lowerLeft[0], upperRight[1], lowerLeft[2], #1
upperRight[0], upperRight[1] , lowerLeft[2],#2
upperRight[0], lowerLeft[1], lowerLeft[2], #3
lowerLeft[0], lowerLeft[1], upperRight[2], #4
lowerLeft[0], upperRight[1], upperRight[2],#5
upperRight[0], upperRight[1], upperRight[2],#6
upperRight[0], lowerLeft[1], upperRight[2],#7
]
faces = [0, 1, 2, 3,
4, 7, 6, 5,
0, 4, 5, 1,
1, 5, 6, 2,
2, 6, 7, 3,
4, 0, 3, 7,
]

verts_loc = vertices
mesh = bpy.data.meshes.new("Box")
mesh.vertices.foreach_set("co", verts_loc)
mesh.faces.foreach_set("vertices_raw", faces)
mesh.update()

# add the mesh as an object into the scene with this utility module
from bpy_extras import object_utils
box = bpy.context.active_object
box.name = "box"
box.location = (0,0,0)
return box

Makes me want to play MonoPoly!

14 quads, though it could be made with 9 and be easier to unwrap and map…

However, I love booleans operations, so top marks from me!

Do you mean ‘neiging’ == ‘inclination’ (or angle)

indeed, neiging is Dutch for inclination

Problems with modifier Boolean, difference forced me to make a box, where faces shown may be selected. Deleting face 2 works perfect with [0,1,3,4,5] as parameter

def add_box(lowerLeft = [-1,-1,-1],upperRight = [1,1,1], withFaces = [0,1,2,3,4,5]):
#under #0 - #3, upper #4 - #7 #4 above #0
height = abs(lowerLeft[2] - upperRight[2])
width = abs(lowerLeft[1] - upperRight[1])
vertices = [lowerLeft[0], lowerLeft[1], lowerLeft[2], #0
lowerLeft[0], upperRight[1], lowerLeft[2], #1
upperRight[0], upperRight[1] , lowerLeft[2],#2
upperRight[0], lowerLeft[1], lowerLeft[2], #3
lowerLeft[0], lowerLeft[1], upperRight[2], #4
lowerLeft[0], upperRight[1], upperRight[2],#5
upperRight[0], upperRight[1], upperRight[2],#6
upperRight[0], lowerLeft[1], upperRight[2],#7
]
face= {}
face[0] = (0, 1, 2, 3,)
face[1] = (4, 7, 6, 5,)
face[2] = (0, 4, 5, 1,)
face[3] = (1, 5, 6, 2,)
face[4] = (2, 6, 7, 3,)
face[5] = (4, 0, 3, 7,)
faces = []
for el in withFaces:
faces.extend(face[el])

#    print("
============",faces)
'''
faces = [0, 1, 2, 3,
4, 7, 6, 5,
0, 4, 5, 1,
1, 5, 6, 2,
2, 6, 7, 3,
4, 0, 3, 7,
]
'''
verts_loc = vertices

mesh = bpy.data.meshes.new("Box")

mesh.vertices.foreach_set("co", verts_loc)
mesh.faces.foreach_set("vertices_raw", faces)
mesh.update()

# add the mesh as an object into the scene with this utility module
from bpy_extras import object_utils
box = bpy.context.active_object
box.name = "box"
box.location = (0,0,0)
return box

So one example (totally script)

I am struggeling with modifiers in the script …
A box is gets three times cut via ‘DIFFERENCE’ boolean modifier.
I used a circumwent: building 3 the modifiers more or less after each other
and the used objects were constructed EARLIER
Obj1, obj2, obj3
parentobject
build modifiers
use obj1 and apply
use obj2 and apply
use obj3 and apply

But I would like to work as follows:
parentobject
build first modifier
build obj1
apply modifier

build obj2

QUESTION: and now how to add a modifier for parentobject.

all deselecting all,
then
parentobject.select = True
now: