Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonioya <blendergit@gmail.com>2019-01-27 19:34:37 +0300
committerAntonioya <blendergit@gmail.com>2019-01-27 21:17:52 +0300
commit00fe1f9d27ef81d535c4ebfea11e7793a41fe373 (patch)
treecaf550d252e478ac29140b781f4d5133bb7c57a3 /archimesh/achm_column_maker.py
parent117b36e1b5ade3d81dfacbb4da5377ca3aabc92d (diff)
Archimesh: Conversion to 2.80
Adapt the script to new Blender version Task T60910
Diffstat (limited to 'archimesh/achm_column_maker.py')
-rw-r--r--archimesh/achm_column_maker.py106
1 files changed, 54 insertions, 52 deletions
diff --git a/archimesh/achm_column_maker.py b/archimesh/achm_column_maker.py
index ed52ae9c..d1680a9c 100644
--- a/archimesh/achm_column_maker.py
+++ b/archimesh/achm_column_maker.py
@@ -26,6 +26,7 @@
# noinspection PyUnresolvedReferences
import bpy
from math import cos, sin, radians, atan, sqrt
+from bpy.props import BoolProperty, IntProperty, FloatProperty, FloatVectorProperty
from .achm_tools import *
@@ -33,11 +34,11 @@ from .achm_tools import *
# Define UI class
# Columns
# ------------------------------------------------------------------
-class AchmColumn(bpy.types.Operator):
+class ARCHIMESH_OT_Column(bpy.types.Operator):
bl_idname = "mesh.archimesh_column"
bl_label = "Column"
bl_description = "Columns Generator"
- bl_category = 'Archimesh'
+ bl_category = 'View'
bl_options = {'REGISTER', 'UNDO'}
# Define properties
@@ -49,185 +50,185 @@ class AchmColumn(bpy.types.Operator):
),
description="Type of column",
)
- keep_size: bpy.props.BoolProperty(
+ keep_size: BoolProperty(
name="Keep radius equal",
description="Keep all radius (top, mid and bottom) to the same size",
default=True,
)
- rad_top: bpy.props.FloatProperty(
+ rad_top: FloatProperty(
name='Top radius',
min=0.001, max=10, default=0.15, precision=3,
description='Radius of the column in the top',
)
- rad_mid: bpy.props.FloatProperty(
+ rad_mid: FloatProperty(
name='Middle radius',
min=0.001, max=10, default=0.15, precision=3,
description='Radius of the column in the middle',
)
- shift: bpy.props.FloatProperty(
+ shift: FloatProperty(
name='',
min=-1, max=1, default=0, precision=3,
description='Middle displacement',
)
- rad_bottom: bpy.props.FloatProperty(
+ rad_bottom: FloatProperty(
name='Bottom radius',
min=0.001, max=10, default=0.15, precision=3,
description='Radius of the column in the bottom',
)
- col_height: bpy.props.FloatProperty(
+ col_height: FloatProperty(
name='Total height',
min=0.001, max=10, default=2.4, precision=3,
description='Total height of column, including bases and tops',
)
- col_sx: bpy.props.FloatProperty(
+ col_sx: FloatProperty(
name='X size',
min=0.001, max=10, default=0.30, precision=3,
description='Column size for x axis',
)
- col_sy: bpy.props.FloatProperty(
+ col_sy: FloatProperty(
name='Y size',
min=0.001, max=10, default=0.30, precision=3,
description='Column size for y axis',
)
- cir_base: bpy.props.BoolProperty(
+ cir_base: BoolProperty(
name="Include circular base",
description="Include a base with circular form",
default=False,
)
- cir_base_r: bpy.props.FloatProperty(
+ cir_base_r: FloatProperty(
name='Radio',
min=0.001, max=10, default=0.08, precision=3,
description='Rise up radio of base',
)
- cir_base_z: bpy.props.FloatProperty(
+ cir_base_z: FloatProperty(
name='Height',
min=0.001, max=10, default=0.05, precision=3,
description='Size for z axis',
)
- cir_top: bpy.props.BoolProperty(
+ cir_top: BoolProperty(
name="Include circular top",
description="Include a top with circular form",
default=False,
)
- cir_top_r: bpy.props.FloatProperty(
+ cir_top_r: FloatProperty(
name='Radio',
min=0.001, max=10, default=0.08, precision=3,
description='Rise up radio of top',
)
- cir_top_z: bpy.props.FloatProperty(
+ cir_top_z: FloatProperty(
name='Height',
min=0.001, max=10, default=0.05, precision=3,
description='Size for z axis',
)
- box_base: bpy.props.BoolProperty(
+ box_base: BoolProperty(
name="Include rectangular base",
description="Include a base with rectangular form",
default=True,
)
- box_base_x: bpy.props.FloatProperty(
+ box_base_x: FloatProperty(
name='X size',
min=0.001, max=10, default=0.40, precision=3,
description='Size for x axis',
)
- box_base_y: bpy.props.FloatProperty(
+ box_base_y: FloatProperty(
name='Y size',
min=0.001, max=10, default=0.40, precision=3,
description='Size for y axis',
)
- box_base_z: bpy.props.FloatProperty(
+ box_base_z: FloatProperty(
name='Height',
min=0.001, max=10, default=0.05, precision=3,
description='Size for z axis',
)
- box_top: bpy.props.BoolProperty(
+ box_top: BoolProperty(
name="Include rectangular top",
description="Include a top with rectangular form",
default=True,
)
- box_top_x: bpy.props.FloatProperty(
+ box_top_x: FloatProperty(
name='X size',
min=0.001, max=10, default=0.40, precision=3,
description='Size for x axis',
)
- box_top_y: bpy.props.FloatProperty(
+ box_top_y: FloatProperty(
name='Y size',
min=0.001, max=10, default=0.40, precision=3,
description='Size for y axis',
)
- box_top_z: bpy.props.FloatProperty(
+ box_top_z: FloatProperty(
name='Height',
min=0.001, max=10, default=0.05, precision=3,
description='Size for z axis',
)
- arc_top: bpy.props.BoolProperty(
+ arc_top: BoolProperty(
name="Create top arch",
description="Include an arch in the top of the column",
default=False,
)
- arc_radio: bpy.props.FloatProperty(
+ arc_radio: FloatProperty(
name='Arc Radio',
min=0.001, max=10, default=1, precision=1,
description='Radio of the arch',
)
- arc_width: bpy.props.FloatProperty(
+ arc_width: FloatProperty(
name='Thickness',
min=0.01, max=10, default=0.15, precision=2,
description='Thickness of the arch wall',
)
- arc_gap: bpy.props.FloatProperty(
+ arc_gap: FloatProperty(
name='Arc gap',
min=0.01, max=10, default=0.25, precision=2,
description='Size of the gap in the arch sides',
)
- crt_mat: bpy.props.BoolProperty(
+ crt_mat: BoolProperty(
name="Create default Cycles materials",
description="Create default materials for Cycles render",
default=True,
)
- crt_array: bpy.props.BoolProperty(
+ crt_array: BoolProperty(
name="Create array of elements",
description="Create a modifier array for all elemnst",
default=False,
)
- array_num_x: bpy.props.IntProperty(
+ array_num_x: IntProperty(
name='Count X',
min=0, max=100, default=3,
description='Number of elements in array',
)
- array_space_x: bpy.props.FloatProperty(
+ array_space_x: FloatProperty(
name='Distance X',
min=0.000, max=10, default=1, precision=3,
description='Distance between elements (only arc disabled)',
)
- array_num_y: bpy.props.IntProperty(
+ array_num_y: IntProperty(
name='Count Y',
min=0, max=100, default=0,
description='Number of elements in array',
)
- array_space_y: bpy.props.FloatProperty(
+ array_space_y: FloatProperty(
name='Distance Y',
min=0.000, max=10, default=1, precision=3,
description='Distance between elements (only arc disabled)',
)
- array_space_z: bpy.props.FloatProperty(
+ array_space_z: FloatProperty(
name='Distance Z',
min=-10, max=10, default=0, precision=3,
description='Combined X/Z distance between elements (only arc disabled)',
)
- ramp: bpy.props.BoolProperty(
+ ramp: BoolProperty(
name="Deform",
description="Deform top base with Z displacement", default=True,
)
- array_space_factor: bpy.props.FloatProperty(
+ array_space_factor: FloatProperty(
name='Move Y center',
min=0.00, max=1, default=0.0, precision=3,
description='Move the center of the arch in Y axis. (0 centered)',
@@ -322,7 +323,7 @@ class AchmColumn(bpy.types.Operator):
row.prop(self, 'ramp')
box = layout.box()
- if not context.scene.render.engine == 'CYCLES':
+ if not context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
box.enabled = False
box.prop(self, 'crt_mat')
else:
@@ -355,7 +356,7 @@ def create_column_mesh(self):
mycolumn = None
# deactivate others
for o in bpy.data.objects:
- if o.select is True:
+ if o.select_get() is True:
o.select_set(False)
bpy.ops.object.select_all(False)
@@ -374,6 +375,7 @@ def create_column_mesh(self):
height = height - self.box_base_z
if self.box_top:
height = height - self.box_top_z
+
# ------------------------
# Create circular column
# ------------------------
@@ -381,7 +383,7 @@ def create_column_mesh(self):
bpy.ops.object.select_all(False)
mycolumn = create_circular_column(self, "Column", radio_top, radio_mid, radio_bottom, height)
mycolumn.select_set(True)
- bpy.context.scene.objects.active = mycolumn
+ bpy.context.view_layer.objects.active = mycolumn
# Subsurf
set_smooth(mycolumn)
set_modifier_subsurf(mycolumn)
@@ -392,7 +394,7 @@ def create_column_mesh(self):
mycolumn = create_rectangular_base(self, "Column", self.col_sx, self.col_sy, height)
bpy.ops.object.select_all(False)
mycolumn.select_set(True)
- bpy.context.scene.objects.active = mycolumn
+ bpy.context.view_layer.objects.active = mycolumn
set_normals(mycolumn)
# ------------------------
# Circular base
@@ -401,7 +403,7 @@ def create_column_mesh(self):
cir_bottom = create_torus("Column_cir_bottom", radio_bottom, self.cir_base_r, self.cir_base_z)
bpy.ops.object.select_all(False)
cir_bottom.select_set(True)
- bpy.context.scene.objects.active = cir_bottom
+ bpy.context.view_layer.objects.active = cir_bottom
set_modifier_subsurf(cir_bottom)
set_smooth(cir_bottom)
cir_bottom.location.x = 0.0
@@ -417,7 +419,7 @@ def create_column_mesh(self):
self.box_base_z)
bpy.ops.object.select_all(False)
box_bottom.select_set(True)
- bpy.context.scene.objects.active = box_bottom
+ bpy.context.view_layer.objects.active = box_bottom
box_bottom.parent = mycolumn
set_normals(box_bottom)
box_bottom.location.x = 0.0
@@ -433,7 +435,7 @@ def create_column_mesh(self):
cir_top = create_torus("Column_cir_top", radio_top, self.cir_top_r, self.cir_top_z)
bpy.ops.object.select_all(False)
cir_top.select_set(True)
- bpy.context.scene.objects.active = cir_top
+ bpy.context.view_layer.objects.active = cir_top
set_modifier_subsurf(cir_top)
set_smooth(cir_top)
cir_top.parent = mycolumn
@@ -449,7 +451,7 @@ def create_column_mesh(self):
self.box_top_z, self.ramp)
bpy.ops.object.select_all(False)
box_top.select_set(True)
- bpy.context.scene.objects.active = box_top
+ bpy.context.view_layer.objects.active = box_top
set_normals(box_top)
box_top.parent = mycolumn
box_top.location.x = 0.0
@@ -465,7 +467,7 @@ def create_column_mesh(self):
myarc.parent = mycolumn
bpy.ops.object.select_all(False)
myarc.select_set(True)
- bpy.context.scene.objects.active = myarc
+ bpy.context.view_layer.objects.active = myarc
set_normals(myarc)
set_modifier_mirror(myarc, "X")
myarc.location.x = self.arc_radio + self.arc_gap
@@ -530,7 +532,7 @@ def create_column_mesh(self):
# ------------------------
# Create materials
# ------------------------
- if self.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
+ if self.crt_mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
# Column material
mat = create_diffuse_material("Column_material", False, 0.748, 0.734, 0.392, 0.573, 0.581, 0.318)
set_material(mycolumn, mat)
@@ -555,7 +557,7 @@ def create_column_mesh(self):
bpy.ops.object.select_all(False)
mycolumn.select_set(True)
- bpy.context.scene.objects.active = mycolumn
+ bpy.context.view_layer.objects.active = mycolumn
return
@@ -604,7 +606,7 @@ def create_circular_column(self, objname, radio_top, radio_mid, radio_bottom, he
myobject = bpy.data.objects.new(objname, mesh)
myobject.location = bpy.context.scene.cursor_location
- bpy.context.scene.objects.link(myobject)
+ bpy.context.collection.objects.link(myobject)
mesh.from_pydata(myvertex, [], myfaces)
mesh.update(calc_edges=True)
@@ -676,7 +678,7 @@ def create_torus(objname, radio_inside, radio_outside, height):
myobject = bpy.data.objects.new(objname, mesh)
myobject.location = bpy.context.scene.cursor_location
- bpy.context.scene.objects.link(myobject)
+ bpy.context.collection.objects.link(myobject)
mesh.from_pydata(myvertex, [], myfaces)
mesh.update(calc_edges=True)
@@ -725,7 +727,7 @@ def create_rectangular_base(self, objname, x, y, z, ramp=False):
myobject = bpy.data.objects.new(objname, mesh)
myobject.location = bpy.context.scene.cursor_location
- bpy.context.scene.objects.link(myobject)
+ bpy.context.collection.objects.link(myobject)
mesh.from_pydata(myvertex, [], myfaces)
mesh.update(calc_edges=True)
@@ -791,7 +793,7 @@ def create_arc(objname, radio, gap, thickness, center):
myobject = bpy.data.objects.new(objname, mesh)
myobject.location = bpy.context.scene.cursor_location
- bpy.context.scene.objects.link(myobject)
+ bpy.context.collection.objects.link(myobject)
mesh.from_pydata(myvertex, [], myfaces)
mesh.update(calc_edges=True)