use new preferences standard and fixes for various blender changes
[blender-addons-contrib.git] / add_mesh_building_objects / add_mesh_balcony.py
1 '''
2 bl_info = {
3     "name": "Balcony",
4     "author": "SayPRODUCTIONS",
5     "version": (1, 0),
6     "blender": (2, 59, 0),
7     "api": 33333,
8     "location": "View3D > Add > Mesh > Say3D",
9     "description": "Balcony olusturma",
10     "warning": "",
11     "wiki_url": "",
12     "tracker_url": "",
13     "category": "Add Mesh"}
14 '''
15 import bpy, bmesh
16 from bpy.props import *
17 from bpy_extras.object_utils import object_data_add
18 from mathutils import Vector
19 import operator
20 import os
21 from math import pi, sin, cos, sqrt, atan
22 def MAT(AD,R,G,B):
23     if AD not in bpy.data.materials:
24         mtl=bpy.data.materials.new(AD)
25         mtl.diffuse_color     = ([R,G,B])
26         mtl.diffuse_shader    = 'LAMBERT'
27         mtl.diffuse_intensity = 1.0
28     else:
29         mtl=bpy.data.materials[AD]
30     return mtl
31 def Prs(s,v):
32     if v=='1':
33         s.lst=3
34         s.ls0='1';s.by0= 80;s.bk0=20;s.bf0=4;s.fh0=3;s.fd0=2;s.f00=16;s.f01=12;s.f02=12;s.f03=12
35         s.ls1='3';s.my1=  4;s.mg1= 4
36         s.ls2='4';s.kt2="2";s.ky2= 5;s.kk2=5
37     if v=='2':
38         s.lst=5
39         s.ls0='1';s.by0= 15;s.bk0=20;s.bf0=0
40         s.ls1='2';s.py1= 60;s.pd1=10
41         s.ls2='1';s.by2= 15;s.bk2=20;s.bf2=0
42         s.ls3='3';s.my3=  4;s.mg3= 4
43         s.ls4='4';s.kt4="2";s.ky4= 5;s.kk4=5
44     if v=='3':
45         s.lst=3
46         s.ls0='1';s.by0= 40;s.bk0=10;s.bf0=0
47         s.ls1='5';s.cy1= 56
48         s.ls2='4';s.kt2="1";s.ky2= 0;s.kk2=4
49     if v=='4':
50         s.lst=2
51         s.ls0='1';s.by0= 30;s.bk0=20;s.bf0=0
52         s.ls1='3';s.my1=  4;s.mg1= 4
53     if v=='5':
54         s.lst=2
55         s.ls0='1';s.by0= 27;s.bk0=20;s.bf0=2;s.fh0=3;s.fd0=2;s.f00=7;s.f01=7
56         s.ls1='3';s.my1=  4;s.mg1= 4
57     if v=='6':
58         s.lst=6
59         s.ls0='1';s.by0= 50;s.bk0=20;s.bf0=2;s.fh0=3;s.fd0=2;s.f00=12;s.f01=20
60         s.ls1='3';s.my1=  4;s.mg1= 4
61         s.ls2='4';s.kt2="2";s.ky2= 5;s.kk2=4
62         s.ls3='4';s.kt3="2";s.ky3= 5;s.kk3=4
63         s.ls4='4';s.kt4="2";s.ky4= 5;s.kk4=4
64         s.ls5='4';s.kt5="2";s.ky5= 5;s.kk5=5
65 def EXT(PR,vr,fc,lz,mz,rz):
66     n=len(vr)
67     m=len(PR)
68     if lz==0:
69         for P in PR:vr.append([-mz,P[0],P[1]])
70     else:
71         for P in PR:vr.append([ P[0]-mz,  lz,P[1]])
72         for P in PR:vr.append([ P[0]-mz,P[0],P[1]])
73     if rz==0:
74         for P in PR:vr.append([ mz,P[0],P[1]])
75     else:
76         for P in PR:vr.append([-P[0]+mz,P[0],P[1]])
77         for P in PR:vr.append([-P[0]+mz,  rz,P[1]])
78     if   lz==0 and rz==0:l=1
79     elif lz==0 and rz> 0:l=2
80     elif lz> 0 and rz==0:l=2
81     elif lz> 0 and rz> 0:l=3
82     for j in range(0,l):
83         for i in range(0,m):
84             a=j*m
85             if i==m-1:fc.append([a+i+n,a+0+n+0,a+0+n+0+m,a+i+n+m])
86             else:     fc.append([a+i+n,a+i+n+1,a+i+n+1+m,a+i+n+m])
87 def add_object(s,context):
88     fc=[];vr=[];SM=[]
89     Bal=[];Par=[];Mer=[];Krm=[];Glass=[];Dos=[]
90     blok=[]#    [ Tip ][             Balcony           [                    Joint_Gap                        ] [  Bulwark  ] [   Marble  ] [       Chrome      ] [  Glass  ]
91     blok.append([s.ls0,[s.by0,s.bk0,s.bf0,s.fh0,s.fd0,[s.f00,s.f01,s.f02,s.f03,s.f04,s.f05,s.f06,s.f07]],[s.py0,s.pd0],[s.my0,s.mg0],[s.kt0,s.ky0,s.kk0],[s.cy0]])
92     blok.append([s.ls1,[s.by1,s.bk1,s.bf1,s.fh1,s.fd1,[s.f10,s.f11,s.f12,s.f13,s.f14,s.f15,s.f16,s.f17]],[s.py1,s.pd1],[s.my1,s.mg1],[s.kt1,s.ky1,s.kk1],[s.cy1]])
93     blok.append([s.ls2,[s.by2,s.bk2,s.bf2,s.fh2,s.fd2,[s.f20,s.f21,s.f22,s.f23,s.f24,s.f25,s.f26,s.f27]],[s.py2,s.pd2],[s.my2,s.mg2],[s.kt2,s.ky2,s.kk2],[s.cy2]])
94     blok.append([s.ls3,[s.by3,s.bk3,s.bf3,s.fh3,s.fd3,[s.f30,s.f31,s.f32,s.f33,s.f34,s.f35,s.f36,s.f37]],[s.py3,s.pd3],[s.my3,s.mg3],[s.kt3,s.ky3,s.kk3],[s.cy3]])
95     blok.append([s.ls4,[s.by4,s.bk4,s.bf4,s.fh4,s.fd4,[s.f40,s.f41,s.f42,s.f43,s.f44,s.f45,s.f46,s.f47]],[s.py4,s.pd4],[s.my4,s.mg4],[s.kt4,s.ky4,s.kk4],[s.cy4]])
96     blok.append([s.ls5,[s.by5,s.bk5,s.bf5,s.fh5,s.fd5,[s.f50,s.f51,s.f52,s.f53,s.f54,s.f55,s.f56,s.f57]],[s.py5,s.pd5],[s.my5,s.mg5],[s.kt5,s.ky5,s.kk5],[s.cy5]])
97     blok.append([s.ls6,[s.by6,s.bk6,s.bf6,s.fh6,s.fd6,[s.f60,s.f61,s.f62,s.f63,s.f64,s.f65,s.f66,s.f67]],[s.py6,s.pd6],[s.my6,s.mg6],[s.kt6,s.ky6,s.kk6],[s.cy6]])
98     blok.append([s.ls7,[s.by7,s.bk7,s.bf7,s.fh7,s.fd7,[s.f70,s.f71,s.f72,s.f73,s.f74,s.f75,s.f76,s.f77]],[s.py7,s.pd7],[s.my7,s.mg7],[s.kt7,s.ky7,s.kk7],[s.cy7]])
99
100     h=-s.dds/100;dh=h+s.dhg/100;du=s.duz/100;
101     lz=s.luz/100;mz=s.muz/200;rz=s.ruz/100
102     dg=-((blok[0][1][1]-s.ddg)/100)
103     if h<0:#Pavement
104         if lz==0 and rz==0:
105             vr=[[-mz,du,h],[ mz,du, h],[-mz,dg, h],[ mz,dg, h],[-mz,dg, 0],
106                 [ mz,dg,0],[-mz, 0,dh],[ mz, 0,dh],[-mz,du,dh],[ mz,du,dh]]
107             fc=[[0,1,3,2],[2,3,5,4],[6,7,9,8]];Dos=[0,1,2]
108         if lz==0 and rz >0:
109             vr=[[-mz,   du,h],[ mz-dg,du, h],[-mz,   dg, h],[ mz-dg,dg, h],[-mz,   dg, 0],
110                 [ mz-dg,dg,0],[-mz, 0,   dh],[ mz-dg, 0,dh],[-mz,   du,dh],[ mz-dg,du,dh],[ mz-dg,du,0]]
111             fc=[[0,1,3,2],[2,3,5,4],[6,7,9,8],[3,1,10,5]];Dos=[0,1,2,3]
112         if lz >0 and rz==0:
113             vr=[[-mz+dg,du,h],[ mz,   du, h],[-mz+dg,dg, h],[ mz,   dg, h],[-mz+dg,dg, 0],
114                 [ mz,   dg,0],[-mz+dg, 0,dh],[ mz,    0,dh],[-mz+dg,du,dh],[ mz,   du,dh],[-mz+dg,du,0]]
115             fc=[[0,1,3,2],[2,3,5,4],[6,7,9,8],[0,2,4,10]];Dos=[0,1,2,3]
116         if lz >0 and rz >0:
117             vr=[[-mz+dg,dg,0],[mz-dg,dg,0],[-mz+dg,dg, h],[mz-dg,dg, h],[-mz+dg,du, h],[mz-dg,du, h],
118                 [-mz+dg,du,0],[mz-dg,du,0],[-mz,    0,dh],[mz,    0,dh],[-mz,   du,dh],[mz,   du,dh]]
119             fc=[[1,0,2,3],[3,2,4,5],[6,4,2,0],[3,5,7,1],[8,9,11,10]];Dos=[0,1,2,3,4]
120     else:
121         vr=[[-mz, 0, h],[mz, 0, h],[-mz,du, h],[mz,du, h],
122             [-mz,du,dh],[mz,du,dh],[-mz, 0,dh],[mz, 0,dh]]
123         fc=[[1,0,2,3],[5,4,6,7]];Dos=[0,1]
124     z=0
125     for i in range(s.lst):
126         if blok[i][0]=='1':#Balcony
127             k1=blok[i][1][1]/100;h =blok[i][1][0]/100
128             fh=blok[i][1][3]/100;fd=blok[i][1][4]/100
129             PR=[[-k1,z],[0,z],[0,z+h],[-k1,z+h]]
130             z+=h;fz=z
131             for f in range(blok[i][1][2]):
132                 fz-=blok[i][1][5][f]/100
133                 PR.append([-k1,   fz   ]);PR.append([-k1+fd,fz   ])
134                 PR.append([-k1+fd,fz-fh]);PR.append([-k1,   fz-fh])
135                 fz-=fh
136             BB=len(fc)
137             EXT(PR,vr,fc,lz,mz,rz)
138             BE=len(fc)
139             for F in range(BB,BE):Bal.append(F)
140         if blok[i][0]=='2':#Bulwark
141             k1=blok[i][2][1]/100;h=blok[i][2][0]/100
142             PR=[[-k1,z],[0,z],[0,z+h],[-k1,z+h]]
143             z+=h
144             BB=len(fc)
145             EXT(PR,vr,fc,lz,mz,rz)
146             BE=len(fc)
147             for F in range(BB,BE):Par.append(F)
148         if blok[i][0]=='3':#Marble
149             k1=blok[0][1][1]/100;k2=blok[i][3][1]/100;h=blok[i][3][0]/100
150             PR=[[-k1-k2,z],[k2,z],[k2,z+h],[-k1-k2,z+h]]
151             z+=h
152             BB=len(fc)
153             EXT(PR,vr,fc,lz,mz,rz)
154             BE=len(fc)
155             for F in range(BB,BE):Mer.append(F)
156         if blok[i][0]=='4':#Chrome
157             k1=blok[0][1][1]/200;k2=blok[i][4][2]/200;h=blok[i][4][1]/100
158             if blok[i][4][0]=="1":#Duz
159                 z+=h
160                 PR=[[-k1-k2,z],[-k1+k2,z],[-k1+k2,z+k2*2],[-k1-k2,z+k2*2]]
161                 z+=k2*2
162             else:#Round
163                 PR=[];z+=h+k2
164                 for a in range(24):
165                     x=-k1+cos(a*pi/12)*k2;y=z+sin(a*pi/12)*k2
166                     PR.append([x,y])
167                 z+=k2
168             BB=len(fc)
169             EXT(PR,vr,fc,lz,mz,rz)
170             BE=len(fc)
171             for F in range(BB,BE):Krm.append(F)
172             if blok[i][4][0]=="2":
173                 for F in range(BB,BE):SM.append(F)
174         if blok[i][0]=='5':#Glass
175             k1=blok[0][1][1]/200;h=blok[i][5][0]/100
176             PR=[[-k1-0.001,z],[-k1+0.001,z],[-k1+0.001,z+h],[-k1-0.001,z+h]]
177             z+=h;BB=len(fc);n=len(vr)
178             fc.append([n+1,n,n+3,n+2])
179             EXT(PR,vr,fc,lz,mz,rz)
180             n=len(vr)
181             fc.append([n-2,n-1,n-4,n-3])
182             BE=len(fc)
183             for F in range(BB,BE):Glass.append(F)
184 #OBJE -----------------------------------------------------------
185     mesh = bpy.data.meshes.new(name='Balcony')
186     mesh.from_pydata(vr,[],fc)
187     for i in SM:
188         mesh.polygons[i].use_smooth = 1
189     mesh.materials.append(MAT('Balcony', 0.66,0.64,0.72))
190     mesh.materials.append(MAT('Bulwark',0.46,0.44,0.52))
191     mesh.materials.append(MAT('Marble', 0.90,0.85,0.80))
192     mesh.materials.append(MAT('Chrome',   0.50,0.55,0.60))
193     mesh.materials.append(MAT('Glass',    0.50,0.80,1.00))
194     mesh.materials.append(MAT('Pavement', 1.00,1.00,1.00))
195
196     for i in Bal:mesh.polygons[i].material_index = 0
197     for i in Par:mesh.polygons[i].material_index = 1
198     for i in Mer:mesh.polygons[i].material_index = 2
199     for i in Krm:mesh.polygons[i].material_index = 3
200     for i in Glass:mesh.polygons[i].material_index = 4
201     for i in Dos:mesh.polygons[i].material_index = 5
202
203     mesh.update(calc_edges=True)
204     object_data_add(context, mesh, operator=None)
205     if bpy.context.mode != 'EDIT_MESH':
206         bpy.ops.object.editmode_toggle()
207         bpy.ops.object.editmode_toggle()
208 #----------------------------------------------------------------
209 class OBJECT_OT_add_balcony(bpy.types.Operator):
210     bl_idname = "mesh.add_say3d_balcony"
211     bl_label = "Balcony"
212     bl_description = "Balcony Olustur"
213     bl_options = {'REGISTER', 'UNDO'}
214     prs = EnumProperty(items = (("1","Joint_Gap",    ""),
215                                 ("2","Bulwark", ""),
216                                 ("3","Glass",     ""),
217                                 ("4","Marquise",  ""),
218                                 ("5","Eaves",   ""),
219                                 ("6","Railing","")))
220     son=prs
221     lst=IntProperty(         min=1,max=   8,default=  3)
222     luz=IntProperty(name='<',min=0,max=1000,default=100)
223     muz=IntProperty(         min=0,max=1000,default=200)
224     ruz=IntProperty(name='>',min=0,max=1000,default=100)
225
226     duz=IntProperty(min=  1,max=500,default=100,description="Pavement Width")
227     dhg=IntProperty(min=  1,max= 50,default= 17,description="Pavement Height")
228     dds=IntProperty(min=-50,max= 50,default= 10,description="Pavement Height")
229     ddg=IntProperty(min=  0,max= 50,default= 10,description="Pavement Width")
230     #Tip
231     ls0=EnumProperty(items=(("1","Balcony",""),("2","Bulwark",""),("3","Marble",""),("4","Chrome",""),("5","Glass","")),default="1")
232     #Balcony
233     by0=IntProperty(name='Elevation',min=1,max=200,default=80,description='Elevation')
234     bk0=IntProperty(name='Thickness', min=1,max= 50,default=20,description='Thickness' )
235     bf0=IntProperty(name='Joint_Gap',     min=0,max=  8,default= 4,description='Joint_Gap'     )
236     fh0=IntProperty(min=1,max= 10,default= 3);fd0=IntProperty(min=1,max= 10,default= 2)
237     f00=IntProperty(min=1,max=200,default=16);f01=IntProperty(min=1,max=200,default=12)
238     f02=IntProperty(min=1,max=200,default=12);f03=IntProperty(min=1,max=200,default=12)
239     f04=IntProperty(min=1,max=200,default= 3);f05=IntProperty(min=1,max=200,default= 3)
240     f06=IntProperty(min=1,max=200,default= 3);f07=IntProperty(min=1,max=200,default= 3)
241     #Bulwark
242     py0=IntProperty(name='Elevation',min=1,max=200,default=80,description='Elevation')
243     pd0=IntProperty(name='Thickness', min=1,max= 50,default=10,description='Thickness' )
244     #Marble
245     my0=IntProperty(name='Elevation',min=1,max=50,default=4,description='Elevation')
246     mg0=IntProperty(name='maxWidth', min=0,max=20,default=4,description='maxWidth' )
247     #Chrome
248     kt0=EnumProperty(items=(("1","Square",""),("2","Round","")))
249     ky0=IntProperty(min=0,max=50,default=5,description='CutOut'  )
250     kk0=IntProperty(min=1,max=20,default=5,description='Thickness')
251     #Glass
252     cy0=IntProperty(name='Elevation',min=1,max=100,default=20,description='Elevation')
253     #--------------------------------------------------------------
254     #Tip
255     ls1=EnumProperty(items=(("1","Balcony",""),("2","Bulwark",""),("3","Marble",""),("4","Chrome",""),("5","Glass","")),default="3")
256     #Balcony
257     by1=IntProperty(name='Elevation',min=1,max=200,default=80,description='Elevation')
258     bk1=IntProperty(name='Thickness', min=1,max= 50,default=20,description='Thickness' )
259     bf1=IntProperty(name='Joint_Gap',     min=0,max=  8,default= 0,description='Joint_Gap'     )
260     fh1=IntProperty(min=1,max= 10,default=3);fd1=IntProperty(min=1,max= 10,default=2)
261     f10=IntProperty(min=1,max=200,default=3);f11=IntProperty(min=1,max=200,default=3)
262     f12=IntProperty(min=1,max=200,default=3);f13=IntProperty(min=1,max=200,default=3)
263     f14=IntProperty(min=1,max=200,default=3);f15=IntProperty(min=1,max=200,default=3)
264     f16=IntProperty(min=1,max=200,default=3);f17=IntProperty(min=1,max=200,default=3)
265     #Bulwark
266     py1=IntProperty(name='Elevation',min=1,max=200,default=80,description='Elevation')
267     pd1=IntProperty(name='Thickness', min=1,max= 50,default=10,description='Thickness' )
268     #Marble
269     my1=IntProperty(name='Elevation',min=1,max=50,default=4,description='Elevation')
270     mg1=IntProperty(name='maxWidth', min=0,max=20,default=4,description='maxWidth' )
271     #Chrome
272     kt1=EnumProperty(items=(("1","Square",""),("2","Round","")))
273     ky1=IntProperty(min=0,max=50,default=5,description='CutOut'  )
274     kk1=IntProperty(min=1,max=20,default=5,description='Thickness')
275     #Glass
276     cy1=IntProperty(name='Elevation',min=1,max=100,default=20,description='Elevation')
277     #--------------------------------------------------------------
278     #Tip
279     ls2=EnumProperty(items=(("1","Balcony",""),("2","Bulwark",""),("3","Marble",""),("4","Chrome",""),("5","Glass","")),default="4")
280     #Balcony
281     by2=IntProperty(name='Elevation',min=1,max=200,default=80,description='Elevation')
282     bk2=IntProperty(name='Thickness', min=1,max= 50,default=20,description='Thickness' )
283     bf2=IntProperty(name='Joint_Gap',     min=0,max=  8,default= 0,description='Joint_Gap'     )
284     fh2=IntProperty(min=1,max= 10,default=3);fd2=IntProperty(min=1,max= 10,default=2)
285     f20=IntProperty(min=1,max=200,default=3);f21=IntProperty(min=1,max=200,default=3)
286     f22=IntProperty(min=1,max=200,default=3);f23=IntProperty(min=1,max=200,default=3)
287     f24=IntProperty(min=1,max=200,default=3);f25=IntProperty(min=1,max=200,default=3)
288     f26=IntProperty(min=1,max=200,default=3);f27=IntProperty(min=1,max=200,default=3)
289     #Bulwark
290     py2=IntProperty(name='Elevation',min=1,max=200,default=80,description='Elevation')
291     pd2=IntProperty(name='Thickness', min=1,max= 50,default=10,description='Thickness' )
292     #Marble
293     my2=IntProperty(name='Elevation',min=1,max=50,default=4,description='Elevation')
294     mg2=IntProperty(name='maxWidth', min=0,max=20,default=4,description='maxWidth' )
295     #Chrome
296     kt2=EnumProperty(items=(("1","Square",""),("2","Round","")),default="2")
297     ky2=IntProperty(min=0,max=50,default=5,description='CutOut'  )
298     kk2=IntProperty(min=1,max=20,default=5,description='Thickness')
299     #Glass
300     cy2=IntProperty(name='Elevation',min=1,max=100,default=20,description='Elevation')
301     #--------------------------------------------------------------
302     #Tip
303     ls3=EnumProperty(items=(("1","Balcony",""),("2","Bulwark",""),("3","Marble",""),("4","Chrome",""),("5","Glass","")),default="4")
304     #Balcony
305     by3=IntProperty(name='Elevation',min=1,max=200,default=80,description='Elevation')
306     bk3=IntProperty(name='Thickness', min=1,max= 50,default=20,description='Thickness' )
307     bf3=IntProperty(name='Joint_Gap',     min=0,max=  8,default= 0,description='Joint_Gap'     )
308     fh3=IntProperty(min=1,max= 10,default=3);fd3=IntProperty(min=1,max= 10,default=2)
309     f30=IntProperty(min=1,max=200,default=3);f31=IntProperty(min=1,max=200,default=3)
310     f32=IntProperty(min=1,max=200,default=3);f33=IntProperty(min=1,max=200,default=3)
311     f34=IntProperty(min=1,max=200,default=3);f35=IntProperty(min=1,max=200,default=3)
312     f36=IntProperty(min=1,max=200,default=3);f37=IntProperty(min=1,max=200,default=3)
313     #Bulwark
314     py3=IntProperty(name='Elevation',min=1,max=200,default=80,description='Elevation')
315     pd3=IntProperty(name='Thickness', min=1,max= 50,default=10,description='Thickness' )
316     #Marble
317     my3=IntProperty(name='Elevation',min=1,max=50,default=4,description='Elevation')
318     mg3=IntProperty(name='maxWidth', min=0,max=20,default=4,description='maxWidth' )
319     #Chrome
320     kt3=EnumProperty(items=(("1","Square",""),("2","Round","")))
321     ky3=IntProperty(min=0,max=50,default=5,description='CutOut'  )
322     kk3=IntProperty(min=1,max=20,default=5,description='Thickness')
323     #Glass
324     cy3=IntProperty(name='Elevation',min=1,max=100,default=20,description='Elevation')
325     #--------------------------------------------------------------
326     #Tip
327     ls4=EnumProperty(items=(("1","Balcony",""),("2","Bulwark",""),("3","Marble",""),("4","Chrome",""),("5","Glass","")),default="4")
328     #Balcony
329     by4=IntProperty(name='Elevation',min=1,max=200,default=80,description='Elevation')
330     bk4=IntProperty(name='Thickness', min=1,max= 50,default=20,description='Thickness' )
331     bf4=IntProperty(name='Joint_Gap',     min=0,max=  8,default= 0,description='Joint_Gap'     )
332     fh4=IntProperty(min=1,max= 10,default=3);fd4=IntProperty(min=1,max= 10,default=2)
333     f40=IntProperty(min=1,max=200,default=3);f41=IntProperty(min=1,max=200,default=3)
334     f42=IntProperty(min=1,max=200,default=3);f43=IntProperty(min=1,max=200,default=3)
335     f44=IntProperty(min=1,max=200,default=3);f45=IntProperty(min=1,max=200,default=3)
336     f46=IntProperty(min=1,max=200,default=3);f47=IntProperty(min=1,max=200,default=3)
337     #Bulwark
338     py4=IntProperty(name='Elevation',min=1,max=200,default=80,description='Elevation')
339     pd4=IntProperty(name='Thickness', min=1,max= 50,default=10,description='Thickness' )
340     #Marble
341     my4=IntProperty(name='Elevation',min=1,max=50,default=4,description='Elevation')
342     mg4=IntProperty(name='maxWidth', min=0,max=20,default=4,description='maxWidth' )
343     #Chrome
344     kt4=EnumProperty(items=(("1","Square",""),("2","Round","")))
345     ky4=IntProperty(min=0,max=50,default=5,description='CutOut'  )
346     kk4=IntProperty(min=1,max=20,default=5,description='Thickness')
347     #Glass
348     cy4=IntProperty(name='Elevation',min=1,max=100,default=20,description='Elevation')
349     #--------------------------------------------------------------
350     #Tip
351     ls5=EnumProperty(items=(("1","Balcony",""),("2","Bulwark",""),("3","Marble",""),("4","Chrome",""),("5","Glass","")),default="4")
352     #Balcony
353     by5=IntProperty(name='Elevation',min=1,max=200,default=80,description='Elevation')
354     bk5=IntProperty(name='Thickness', min=1,max= 50,default=20,description='Thickness' )
355     bf5=IntProperty(name='Joint_Gap',     min=0,max=  8,default= 0,description='Joint_Gap'     )
356     fh5=IntProperty(min=1,max= 10,default=3);fd5=IntProperty(min=1,max= 10,default=2)
357     f50=IntProperty(min=1,max=200,default=3);f51=IntProperty(min=1,max=200,default=3)
358     f52=IntProperty(min=1,max=200,default=3);f53=IntProperty(min=1,max=200,default=3)
359     f54=IntProperty(min=1,max=200,default=3);f55=IntProperty(min=1,max=200,default=3)
360     f56=IntProperty(min=1,max=200,default=3);f57=IntProperty(min=1,max=200,default=3)
361     #Bulwark
362     py5=IntProperty(name='Elevation',min=1,max=200,default=80,description='Elevation')
363     pd5=IntProperty(name='Thickness', min=1,max= 50,default=10,description='Thickness' )
364     #Marble
365     my5=IntProperty(name='Elevation',min=1,max=50,default=4,description='Elevation')
366     mg5=IntProperty(name='maxWidth', min=0,max=20,default=4,description='maxWidth' )
367     #Chrome
368     kt5=EnumProperty(items=(("1","Square",""),("2","Round","")))
369     ky5=IntProperty(min=0,max=50,default=5,description='CutOut'  )
370     kk5=IntProperty(min=1,max=20,default=5,description='Thickness')
371     #Glass
372     cy5=IntProperty(name='Elevation',min=1,max=100,default=20,description='Elevation')
373     #--------------------------------------------------------------
374     #Tip
375     ls6=EnumProperty(items=(("1","Balcony",""),("2","Bulwark",""),("3","Marble",""),("4","Chrome",""),("5","Glass","")),default="4")
376     #Balcony
377     by6=IntProperty(name='Elevation',min=1,max=200,default=80,description='Elevation')
378     bk6=IntProperty(name='Thickness', min=1,max= 50,default=20,description='Thickness' )
379     bf6=IntProperty(name='Joint_Gap',     min=0,max=  8,default= 0,description='Joint_Gap'     )
380     fh6=IntProperty(min=1,max= 10,default=3);fd6=IntProperty(min=1,max= 10,default=2)
381     f60=IntProperty(min=1,max=200,default=3);f61=IntProperty(min=1,max=200,default=3)
382     f62=IntProperty(min=1,max=200,default=3);f63=IntProperty(min=1,max=200,default=3)
383     f64=IntProperty(min=1,max=200,default=3);f65=IntProperty(min=1,max=200,default=3)
384     f66=IntProperty(min=1,max=200,default=3);f67=IntProperty(min=1,max=200,default=3)
385     #Bulwark
386     py6=IntProperty(name='Elevation',min=1,max=200,default=80,description='Elevation')
387     pd6=IntProperty(name='Thickness', min=1,max= 50,default=10,description='Thickness' )
388     #Marble
389     my6=IntProperty(name='Elevation',min=1,max=50,default=4,description='Elevation')
390     mg6=IntProperty(name='maxWidth', min=0,max=20,default=4,description='maxWidth' )
391     #Chrome
392     kt6=EnumProperty(items=(("1","Square",""),("2","Round","")))
393     ky6=IntProperty(min=0,max=50,default=5,description='CutOut'  )
394     kk6=IntProperty(min=1,max=20,default=5,description='Thickness')
395     #Glass
396     cy6=IntProperty(name='Elevation',min=1,max=100,default=20,description='Elevation')
397     #--------------------------------------------------------------
398     #Tip
399     ls7=EnumProperty(items=(("1","Balcony",""),("2","Bulwark",""),("3","Marble",""),("4","Chrome",""),("5","Glass","")),default="4")
400     #Balcony
401     by7=IntProperty(name='Elevation',min=1,max=200,default=80,description='Elevation')
402     bk7=IntProperty(name='Thickness', min=1,max= 50,default=20,description='Thickness' )
403     bf7=IntProperty(name='Joint_Gap',     min=0,max=  8,default= 0,description='Joint_Gap'     )
404     fh7=IntProperty(min=1,max= 10,default=3);fd7=IntProperty(min=1,max= 10,default=2)
405     f70=IntProperty(min=1,max=200,default=3);f71=IntProperty(min=1,max=200,default=3)
406     f72=IntProperty(min=1,max=200,default=3);f73=IntProperty(min=1,max=200,default=3)
407     f74=IntProperty(min=1,max=200,default=3);f75=IntProperty(min=1,max=200,default=3)
408     f76=IntProperty(min=1,max=200,default=3);f77=IntProperty(min=1,max=200,default=3)
409     #Bulwark
410     py7=IntProperty(name='Elevation',min=1,max=200,default=80,description='Elevation')
411     pd7=IntProperty(name='Thickness', min=1,max= 50,default=10,description='Thickness' )
412     #Marble
413     my7=IntProperty(name='Elevation',min=1,max=50,default=4,description='Elevation')
414     mg7=IntProperty(name='maxWidth', min=0,max=20,default=4,description='maxWidth' )
415     #Chrome
416     kt7=EnumProperty(items=(("1","Square",""),("2","Round","")))
417     ky7=IntProperty(min=0,max=50,default=5,description='CutOut'  )
418     kk7=IntProperty(min=1,max=20,default=5,description='Thickness')
419     #Glass
420     cy7=IntProperty(name='Elevation',min=1,max=100,default=20,description='Elevation')
421     #--------------------------------------------------------------
422     def draw(self, context):
423         layout = self.layout
424         layout.prop(self,'prs', text="Wall Style")
425         layout.prop(self,'lst', text="Add Level")
426         row=layout.row()
427         row.label(text="Wall Length & Width")
428         row=layout.row()
429         row.prop(self,'luz')
430         row.prop(self,'muz')
431         row.prop(self,'ruz')
432
433         layout.label('Pavement XYZ')
434         row=layout.row();row.prop(self,'duz');row.prop(self,'dhg')
435         row=layout.row();row.prop(self,'dds');row.prop(self,'ddg')
436
437         ls=[];lf=[]
438         ls.append(self.ls0);lf.append(self.bf0)
439         ls.append(self.ls1);lf.append(self.bf1)
440         ls.append(self.ls2);lf.append(self.bf2)
441         ls.append(self.ls3);lf.append(self.bf3)
442         ls.append(self.ls4);lf.append(self.bf4)
443         ls.append(self.ls5);lf.append(self.bf5)
444         ls.append(self.ls6);lf.append(self.bf6)
445         ls.append(self.ls7);lf.append(self.bf7)
446         for i in range(self.lst-1,-1,-1):
447             box=layout.box()
448             box.prop(self,'ls'+str(i))
449             if  ls[i]=='1':#Balcony
450                 box.prop(self,'by'+str(i))
451                 box.prop(self,'bk'+str(i))
452                 box.prop(self,'bf'+str(i))
453                 if lf[i]>0:
454                     row=box.row()
455                     row.prop(self,'fh'+str(i))
456                     row.prop(self,'fd'+str(i))
457                 for f in range(lf[i]):
458                     box.prop(self,'f'+str(i)+str(f))
459             if  ls[i]=='2':#Bulwark
460                 box.prop(self,'py'+str(i))
461                 box.prop(self,'pd'+str(i))
462             if  ls[i]=='3':#Marble
463                 row=box.row()
464                 row.prop(self,'my'+str(i))
465                 row.prop(self,'mg'+str(i))
466             if  ls[i]=='4':#Chrome
467                 row=box.row()
468                 row.prop(self,'kt'+str(i))
469                 row.prop(self,'ky'+str(i))
470                 row.prop(self,'kk'+str(i))
471             if  ls[i]=='5':#Glass
472                 box.prop(self,'cy'+str(i))
473     def execute(self, context):
474         if self.son!=self.prs:
475             Prs(self,self.prs)
476             self.son=self.prs
477         add_object(self,context)
478         return {'FINISHED'}
479 # Registration
480 def add_object_button(self, context):
481     self.layout.operator(
482         OBJECT_OT_add_balcony.bl_idname,
483         text="Balcony",
484         icon="SNAP_FACE")
485 def register():
486     bpy.utils.register_class(OBJECT_OT_add_balcony)
487     bpy.types.INFO_MT_mesh_add.append(add_object_button)
488 def unregister():
489     bpy.utils.unregister_class(OBJECT_OT_add_balcony)
490     bpy.types.INFO_MT_mesh_add.remove(add_object_button)
491 if __name__ == '__main__':
492     register()