Archimesh: Conversion to 2.80

Adapt the script to new Blender version

Task T60910
This commit is contained in:
Antonio Vazquez 2019-01-27 17:34:37 +01:00
parent 117b36e1b5
commit 00fe1f9d27
17 changed files with 541 additions and 585 deletions

View File

@ -29,8 +29,8 @@ bl_info = {
"name": "Archimesh",
"author": "Antonio Vazquez (antonioya)",
"location": "View3D > Add > Mesh > Archimesh",
"version": (1, 1, 4),
"blender": (2, 68, 0),
"version": (1, 2, 0),
"blender": (2, 80, 0),
"description": "Generate rooms, doors, windows, and other architecture objects",
"wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Add_Mesh/Archimesh",
"category": "Add Mesh"
@ -53,7 +53,7 @@ if "bpy" in locals():
importlib.reload(achm_kitchen_maker)
importlib.reload(achm_shelves_maker)
importlib.reload(achm_books_maker)
importlib.reload(achm_light_maker)
importlib.reload(achm_lamp_maker)
importlib.reload(achm_curtain_maker)
importlib.reload(achm_venetian_maker)
importlib.reload(achm_main_panel)
@ -66,7 +66,7 @@ else:
from . import achm_venetian_maker
from . import achm_door_maker
from . import achm_kitchen_maker
from . import achm_light_maker
from . import achm_lamp_maker
from . import achm_main_panel
from . import achm_roof_maker
from . import achm_room_maker
@ -101,129 +101,89 @@ from bpy.types import (
# ----------------------------------------------------------
class AchmInfoMtMeshDecorationAdd(Menu):
class ARCHIMESH_MT_MeshDecorationAdd(Menu):
bl_idname = "VIEW3D_MT_mesh_decoration_add"
bl_label = "Decoration assets"
# noinspection PyUnusedLocal
def draw(self, context):
self.layout.operator("mesh.archimesh_books", text="Add Books")
self.layout.operator("mesh.archimesh_light", text="Add Lamp")
self.layout.operator("mesh.archimesh_roller", text="Add Roller curtains")
self.layout.operator("mesh.archimesh_venetian", text="Add Venetian blind")
self.layout.operator("mesh.archimesh_japan", text="Add Japanese curtains")
self.layout.operator("mesh.archimesh_books", text="Books")
self.layout.operator("mesh.archimesh_light", text="Lamp")
self.layout.operator("mesh.archimesh_roller", text="Roller curtains")
self.layout.operator("mesh.archimesh_venetian", text="Venetian blind")
self.layout.operator("mesh.archimesh_japan", text="Japanese curtains")
# ----------------------------------------------------------
# Registration
# ----------------------------------------------------------
class AchmInfoMtMeshCustomMenuAdd(Menu):
class ARCHIMESH_MT_CustomMenuAdd(Menu):
bl_idname = "VIEW3D_MT_mesh_custom_menu_add"
bl_label = "Archimesh"
# noinspection PyUnusedLocal
def draw(self, context):
self.layout.operator_context = 'INVOKE_REGION_WIN'
self.layout.operator("mesh.archimesh_room", text="Add Room")
self.layout.operator("mesh.archimesh_door", text="Add Door")
self.layout.operator("mesh.archimesh_window", text="Add Rail Window")
self.layout.operator("mesh.archimesh_winpanel", text="Add Panel Window")
self.layout.operator("mesh.archimesh_kitchen", text="Add Cabinet")
self.layout.operator("mesh.archimesh_shelves", text="Add Shelves")
self.layout.operator("mesh.archimesh_column", text="Add Column")
self.layout.operator("mesh.archimesh_stairs", text="Add Stairs")
self.layout.operator("mesh.archimesh_roof", text="Add Roof")
self.layout.operator("mesh.archimesh_room", text="Room")
self.layout.operator("mesh.archimesh_door", text="Door")
self.layout.operator("mesh.archimesh_window", text="Rail Window")
self.layout.operator("mesh.archimesh_winpanel", text="Panel Window")
self.layout.operator("mesh.archimesh_kitchen", text="Cabinet")
self.layout.operator("mesh.archimesh_shelves", text="Shelves")
self.layout.operator("mesh.archimesh_column", text="Column")
self.layout.operator("mesh.archimesh_stairs", text="Stairs")
self.layout.operator("mesh.archimesh_roof", text="Roof")
self.layout.menu("VIEW3D_MT_mesh_decoration_add", text="Decoration props", icon="GROUP")
# --------------------------------------------------------------
# Register all operators and panels
# --------------------------------------------------------------
# Add-ons Preferences Update Panel
# Define Panel classes for updating
panels = (
achm_main_panel.ArchimeshMainPanel,
)
def update_panel(self, context):
message = "Archimesh: Updating Panel locations has failed"
try:
for panel in panels:
if "bl_rna" in panel.__dict__:
bpy.utils.unregister_class(panel)
for panel in panels:
panel.bl_category = context.preferences.addons[__name__].preferences.category
bpy.utils.register_class(panel)
except Exception as e:
print("\n[{}]\n{}\n\nError:\n{}".format(__name__, message, e))
pass
class Archi_Pref(AddonPreferences):
# this must match the addon name, use '__package__'
# when defining this in a submodule of a python package.
bl_idname = __name__
category: StringProperty(
name="Tab Category",
description="Choose a name for the category of the panel",
default="Create",
update=update_panel
)
def draw(self, context):
layout = self.layout
row = layout.row()
col = row.column()
col.label(text="Tab Category:")
col.prop(self, "category", text="")
# Define menu
# noinspection PyUnusedLocal
def AchmMenu_func(self, context):
self.layout.menu("VIEW3D_MT_mesh_custom_menu_add", icon="GROUP")
classes = (
ARCHIMESH_MT_CustomMenuAdd,
ARCHIMESH_MT_MeshDecorationAdd,
achm_room_maker.ARCHIMESH_OT_Room,
achm_room_maker.ARCHIMESH_PT_RoomGenerator,
achm_room_maker.ARCHIMESH_OT_ExportRoom,
achm_room_maker.ARCHIMESH_OT_ImportRoom,
achm_door_maker.ARCHIMESH_OT_Door,
achm_door_maker.ARCHIMESH_PT_DoorObjectgenerator,
achm_window_maker.ARCHIMESH_OT_Windows,
achm_window_maker.ARCHIMESH_PT_WindowObjectgenerator,
achm_roof_maker.ARCHIMESH_OT_Roof,
achm_column_maker.ARCHIMESH_OT_Column,
achm_stairs_maker.ARCHIMESH_OT_Stairs,
achm_kitchen_maker.ARCHIMESH_OT_Kitchen,
achm_kitchen_maker.ARCHIMESH_OT_ExportInventory,
achm_shelves_maker.ARCHIMESH_OT_Shelves,
achm_books_maker.ARCHIMESH_OT_Books,
achm_lamp_maker.ARCHIMESH_PT_Lamp,
achm_curtain_maker.ARCHIMESH_OT_Roller,
achm_curtain_maker.ARCHIMESH_OT_Japan,
achm_venetian_maker.ARCHIMESH_OT_Venetian,
achm_venetian_maker.ARCHIMESH_PT_VenetianObjectgenerator,
achm_main_panel.ARCHIMESH_PT_Main,
achm_main_panel.ARCHIMESH_OT_Hole,
achm_main_panel.ARCHIMESH_OT_Pencil,
achm_main_panel.ARCHIMESH_OT_HintDisplay,
achm_window_panel.ARCHIMESH_PT_Win,
achm_window_panel.ARCHIMESH_PT_WindowEdit
)
def register():
bpy.utils.register_class(AchmInfoMtMeshCustomMenuAdd)
bpy.utils.register_class(AchmInfoMtMeshDecorationAdd)
bpy.utils.register_class(achm_room_maker.AchmRoom)
bpy.utils.register_class(achm_room_maker.AchmRoomGeneratorPanel)
bpy.utils.register_class(achm_room_maker.AchmExportRoom)
bpy.utils.register_class(achm_room_maker.AchmImportRoom)
bpy.utils.register_class(achm_door_maker.AchmDoor)
bpy.utils.register_class(achm_door_maker.AchmDoorObjectgeneratorpanel)
bpy.utils.register_class(achm_window_maker.AchmWindows)
bpy.utils.register_class(achm_window_maker.AchmWindowObjectgeneratorpanel)
bpy.utils.register_class(achm_roof_maker.AchmRoof)
bpy.utils.register_class(achm_column_maker.AchmColumn)
bpy.utils.register_class(achm_stairs_maker.AchmStairs)
bpy.utils.register_class(achm_kitchen_maker.AchmKitchen)
bpy.utils.register_class(achm_kitchen_maker.AchmExportInventory)
bpy.utils.register_class(achm_shelves_maker.AchmShelves)
bpy.utils.register_class(achm_books_maker.AchmBooks)
bpy.utils.register_class(achm_light_maker.AchmLamp)
bpy.utils.register_class(achm_curtain_maker.AchmRoller)
bpy.utils.register_class(achm_curtain_maker.AchmJapan)
bpy.utils.register_class(achm_venetian_maker.AchmVenetian)
bpy.utils.register_class(achm_venetian_maker.AchmVenetianObjectgeneratorpanel)
bpy.utils.register_class(achm_main_panel.ArchimeshMainPanel)
bpy.utils.register_class(achm_main_panel.AchmHoleAction)
bpy.utils.register_class(achm_main_panel.AchmPencilAction)
bpy.utils.register_class(achm_main_panel.AchmRunHintDisplayButton)
bpy.utils.register_class(achm_window_panel.AchmWinPanel)
bpy.utils.register_class(achm_window_panel.AchmWindowEditPanel)
bpy.utils.register_class(Archi_Pref)
from bpy.utils import register_class
for cls in classes:
register_class(cls)
VIEW3D_MT_mesh_add.append(AchmMenu_func)
update_panel(None, bpy.context)
# Define properties
Scene.archimesh_select_only = BoolProperty(
name="Only selected",
@ -304,35 +264,10 @@ def register():
def unregister():
bpy.utils.unregister_class(AchmInfoMtMeshCustomMenuAdd)
bpy.utils.unregister_class(AchmInfoMtMeshDecorationAdd)
bpy.utils.unregister_class(achm_room_maker.AchmRoom)
bpy.utils.unregister_class(achm_room_maker.AchmRoomGeneratorPanel)
bpy.utils.unregister_class(achm_room_maker.AchmExportRoom)
bpy.utils.unregister_class(achm_room_maker.AchmImportRoom)
bpy.utils.unregister_class(achm_door_maker.AchmDoor)
bpy.utils.unregister_class(achm_door_maker.AchmDoorObjectgeneratorpanel)
bpy.utils.unregister_class(achm_window_maker.AchmWindows)
bpy.utils.unregister_class(achm_window_maker.AchmWindowObjectgeneratorpanel)
bpy.utils.unregister_class(achm_roof_maker.AchmRoof)
bpy.utils.unregister_class(achm_column_maker.AchmColumn)
bpy.utils.unregister_class(achm_stairs_maker.AchmStairs)
bpy.utils.unregister_class(achm_kitchen_maker.AchmKitchen)
bpy.utils.unregister_class(achm_kitchen_maker.AchmExportInventory)
bpy.utils.unregister_class(achm_shelves_maker.AchmShelves)
bpy.utils.unregister_class(achm_books_maker.AchmBooks)
bpy.utils.unregister_class(achm_light_maker.AchmLamp)
bpy.utils.unregister_class(achm_curtain_maker.AchmRoller)
bpy.utils.unregister_class(achm_curtain_maker.AchmJapan)
bpy.utils.unregister_class(achm_venetian_maker.AchmVenetian)
bpy.utils.unregister_class(achm_venetian_maker.AchmVenetianObjectgeneratorpanel)
bpy.utils.unregister_class(achm_main_panel.ArchimeshMainPanel)
bpy.utils.unregister_class(achm_main_panel.AchmHoleAction)
bpy.utils.unregister_class(achm_main_panel.AchmPencilAction)
bpy.utils.unregister_class(achm_main_panel.AchmRunHintDisplayButton)
bpy.utils.unregister_class(achm_window_panel.AchmWinPanel)
bpy.utils.unregister_class(achm_window_panel.AchmWindowEditPanel)
bpy.utils.unregister_class(Archi_Pref)
from bpy.utils import unregister_class
for cls in reversed(classes):
unregister_class(cls)
VIEW3D_MT_mesh_add.remove(AchmMenu_func)
# Remove properties
@ -349,7 +284,7 @@ def unregister():
del Scene.archimesh_gl_name
del Scene.archimesh_gl_ghost
# remove OpenGL data
achm_main_panel.AchmRunHintDisplayButton.handle_remove(achm_main_panel.AchmRunHintDisplayButton, bpy.context)
achm_main_panel.ARCHIMESH_OT_HintDisplay.handle_remove(achm_main_panel.ARCHIMESH_OT_HintDisplay, bpy.context)
wm = bpy.context.window_manager
p = 'archimesh_run_opengl'
if p in wm:

View File

@ -38,11 +38,11 @@ from .achm_tools import *
# Define UI class
# Books
# ------------------------------------------------------------------
class AchmBooks(Operator):
class ARCHIMESH_OT_Books(Operator):
bl_idname = "mesh.archimesh_books"
bl_label = "Books"
bl_description = "Books Generator"
bl_category = 'Archimesh'
bl_category = 'View'
bl_options = {'REGISTER', 'UNDO'}
width: FloatProperty(
@ -58,7 +58,7 @@ class AchmBooks(Operator):
description='Bounding book height',
)
num: IntProperty(
name='Number of books', min=1, max=100, default=20,
name='Number of books', min=1, max=100, default=5,
description='Number total of books',
)
@ -137,7 +137,7 @@ class AchmBooks(Operator):
row.prop(self, 'afn', slider=True)
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')
if self.crt_mat:
@ -170,7 +170,7 @@ class AchmBooks(Operator):
def create_book_mesh(self):
# 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)
generate_books(self)
@ -203,7 +203,7 @@ def generate_books(self):
mydata = create_book("Book" + str(x),
self.width, self.depth, self.height,
lastx, myloc.y, myloc.z,
self.crt_mat if bpy.context.scene.render.engine == 'CYCLES' else False,
self.crt_mat if bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'} else False,
self.rX, self.rY, self.rZ, self.rot, ox, oy, oz, ot,
self.objcol, self.rC)
boxes.extend([mydata[0]])
@ -230,11 +230,11 @@ def generate_books(self):
# deactivate others
for o in bpy.data.objects:
if o.select is True:
if o.select_get() is True:
o.select_set(False)
boxes[0].select_set(True)
bpy.context.scene.objects.active = boxes[0]
bpy.context.view_layer.objects.active = boxes[0]
return
@ -361,7 +361,7 @@ def create_book(objname, sx, sy, sz, px, py, pz, mat, frx,
mybook.location[0] = px
mybook.location[1] = py
mybook.location[2] = pz + sin(radians(rot)) * sx
bpy.context.scene.objects.link(mybook)
bpy.context.collection.objects.link(mybook)
mymesh.from_pydata(myvertex, [], myfaces)
mymesh.update(calc_edges=True)
@ -369,7 +369,7 @@ def create_book(objname, sx, sy, sz, px, py, pz, mat, frx,
# ---------------------------------
# Materials and UV Maps
# ---------------------------------
if mat and bpy.context.scene.render.engine == 'CYCLES':
if mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
rgb = objcol
# External
mat = create_diffuse_material(objname + "_material", True,

View File

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

View File

@ -28,6 +28,7 @@ import bpy
from copy import copy
from math import cos, sin, radians
from bpy.types import Operator
from bpy.props import BoolProperty, IntProperty, FloatProperty
from .achm_tools import *
@ -35,62 +36,62 @@ from .achm_tools import *
# Define UI class
# Japanese curtains
# ------------------------------------------------------------------
class AchmJapan(Operator):
class ARCHIMESH_OT_Japan(Operator):
bl_idname = "mesh.archimesh_japan"
bl_label = "Japanese curtains"
bl_description = "Japanese curtains Generator"
bl_category = 'Archimesh'
bl_category = 'View'
bl_options = {'REGISTER', 'UNDO'}
width: bpy.props.FloatProperty(
width: FloatProperty(
name='Width',
min=0.30, max=4, default=1, precision=3,
description='Total width',
)
height: bpy.props.FloatProperty(
height: FloatProperty(
name='Height',
min=0.20, max=50, default=1.8, precision=3,
description='Total height',
)
num: bpy.props.IntProperty(
num: IntProperty(
name='Rails',
min=2, max=5, default=2,
description='Number total of rails',
)
palnum: bpy.props.IntProperty(
palnum: IntProperty(
name='Panels',
min=1, max=2, default=1,
description='Panels by rail',
)
open01: bpy.props.FloatProperty(
open01: FloatProperty(
name='Position 01',
min=0, max=1, default=0, precision=3,
description='Position of the panel',
)
open02: bpy.props.FloatProperty(
open02: FloatProperty(
name='Position 02',
min=0, max=1, default=0, precision=3,
description='Position of the panel',
)
open03: bpy.props.FloatProperty(
open03: FloatProperty(
name='Position 03',
min=0, max=1, default=0, precision=3,
description='Position of the panel',
)
open04: bpy.props.FloatProperty(
open04: FloatProperty(
name='Position 04',
min=0, max=1, default=0, precision=3,
description='Position of the panel',
)
open05: bpy.props.FloatProperty(
open05: FloatProperty(
name='Position 05',
min=0, max=1, default=0, precision=3,
description='Position of the panel',
)
# Materials
crt_mat: bpy.props.BoolProperty(
crt_mat: BoolProperty(
name="Create default Cycles materials",
description="Create default materials for Cycles render",
default=True,
@ -134,11 +135,11 @@ class AchmJapan(Operator):
row.prop(self, 'open05', slider=True)
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')
if self.crt_mat:
box.label("* Remember to verify fabric texture folder")
box.label(text="* Remember to verify fabric texture folder")
else:
row = layout.row()
row.label(text="Warning: Operator does not work in local view mode", icon='ERROR')
@ -163,7 +164,7 @@ class AchmJapan(Operator):
def create_japan_mesh(self):
# 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)
# Create units
@ -176,26 +177,26 @@ def create_japan_mesh(self):
# Define UI class
# Roller curtains
# ------------------------------------------------------------------
class AchmRoller(Operator):
class ARCHIMESH_OT_Roller(Operator):
bl_idname = "mesh.archimesh_roller"
bl_label = "Roller curtains"
bl_description = "Roller_curtains Generator"
bl_category = 'Archimesh'
bl_category = 'View'
bl_options = {'REGISTER', 'UNDO'}
width: bpy.props.FloatProperty(
width: FloatProperty(
name='Width',
min=0.30, max=4, default=1, precision=3,
description='Total width',
)
height: bpy.props.FloatProperty(
height: FloatProperty(
name='Height',
min=0.01, max=50, default=1.7, precision=3,
description='Total height',
)
# Materials
crt_mat: bpy.props.BoolProperty(
crt_mat: BoolProperty(
name="Create default Cycles materials",
description="Create default materials for Cycles render",
default=True,
@ -220,11 +221,11 @@ class AchmRoller(Operator):
row.prop(self, 'height')
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')
if self.crt_mat:
box.label("* Remember to verify fabric texture folder")
box.label(text="* Remember to verify fabric texture folder")
else:
row = layout.row()
row.label(text="Warning: Operator does not work in local view mode", icon='ERROR')
@ -249,7 +250,7 @@ class AchmRoller(Operator):
def create_roller_mesh(self):
# 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)
generate_roller(self)
@ -356,7 +357,7 @@ def generate_japan(self):
posz = -0.008
x = 1
fabricmat = None
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'}:
fabricmat = create_fabric_material("Fabric_material", False, 0.653, 0.485, 0.265,
0.653, 0.485, 0.265)
@ -396,7 +397,7 @@ def generate_japan(self):
mycurve2.location.y = -0.01
mycurve2.location.z = 0.005
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'}:
mat = create_diffuse_material("String_material", False, 0.1, 0.1, 0.1,
0.1, 0.1, 0.1, 0.01)
set_material(mycurve1, mat)
@ -409,11 +410,11 @@ def generate_japan(self):
# deactivate others
for o in bpy.data.objects:
if o.select is True:
if o.select_get() is True:
o.select_set(False)
myrail.select_set(True)
bpy.context.scene.objects.active = myrail
bpy.context.view_layer.objects.active = myrail
return
@ -482,7 +483,7 @@ def create_japan_rail(objname, sx, ways, px, py, pz, mat):
myobject.location[0] = px
myobject.location[1] = py
myobject.location[2] = pz
bpy.context.scene.objects.link(myobject)
bpy.context.collection.objects.link(myobject)
mymesh.from_pydata(myvertex, [], myfaces)
mymesh.update(calc_edges=True)
@ -490,7 +491,7 @@ def create_japan_rail(objname, sx, ways, px, py, pz, mat):
# ---------------------------------
# Materials
# ---------------------------------
if mat and bpy.context.scene.render.engine == 'CYCLES':
if mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
# External
mat = create_diffuse_material(objname + "_material", False, 0.8, 0.8, 0.8, 0.6, 0.6, 0.6, 0.15)
set_material(myobject, mat)
@ -529,7 +530,7 @@ def create_japan_support(objname, sx, px, py, pz, mat):
myobject.location[0] = px
myobject.location[1] = py
myobject.location[2] = pz
bpy.context.scene.objects.link(myobject)
bpy.context.collection.objects.link(myobject)
mymesh.from_pydata(myvertex, [], myfaces)
mymesh.update(calc_edges=True)
@ -537,7 +538,7 @@ def create_japan_support(objname, sx, px, py, pz, mat):
# ---------------------------------
# Materials
# ---------------------------------
if mat and bpy.context.scene.render.engine == 'CYCLES':
if mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
# External
mat = create_diffuse_material(objname + "_material", False, 0.8, 0.8, 0.8, 0.6, 0.6, 0.6, 0.15)
set_material(myobject, mat)
@ -570,7 +571,7 @@ def create_japan_panel(objname, sx, sz, px, py, pz, mat, fabricmat):
myobject.location[0] = px
myobject.location[1] = py
myobject.location[2] = pz
bpy.context.scene.objects.link(myobject)
bpy.context.collection.objects.link(myobject)
mymesh.from_pydata(myvertex, [], myfaces)
mymesh.update(calc_edges=True)
@ -578,7 +579,7 @@ def create_japan_panel(objname, sx, sz, px, py, pz, mat, fabricmat):
# ---------------------------------
# Materials
# ---------------------------------
if mat and bpy.context.scene.render.engine == 'CYCLES':
if mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
unwrap_mesh(myobject, True)
# remap UV to use all texture
for uv_loop in myobject.data.uv_layers.active.data:
@ -603,7 +604,7 @@ def create_bezier(objname, points, origin, depth=0.001, fill='FULL'):
myobject = bpy.data.objects.new(objname, curvedata)
myobject.location = origin
bpy.context.scene.objects.link(myobject)
bpy.context.collection.objects.link(myobject)
polyline = curvedata.splines.new('BEZIER')
polyline.bezier_points.add(len(points) - 1)
@ -631,7 +632,7 @@ def generate_roller(self):
# Roller Top
# ------------------
fabricsolid = None
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'}:
fabricsolid = create_diffuse_material("Fabric_solid_material", False, 0.653, 0.485, 0.265)
myroller = create_roller_rail("Roller",
@ -647,7 +648,7 @@ def generate_roller(self):
# Sides
# --------------------------------------------------------------------------------
plastic = None
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'}:
plastic = create_diffuse_material("Plastic_roller_material", False, 0.653, 0.485, 0.265, 0.653, 0.485, 0.265,
0.2)
@ -669,7 +670,7 @@ def generate_roller(self):
# Panel
# --------------------------------------------------------------------------------
fabricmat = None
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'}:
fabricmat = create_fabric_material("Fabric_translucent_material", False, 0.653, 0.485, 0.265, 0.653, 0.485,
0.265)
@ -707,17 +708,17 @@ def generate_roller(self):
mycurve.location.x = self.width + 0.015
mycurve.location.y = 0
mycurve.location.z = -0.38
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'}:
mat = create_diffuse_material("String_material", False, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.01)
set_material(mycurve, mat)
# deactivate others
for o in bpy.data.objects:
if o.select is True:
if o.select_get() is True:
o.select_set(False)
myroller.select_set(True)
bpy.context.scene.objects.active = myroller
bpy.context.view_layer.objects.active = myroller
return
@ -771,7 +772,7 @@ def create_roller_rail(objname, width, radio, px, py, pz, mat, mymaterial):
mymesh = bpy.data.meshes.new(objname)
myroll = bpy.data.objects.new(objname, mymesh)
bpy.context.scene.objects.link(myroll)
bpy.context.collection.objects.link(myroll)
mymesh.from_pydata(myvertex, [], myfaces)
mymesh.update(calc_edges=True)
@ -781,7 +782,7 @@ def create_roller_rail(objname, width, radio, px, py, pz, mat, mymaterial):
myroll.location.z = pz
# Materials
if mat and bpy.context.scene.render.engine == 'CYCLES':
if mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
set_material(myroll, mymaterial)
# Smooth
@ -811,7 +812,7 @@ def create_roller_sides(myroller, side, px, py, pz, mat, plastic):
mymesh = bpy.data.meshes.new("Side." + side)
myside = bpy.data.objects.new("Side." + side, mymesh)
bpy.context.scene.objects.link(myside)
bpy.context.collection.objects.link(myside)
mymesh.from_pydata(myvertex, [], myfaces)
mymesh.update(calc_edges=True)
# Position
@ -825,7 +826,7 @@ def create_roller_sides(myroller, side, px, py, pz, mat, plastic):
myside.parent = myroller
# Materials
if mat and bpy.context.scene.render.engine == 'CYCLES':
if mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
set_material(myside, plastic)
# Smooth
@ -1103,7 +1104,7 @@ def roller_side():
# myObject: Curve object
# --------------------------------------------------------------------
def set_curve_cycle(myobject):
bpy.context.scene.objects.active = myobject
bpy.context.view_layer.objects.active = myobject
# go edit mode
bpy.ops.object.mode_set(mode='EDIT')
# select all faces

View File

@ -34,11 +34,11 @@ from .achm_tools import *
# ------------------------------------------------------------------
# Define operator class to create object
# ------------------------------------------------------------------
class AchmDoor(Operator):
class ARCHIMESH_OT_Door(Operator):
bl_idname = "mesh.archimesh_door"
bl_label = "Door"
bl_description = "Door"
bl_category = 'Archimesh'
bl_category = 'View'
bl_options = {'REGISTER', 'UNDO'}
# -----------------------------------------------------
@ -48,7 +48,7 @@ class AchmDoor(Operator):
def draw(self, context):
layout = self.layout
row = layout.row()
row.label("Use Properties panel (N) to define parms", icon='INFO')
row.label(text="Use Properties panel (N) to define parms", icon='INFO')
# -----------------------------------------------------
# Execute
@ -77,7 +77,7 @@ def create_object(self, context):
mainmesh = bpy.data.meshes.new("DoorFrane")
mainobject = bpy.data.objects.new("DoorFrame", mainmesh)
mainobject.location = bpy.context.scene.cursor_location
bpy.context.scene.objects.link(mainobject)
bpy.context.collection.objects.link(mainobject)
mainobject.DoorObjectGenerator.add()
# we shape the main object and create other objects as children
@ -86,7 +86,7 @@ def create_object(self, context):
# we select, and activate, main object
mainobject.select_set(True)
bpy.context.scene.objects.active = mainobject
bpy.context.view_layer.objects.active = mainobject
# ------------------------------------------------------------------------------
@ -121,7 +121,7 @@ def update_object(self, context):
# noinspection PyBroadException
try:
# clear child data
child.hide = False # must be visible to avoid bug
child.hide_viewport = False # must be visible to avoid bug
child.hide_render = False # must be visible to avoid bug
old = child.data
child.select_set(True)
@ -151,7 +151,7 @@ def update_object(self, context):
tmp_mesh.name = oldname
# and select, and activate, the main object
o.select_set(True)
bpy.context.scene.objects.active = o
bpy.context.view_layer.objects.active = o
# ------------------------------------------------------------------------------
@ -205,7 +205,7 @@ def shape_children(mainobject, update=False):
mydoor = make_one_door(mp, mainobject, widthr + mp.frame_size, "1")
mydoor.location.x = mp.frame_width / 2 - mp.frame_size
if mp.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
if mp.crt_mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
mat = create_diffuse_material("Door_material", False, 0.8, 0.8, 0.8)
set_material(mainobject, mat)
@ -234,9 +234,9 @@ def shape_children(mainobject, update=False):
myctrl.location.y = -((mp.frame_thick * 3) / 2)
myctrl.location.z = -gap
myctrl.display_type = 'BOUNDS'
myctrl.hide = False
myctrl.hide_viewport = False
myctrl.hide_render = True
if bpy.context.scene.render.engine == 'CYCLES':
if bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
myctrl.cycles_visibility.camera = False
myctrl.cycles_visibility.diffuse = False
myctrl.cycles_visibility.glossy = False
@ -257,9 +257,9 @@ def shape_children(mainobject, update=False):
myctrlbase.location.y = -0.15 - (mp.frame_thick / 3)
myctrlbase.location.z = -0.10
myctrlbase.display_type = 'BOUNDS'
myctrlbase.hide = False
myctrlbase.hide_viewport = False
myctrlbase.hide_render = True
if bpy.context.scene.render.engine == 'CYCLES':
if bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
myctrlbase.cycles_visibility.camera = False
myctrlbase.cycles_visibility.diffuse = False
myctrlbase.cycles_visibility.glossy = False
@ -273,7 +273,7 @@ def shape_children(mainobject, update=False):
# deactivate others
for o in bpy.data.objects:
if o.select is True and o.name != mainobject.name:
if o.select_get() is True and o.name != mainobject.name:
o.select_set(False)
@ -390,18 +390,18 @@ class ObjectProperties(PropertyGroup):
# Register
bpy.utils.register_class(ObjectProperties)
Object.DoorObjectGenerator = CollectionProperty(type=ObjectProperties)
Object.DoorObjectGenerator= CollectionProperty(type=ObjectProperties)
# ------------------------------------------------------------------
# Define panel class to modify object
# ------------------------------------------------------------------
class AchmDoorObjectgeneratorpanel(Panel):
class ARCHIMESH_PT_DoorObjectgenerator(Panel):
bl_idname = "OBJECT_PT_door_generator"
bl_label = "Door"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = 'Archimesh'
bl_category = 'View'
# -----------------------------------------------------
# Verify if visible
@ -459,7 +459,7 @@ class AchmDoorObjectgeneratorpanel(Panel):
layout.prop(myobjdat, 'handle')
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(myobjdat, 'crt_mat')
else:
@ -536,14 +536,14 @@ def make_one_door(self, myframe, width, openside):
if self.handle != "0":
handle1 = create_handle(self, mydoor, "Front", width, openside)
handle1.select_set(True)
bpy.context.scene.objects.active = handle1
bpy.context.view_layer.objects.active = handle1
set_smooth(handle1)
set_modifier_subsurf(handle1)
handle2 = create_handle(self, mydoor, "Back", width, openside)
set_smooth(handle2)
set_modifier_subsurf(handle2)
# 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'}:
# Door material
mat = create_diffuse_material("Door_material", False, 0.8, 0.8, 0.8)
set_material(mydoor, mat)
@ -602,7 +602,7 @@ def create_door_data(self, myframe, width, openside):
myobject = bpy.data.objects.new("Door", mymesh)
myobject.location = bpy.context.scene.cursor_location
bpy.context.scene.objects.link(myobject)
bpy.context.collection.objects.link(myobject)
mymesh.from_pydata(verts, [], faces)
mymesh.update(calc_edges=True)
@ -654,7 +654,7 @@ def create_handle(self, mydoor, pos, frame_width, openside):
myobject = bpy.data.objects.new("Handle_" + pos, mymesh)
myobject.location = bpy.context.scene.cursor_location
bpy.context.scene.objects.link(myobject)
bpy.context.collection.objects.link(myobject)
mymesh.from_pydata(verts, [], faces)
mymesh.update(calc_edges=True)

View File

@ -26,8 +26,6 @@
# noinspection PyUnresolvedReferences
import bpy
# noinspection PyUnresolvedReferences
import bgl
# noinspection PyUnresolvedReferences
import blf
from math import fabs, sqrt, sin, cos
# noinspection PyUnresolvedReferences
@ -35,7 +33,12 @@ from mathutils import Vector
# noinspection PyUnresolvedReferences
from bpy_extras import view3d_utils
from .achm_room_maker import get_wall_points
# GPU
import bgl
import gpu
from gpu_extras.batch import batch_for_shader
shader = gpu.shader.from_builtin('2D_UNIFORM_COLOR')
# -------------------------------------------------------------
# Handle all draw routines (OpenGL main entry point)
@ -46,68 +49,58 @@ def draw_main(context):
rv3d = context.space_data.region_3d
scene = context.scene
rgb = scene.archimesh_text_color
rgbw = scene.archimesh_walltext_color
rgba = scene.archimesh_text_color
rgbaw = scene.archimesh_walltext_color
fsize = scene.archimesh_font_size
wfsize = scene.archimesh_wfont_size
space = scene.archimesh_hint_space
measure = scene.archimesh_gl_measure
dspname = scene.archimesh_gl_name
# Get visible layers
layers = []
for x in range(0, 20):
if context.scene.layers[x] is True:
layers.extend([x])
bgl.glEnable(bgl.GL_BLEND)
# Display selected or all
if scene.archimesh_gl_ghost is False:
objlist = context.selected_objects
else:
objlist = context.scene.objects
objlist = context.view_layer.objects
# ---------------------------------------
# Generate all OpenGL calls
# ---------------------------------------
for myobj in objlist:
if myobj.hide is False:
# verify visible layer
for x in range(0, 20):
if myobj.layers[x] is True:
if x in layers:
# -----------------------------------------------------
# Rooms
# -----------------------------------------------------
if 'RoomGenerator' in myobj:
op = myobj.RoomGenerator[0]
draw_room_data(myobj, op, region, rv3d, rgb, rgbw, fsize, wfsize, space, measure, dspname)
if myobj.visible_get() is True:
# -----------------------------------------------------
# Rooms
# -----------------------------------------------------
if 'RoomGenerator' in myobj:
op = myobj.RoomGenerator[0]
draw_room_data(myobj, op, region, rv3d, rgba, rgbaw, fsize, wfsize, space, measure, dspname)
# -----------------------------------------------------
# Doors
# -----------------------------------------------------
if 'DoorObjectGenerator' in myobj:
op = myobj.DoorObjectGenerator[0]
draw_door_data(myobj, op, region, rv3d, rgb, fsize, space, measure)
# -----------------------------------------------------
# Doors
# -----------------------------------------------------
if 'DoorObjectGenerator' in myobj:
op = myobj.DoorObjectGenerator[0]
draw_door_data(myobj, op, region, rv3d, rgba, fsize, space, measure)
# -----------------------------------------------------
# Window (Rail)
# -----------------------------------------------------
if 'WindowObjectGenerator' in myobj:
op = myobj.WindowObjectGenerator[0]
draw_window_rail_data(myobj, op, region, rv3d, rgb, fsize, space, measure)
# -----------------------------------------------------
# Window (Rail)
# -----------------------------------------------------
if 'WindowObjectGenerator' in myobj:
op = myobj.WindowObjectGenerator[0]
draw_window_rail_data(myobj, op, region, rv3d, rgba, fsize, space, measure)
# -----------------------------------------------------
# Window (Panel)
# -----------------------------------------------------
if 'WindowPanelGenerator' in myobj:
op = myobj.WindowPanelGenerator[0]
draw_window_panel_data(myobj, op, region, rv3d, rgba, fsize, space, measure)
# -----------------------------------------------------
# Window (Panel)
# -----------------------------------------------------
if 'WindowPanelGenerator' in myobj:
op = myobj.WindowPanelGenerator[0]
draw_window_panel_data(myobj, op, region, rv3d, rgb, fsize, space, measure)
break # avoid unnecessary loops
# -----------------------
# restore opengl defaults
# -----------------------
bgl.glLineWidth(1)
bgl.glDisable(bgl.GL_BLEND)
bgl.glColor4f(0.0, 0.0, 0.0, 1.0)
# -------------------------------------------------------------
@ -115,7 +108,7 @@ def draw_main(context):
#
# right: Align to right
# -------------------------------------------------------------
def draw_text(x_pos, y_pos, display_text, rgb, fsize, right=False):
def draw_text(x_pos, y_pos, display_text, rgba, fsize, right=False):
gap = 12
font_id = 0
blf.size(font_id, fsize, 72)
@ -126,7 +119,7 @@ def draw_text(x_pos, y_pos, display_text, rgb, fsize, right=False):
else:
newx = x_pos
blf.position(font_id, newx, y_pos, 0)
bgl.glColor4f(rgb[0], rgb[1], rgb[2], rgb[3])
blf.color(font_id, rgba[0], rgba[1], rgba[2], rgba[3])
blf.draw(font_id, display_text)
return
@ -135,25 +128,26 @@ def draw_text(x_pos, y_pos, display_text, rgb, fsize, right=False):
# Draw an OpenGL line
#
# -------------------------------------------------------------
def draw_line(v1, v2):
def draw_line(v1, v2, rgba):
coords = [(v1[0], v1[1]), (v2[0], v2[1])]
batch = batch_for_shader(shader, 'LINES', {"pos": coords})
# noinspection PyBroadException
try:
if v1 is not None and v2 is not None:
bgl.glBegin(bgl.GL_LINES)
bgl.glVertex2f(*v1)
bgl.glVertex2f(*v2)
bgl.glEnd()
shader.bind()
shader.uniform_float("color", rgba)
batch.draw(shader)
except:
pass
# -------------------------------------------------------------
# Draw room information
#
# rgb: Color
# rgba: Color
# fsize: Font size
# -------------------------------------------------------------
def draw_room_data(myobj, op, region, rv3d, rgb, rgbw, fsize, wfsize, space, measure, dspname):
def draw_room_data(myobj, op, region, rv3d, rgba, rgbaw, fsize, wfsize, space, measure, dspname):
verts, activefaces, activenormals = get_wall_points(myobj)
@ -201,8 +195,6 @@ def draw_room_data(myobj, op, region, rv3d, rgb, rgbw, fsize, wfsize, space, mea
# colour + line setup
bgl.glEnable(bgl.GL_BLEND)
bgl.glLineWidth(1)
bgl.glColor4f(rgb[0], rgb[1], rgb[2], rgb[3])
# --------------------------------
# Measures
# --------------------------------
@ -215,18 +207,18 @@ def draw_room_data(myobj, op, region, rv3d, rgb, rgbw, fsize, wfsize, space, mea
txtpoint2d = view3d_utils.location_3d_to_region_2d(region, rv3d, gap3d)
draw_text(txtpoint2d[0], txtpoint2d[1], "%6.2f" % dist, rgb, fsize)
draw_text(txtpoint2d[0], txtpoint2d[1], "%6.2f" % dist, rgba, fsize)
# Draw horizontal line
draw_line(screen_point_a, screen_point_b)
draw_line(screen_point_a, screen_point_b, rgba)
# Draw vertical line 1 (upper vertical)
draw_line(screen_point_a1, screen_point_a2)
draw_line(screen_point_a1, screen_point_a2, rgba)
# Draw vertical line 2 (upper vertical)
draw_line(screen_point_b1, screen_point_b2)
draw_line(screen_point_b1, screen_point_b2, rgba)
# Draw vertical line 1
draw_line(screen_point_a, screen_point_a1)
draw_line(screen_point_a, screen_point_a1, rgba)
# Draw vertical line 2
draw_line(screen_point_b, screen_point_b1)
draw_line(screen_point_b, screen_point_b1, rgba)
# --------------------------------
# Wall Number
@ -247,7 +239,7 @@ def draw_room_data(myobj, op, region, rv3d, rgb, rgbw, fsize, wfsize, space, mea
if op.walls[i].curved is True:
txt = "Curved: "
draw_text(txtpoint2d[0], txtpoint2d[1], txt + str(i + 1), rgbw, wfsize)
draw_text(txtpoint2d[0], txtpoint2d[1], txt + str(i + 1), rgbaw, wfsize)
return
@ -255,10 +247,10 @@ def draw_room_data(myobj, op, region, rv3d, rgb, rgbw, fsize, wfsize, space, mea
# -------------------------------------------------------------
# Draw door information
#
# rgb: Color
# rgba: Color
# fsize: Font size
# -------------------------------------------------------------
def draw_door_data(myobj, op, region, rv3d, rgb, fsize, space, measure):
def draw_door_data(myobj, op, region, rv3d, rgba, fsize, space, measure):
# Points
a_p1 = get_point(op.glpoint_a, myobj)
@ -312,7 +304,6 @@ def draw_door_data(myobj, op, region, rv3d, rgb, fsize, space, measure):
# colour + line setup
bgl.glEnable(bgl.GL_BLEND)
bgl.glLineWidth(1)
bgl.glColor4f(rgb[0], rgb[1], rgb[2], rgb[3])
# --------------------------------
# Measures
@ -323,43 +314,43 @@ def draw_door_data(myobj, op, region, rv3d, rgb, fsize, space, measure):
txtpoint3d = interpolate3d(a_p1, t_p1, fabs(dist / 2))
gap3d = (a_p2[0], txtpoint3d[1], txtpoint3d[2])
txtpoint2d = view3d_utils.location_3d_to_region_2d(region, rv3d, gap3d)
draw_text(txtpoint2d[0], txtpoint2d[1], "%6.2f" % dist, rgb, fsize, True)
draw_text(txtpoint2d[0], txtpoint2d[1], "%6.2f" % dist, rgba, fsize, True)
draw_line(screen_point_ap2, screen_point_tp2)
draw_line(screen_point_ap3, screen_point_ap1)
draw_line(screen_point_tp3, screen_point_tp1)
draw_line(screen_point_ap2, screen_point_tp2, rgba)
draw_line(screen_point_ap3, screen_point_ap1, rgba)
draw_line(screen_point_tp3, screen_point_tp1, rgba)
# Horizontal
dist = distance(b_p1, c_p1)
txtpoint3d = interpolate3d(b_p1, c_p1, fabs(dist / 2))
gap3d = (txtpoint3d[0], txtpoint3d[1], b_p2[2] + 0.02)
txtpoint2d = view3d_utils.location_3d_to_region_2d(region, rv3d, gap3d)
draw_text(txtpoint2d[0], txtpoint2d[1], "%6.2f" % dist, rgb, fsize)
draw_text(txtpoint2d[0], txtpoint2d[1], "%6.2f" % dist, rgba, fsize)
draw_line(screen_point_bp2, screen_point_cp2)
draw_line(screen_point_bp3, screen_point_bp1)
draw_line(screen_point_cp3, screen_point_cp1)
draw_line(screen_point_bp2, screen_point_cp2, rgba)
draw_line(screen_point_bp3, screen_point_bp1, rgba)
draw_line(screen_point_cp3, screen_point_cp1, rgba)
# Door size
dist = distance(d_p1, e_p1)
txtpoint3d = interpolate3d(d_p1, e_p1, fabs(dist / 2))
gap3d = (txtpoint3d[0], txtpoint3d[1], txtpoint3d[2] + 0.02)
txtpoint2d = view3d_utils.location_3d_to_region_2d(region, rv3d, gap3d)
draw_text(txtpoint2d[0], txtpoint2d[1], "%6.2f" % dist, rgb, fsize)
draw_text(txtpoint2d[0], txtpoint2d[1], "%6.2f" % dist, rgba, fsize)
draw_line(screen_point_dp1, screen_point_ep1)
draw_line(screen_point_dp2, screen_point_dp3)
draw_line(screen_point_ep2, screen_point_ep3)
draw_line(screen_point_dp1, screen_point_ep1, rgba)
draw_line(screen_point_dp2, screen_point_dp3, rgba)
draw_line(screen_point_ep2, screen_point_ep3, rgba)
return
# -------------------------------------------------------------
# Draw window rail information
#
# rgb: Color
# rgba: Color
# fsize: Font size
# -------------------------------------------------------------
def draw_window_rail_data(myobj, op, region, rv3d, rgb, fsize, space, measure):
def draw_window_rail_data(myobj, op, region, rv3d, rgba, fsize, space, measure):
# Points
a_p1 = get_point(op.glpoint_a, myobj)
@ -397,7 +388,6 @@ def draw_window_rail_data(myobj, op, region, rv3d, rgb, fsize, space, measure):
# colour + line setup
bgl.glEnable(bgl.GL_BLEND)
bgl.glLineWidth(1)
bgl.glColor4f(rgb[0], rgb[1], rgb[2], rgb[3])
# --------------------------------
# Measures
@ -408,22 +398,22 @@ def draw_window_rail_data(myobj, op, region, rv3d, rgb, fsize, space, measure):
txtpoint3d = interpolate3d(a_p1, t_p1, fabs(dist / 2))
gap3d = (a_p2[0], txtpoint3d[1], txtpoint3d[2])
txtpoint2d = view3d_utils.location_3d_to_region_2d(region, rv3d, gap3d)
draw_text(txtpoint2d[0], txtpoint2d[1], "%6.2f" % dist, rgb, fsize, True)
draw_text(txtpoint2d[0], txtpoint2d[1], "%6.2f" % dist, rgba, fsize, True)
draw_line(screen_point_ap2, screen_point_tp2)
draw_line(screen_point_ap3, screen_point_ap1)
draw_line(screen_point_tp3, screen_point_tp1)
draw_line(screen_point_ap2, screen_point_tp2, rgba)
draw_line(screen_point_ap3, screen_point_ap1, rgba)
draw_line(screen_point_tp3, screen_point_tp1, rgba)
# Horizontal
dist = distance(b_p1, c_p1)
txtpoint3d = interpolate3d(b_p1, c_p1, fabs(dist / 2))
gap3d = (txtpoint3d[0], txtpoint3d[1], b_p2[2] + 0.02)
txtpoint2d = view3d_utils.location_3d_to_region_2d(region, rv3d, gap3d)
draw_text(txtpoint2d[0], txtpoint2d[1], "%6.2f" % dist, rgb, fsize)
draw_text(txtpoint2d[0], txtpoint2d[1], "%6.2f" % dist, rgba, fsize)
draw_line(screen_point_bp2, screen_point_cp2)
draw_line(screen_point_bp3, screen_point_bp1)
draw_line(screen_point_cp3, screen_point_cp1)
draw_line(screen_point_bp2, screen_point_cp2, rgba)
draw_line(screen_point_bp3, screen_point_bp1, rgba)
draw_line(screen_point_cp3, screen_point_cp1, rgba)
return
@ -431,10 +421,10 @@ def draw_window_rail_data(myobj, op, region, rv3d, rgb, fsize, space, measure):
# -------------------------------------------------------------
# Draw window panel information
#
# rgb: Color
# rgba: Color
# fsize: Font size
# -------------------------------------------------------------
def draw_window_panel_data(myobj, op, region, rv3d, rgb, fsize, space, measure):
def draw_window_panel_data(myobj, op, region, rv3d, rgba, fsize, space, measure):
# Points
a_p1 = get_point(op.glpoint_a, myobj)
@ -504,7 +494,6 @@ def draw_window_panel_data(myobj, op, region, rv3d, rgb, fsize, space, measure):
# colour + line setup
bgl.glEnable(bgl.GL_BLEND)
bgl.glLineWidth(1)
bgl.glColor4f(rgb[0], rgb[1], rgb[2], rgb[3])
# --------------------------------
# Measures
@ -515,22 +504,22 @@ def draw_window_panel_data(myobj, op, region, rv3d, rgb, fsize, space, measure):
txtpoint3d = interpolate3d(a_p1, t_p1, fabs(dist / 2))
gap3d = (a_p2[0], txtpoint3d[1], txtpoint3d[2])
txtpoint2d = view3d_utils.location_3d_to_region_2d(region, rv3d, gap3d)
draw_text(txtpoint2d[0], txtpoint2d[1], "%6.2f" % dist, rgb, fsize, True)
draw_text(txtpoint2d[0], txtpoint2d[1], "%6.2f" % dist, rgba, fsize, True)
draw_line(screen_point_ap2, screen_point_tp2)
draw_line(screen_point_ap3, screen_point_ap1)
draw_line(screen_point_tp3, screen_point_tp1)
draw_line(screen_point_ap2, screen_point_tp2, rgba)
draw_line(screen_point_ap3, screen_point_ap1, rgba)
draw_line(screen_point_tp3, screen_point_tp1, rgba)
# Vertical (Left)
dist = distance(f_p1, d_p1)
txtpoint3d = interpolate3d(f_p1, d_p1, fabs(dist / 2))
gap3d = (f_p2[0], txtpoint3d[1], txtpoint3d[2])
txtpoint2d = view3d_utils.location_3d_to_region_2d(region, rv3d, gap3d)
draw_text(txtpoint2d[0], txtpoint2d[1], "%6.2f" % dist, rgb, fsize)
draw_text(txtpoint2d[0], txtpoint2d[1], "%6.2f" % dist, rgba, fsize)
draw_line(screen_point_fp2, screen_point_dp2)
draw_line(screen_point_fp1, screen_point_fp3)
draw_line(screen_point_dp1, screen_point_dp3)
draw_line(screen_point_fp2, screen_point_dp2, rgba)
draw_line(screen_point_fp1, screen_point_fp3, rgba)
draw_line(screen_point_dp1, screen_point_dp3, rgba)
# Horizontal (not triangle nor arch)
if op.UST != "4" and op.UST != "2":
@ -538,29 +527,29 @@ def draw_window_panel_data(myobj, op, region, rv3d, rgb, fsize, space, measure):
txtpoint3d = interpolate3d(b_p2, c_p2, fabs(dist / 2))
gap3d = (txtpoint3d[0], txtpoint3d[1], txtpoint3d[2] + 0.05)
txtpoint2d = view3d_utils.location_3d_to_region_2d(region, rv3d, gap3d)
draw_text(txtpoint2d[0], txtpoint2d[1], "%6.2f" % dist, rgb, fsize)
draw_text(txtpoint2d[0], txtpoint2d[1], "%6.2f" % dist, rgba, fsize)
draw_line(screen_point_bp2, screen_point_cp2)
draw_line(screen_point_bp3, screen_point_bp1)
draw_line(screen_point_cp3, screen_point_cp1)
draw_line(screen_point_bp2, screen_point_cp2, rgba)
draw_line(screen_point_bp3, screen_point_bp1, rgba)
draw_line(screen_point_cp3, screen_point_cp1, rgba)
else:
dist = distance(b_p1, g_p3)
txtpoint3d = interpolate3d(b_p2, g_p4, fabs(dist / 2))
gap3d = (txtpoint3d[0], txtpoint3d[1], txtpoint3d[2] + 0.05)
txtpoint2d = view3d_utils.location_3d_to_region_2d(region, rv3d, gap3d)
draw_text(txtpoint2d[0], txtpoint2d[1], "%6.2f" % dist, rgb, fsize, True)
draw_text(txtpoint2d[0], txtpoint2d[1], "%6.2f" % dist, rgba, fsize, True)
dist = distance(g_p3, c_p1)
txtpoint3d = interpolate3d(g_p4, c_p2, fabs(dist / 2))
gap3d = (txtpoint3d[0], txtpoint3d[1], txtpoint3d[2] + 0.05)
txtpoint2d = view3d_utils.location_3d_to_region_2d(region, rv3d, gap3d)
draw_text(txtpoint2d[0], txtpoint2d[1], "%6.2f" % dist, rgb, fsize)
draw_text(txtpoint2d[0], txtpoint2d[1], "%6.2f" % dist, rgba, fsize)
draw_line(screen_point_bp2, screen_point_gp4)
draw_line(screen_point_gp4, screen_point_cp2)
draw_line(screen_point_bp3, screen_point_bp1)
draw_line(screen_point_cp3, screen_point_cp1)
draw_line(screen_point_gp3, screen_point_gp5)
draw_line(screen_point_bp2, screen_point_gp4, rgba)
draw_line(screen_point_gp4, screen_point_cp2, rgba)
draw_line(screen_point_bp3, screen_point_bp1, rgba)
draw_line(screen_point_cp3, screen_point_cp1, rgba)
draw_line(screen_point_gp3, screen_point_gp5, rgba)
# Only for Triangle or arch
if op.UST == "2" or op.UST == "4":
@ -568,9 +557,9 @@ def draw_window_panel_data(myobj, op, region, rv3d, rgb, fsize, space, measure):
txtpoint3d = interpolate3d(g_p2, g_p3, fabs(dist / 2))
gap3d = (txtpoint3d[0] + 0.05, txtpoint3d[1], txtpoint3d[2])
txtpoint2d = view3d_utils.location_3d_to_region_2d(region, rv3d, gap3d)
draw_text(txtpoint2d[0], txtpoint2d[1], "%6.2f" % dist, rgb, fsize)
draw_text(txtpoint2d[0], txtpoint2d[1], "%6.2f" % dist, rgba, fsize)
draw_line(screen_point_gp2, screen_point_gp3)
draw_line(screen_point_gp2, screen_point_gp3, rgba)
# Only for Triangle and Inclines or arch
if op.UST == "3" or op.UST == "4" or op.UST == "2":
@ -584,11 +573,11 @@ def draw_window_panel_data(myobj, op, region, rv3d, rgb, fsize, space, measure):
txtpoint3d = interpolate3d(h_p1, h_p3, fabs(dist / 2))
gap3d = (txtpoint3d[0], txtpoint3d[1], txtpoint3d[2] - space - 0.05)
txtpoint2d = view3d_utils.location_3d_to_region_2d(region, rv3d, gap3d)
draw_text(txtpoint2d[0], txtpoint2d[1], "%6.2f" % dist, rgb, fsize)
draw_text(txtpoint2d[0], txtpoint2d[1], "%6.2f" % dist, rgba, fsize)
draw_line(screen_point_ap1, screen_point_hp2)
draw_line(screen_point_hp3, screen_point_hp5)
draw_line(screen_point_hp1, screen_point_hp4)
draw_line(screen_point_ap1, screen_point_hp2, rgba)
draw_line(screen_point_hp3, screen_point_hp5, rgba)
draw_line(screen_point_hp1, screen_point_hp4, rgba)
return
@ -636,7 +625,7 @@ def get_point(v1, mainobject):
# Using World Matrix
vt = Vector((v1[0], v1[1], v1[2], 1))
m4 = mainobject.matrix_world
vt2 = m4 * vt
vt2 = m4 @ vt
v2 = [vt2[0], vt2[1], vt2[2]]
return v2

View File

@ -46,10 +46,10 @@ RotationType_R180 = 3
# ----------------------------------------------------------
# Export menu UI
# ----------------------------------------------------------
class AchmExportInventory(Operator, ExportHelper):
class ARCHIMESH_OT_ExportInventory(Operator, ExportHelper):
bl_idname = "io_export.kitchen_inventory"
bl_description = 'Export kitchen inventory (.txt)'
bl_category = 'Archimesh'
bl_category = 'View'
bl_label = "Export"
# From ExportHelper. Filter filenames.
@ -357,11 +357,11 @@ bpy.utils.register_class(CabinetProperties)
# Define UI class
# Kitchens
# ------------------------------------------------------------------
class AchmKitchen(Operator):
class ARCHIMESH_OT_Kitchen(Operator):
bl_idname = "mesh.archimesh_kitchen"
bl_label = "Cabinets"
bl_description = "Cabinet Generator"
bl_category = 'Archimesh'
bl_category = 'View'
bl_options = {'REGISTER', 'UNDO'}
# Define properties
@ -371,7 +371,12 @@ class AchmKitchen(Operator):
name="Type",
description="Type of cabinets",
)
oldtype = type_cabinet
oldtype: EnumProperty(
items=(('1', "Floor", ""),
('2', "Wall", "")),
name="Type",
description="Type of cabinets",
)
thickness: FloatProperty(
name='Thickness', min=0.001, max=5, default=0.018, precision=3,
@ -522,7 +527,7 @@ class AchmKitchen(Operator):
add_cabinet(self, box, idx + 1, self.cabinets[idx])
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:
@ -607,7 +612,7 @@ def add_cabinet(self, box, num, cabinet):
def create_kitchen_mesh(self):
# 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)
# Create cabinets
@ -833,7 +838,7 @@ def generate_cabinets(self):
set_normals(base)
# 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'}:
mat = create_diffuse_material("Cabinet_material", False, 0.8, 0.8, 0.8)
for box in boxes:
set_material(box, mat)
@ -908,7 +913,7 @@ def create_box(type_cabinet, objname, thickness, sx, sy, sz, px, py, pz, doortyp
myobject.location[0] = px
myobject.location[1] = py
myobject.location[2] = pz
bpy.context.scene.objects.link(myobject)
bpy.context.collection.objects.link(myobject)
mymesh.from_pydata(myvertex, [], myfaces)
mymesh.update(calc_edges=True)
@ -1050,13 +1055,13 @@ def create_baseboard(objname, sx, sy, sz, mat, bl, br, depth, doortype, gap):
mybaseboard.location[0] = 0
mybaseboard.location[1] = 0
mybaseboard.location[2] = 0
bpy.context.scene.objects.link(mybaseboard)
bpy.context.collection.objects.link(mybaseboard)
mymesh.from_pydata(myvertex, [], myfaces)
mymesh.update(calc_edges=True)
# Material
if mat and bpy.context.scene.render.engine == 'CYCLES':
if mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
mat = create_diffuse_material("Baseboard_material", False, 0.8, 0.8, 0.8)
set_material(mybaseboard, mat)
@ -1118,13 +1123,13 @@ def create_countertop(objname, sx, sy, sz, over, mat, doortype, depth, edge):
mycountertop.location[0] = 0
mycountertop.location[1] = 0
mycountertop.location[2] = 0
bpy.context.scene.objects.link(mycountertop)
bpy.context.collection.objects.link(mycountertop)
mymesh.from_pydata(myvertex, [], myfaces)
mymesh.update(calc_edges=True)
# Material
if mat and bpy.context.scene.render.engine == 'CYCLES':
if mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
mat = create_diffuse_material("countertop_material", False, 0, 0, 0, 0.2, 0.2, 0.2, 0.15)
set_material(mycountertop, mat)
@ -1196,7 +1201,7 @@ def create_door(type_cabinet, objname, thickness, sx, sz, doortype, gf, mat, han
mydoor.location[1] = 0
mydoor.location[2] = 0
bpy.context.scene.objects.link(mydoor)
bpy.context.collection.objects.link(mydoor)
mymesh.from_pydata(myvertex, [], myfaces)
mymesh.update(calc_edges=True)
@ -1238,7 +1243,7 @@ def create_door(type_cabinet, objname, thickness, sx, sz, doortype, gf, mat, han
create_handle(handle_model, mydoor, thickness, hpos, mat, handle_x, handle_z)
if mat and bpy.context.scene.render.engine == 'CYCLES':
if mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
# Door material
mat = create_diffuse_material("Door_material", False, 0.8, 0.8, 0.8, 0.279, 0.337, 0.6, 0.2)
set_material(mydoor, mat)
@ -1306,7 +1311,7 @@ def create_drawer(objname, thickness, sx, sy, sz, mat, handle, handle_model, han
mydrawer.location[0] = 0
mydrawer.location[1] = 0
mydrawer.location[2] = 0
bpy.context.scene.objects.link(mydrawer)
bpy.context.collection.objects.link(mydrawer)
mymesh.from_pydata(myvertex, [], myfaces)
mymesh.update(calc_edges=True)
@ -1324,7 +1329,7 @@ def create_drawer(objname, thickness, sx, sy, sz, mat, handle, handle_model, han
create_handle(model, mydrawer, thickness, "TM", mat, 0, handle_z) # always in the top area/middle
# Material
if mat and bpy.context.scene.render.engine == 'CYCLES':
if mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
mat = create_diffuse_material("Drawer_material", False, 0.8, 0.8, 0.8, 0.6, 0.6, 0.6, 0.2)
set_material(mydrawer, mat)
@ -1379,7 +1384,7 @@ def create_handle(model, mydoor, thickness, handle_position, mat, handle_x, hand
mymesh = bpy.data.meshes.new("Handle")
myhandle = bpy.data.objects.new("Handle", mymesh)
bpy.context.scene.objects.link(myhandle)
bpy.context.collection.objects.link(myhandle)
mymesh.from_pydata(myvertex, [], myfaces)
mymesh.update(calc_edges=True)
@ -1447,7 +1452,7 @@ def create_handle(model, mydoor, thickness, handle_position, mat, handle_x, hand
# parent
myhandle.parent = mydoor
# Materials
if mat and bpy.context.scene.render.engine == 'CYCLES':
if mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
mat = create_glossy_material("Handle_material", False, 0.733, 0.779, 0.8, 0.733, 0.779, 0.8, 0.02)
set_material(myhandle, mat)

View File

@ -129,11 +129,11 @@ def set_preset(self):
# Define UI class
# Lamps
# ------------------------------------------------------------------
class AchmLamp(Operator):
class ARCHIMESH_PT_Lamp(Operator):
bl_idname = "mesh.archimesh_light"
bl_label = "Lamp"
bl_description = "Lamp Generator"
bl_category = 'Archimesh'
bl_category = 'View'
bl_options = {'REGISTER', 'UNDO'}
# preset
preset: EnumProperty(
@ -147,7 +147,17 @@ class AchmLamp(Operator):
name="Predefined",
description="Apply predefined design",
)
oldpreset = preset
oldpreset: EnumProperty(
items=(
('0', "None", ""),
('1', "Sphere", ""),
('2', "Pear", ""),
('3', "Vase", ""),
('4', "Rectangular", ""),
),
name="Predefined",
description="Apply predefined design",
)
base_height: FloatProperty(
name='Height',
@ -354,7 +364,7 @@ class AchmLamp(Operator):
row.prop(self, 'tr03')
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')
if self.crt_mat:
@ -389,7 +399,7 @@ class AchmLamp(Operator):
def create_light_mesh(self):
# 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)
generate_light(self)
@ -481,22 +491,22 @@ def generate_light(self):
# Light bulb
# ---------------------
radbulb = 0.02
bpy.ops.mesh.primitive_uv_sphere_add(segments=16, size=radbulb)
bpy.ops.mesh.primitive_uv_sphere_add(segments=16, radius=radbulb)
mybulb = bpy.data.objects[bpy.context.active_object.name]
mybulb.name = "Lamp_Bulb"
mybulb.parent = myholder
mybulb.location = (0, 0, radbulb + self.holder + 0.04)
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'}:
mat = create_emission_material(mybulb.name, True, 0.8, 0.8, 0.8, self.energy)
set_material(mybulb, mat)
# deactivate others
for o in bpy.data.objects:
if o.select is True:
if o.select_get() is True:
o.select_set(False)
mybase.select_set(True)
bpy.context.scene.objects.active = mybase
bpy.context.view_layer.objects.active = mybase
return
@ -534,7 +544,7 @@ def create_light_base(objname, height, px, py, pz, segments, rings, radios, rati
mymesh = bpy.data.meshes.new(objname)
mycylinder = bpy.data.objects.new(objname, mymesh)
bpy.context.scene.objects.link(mycylinder)
bpy.context.collection.objects.link(mycylinder)
mymesh.from_pydata(myvertex, [], myfaces)
mymesh.update(calc_edges=True)
@ -543,7 +553,7 @@ def create_light_base(objname, height, px, py, pz, segments, rings, radios, rati
mycylinder.location.y = py
mycylinder.location.z = pz
# Materials
if mat and bpy.context.scene.render.engine == 'CYCLES':
if mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
rgb = objcol
mymat = create_diffuse_material(mycylinder.name + "_material", True, rgb[0], rgb[1], rgb[2], rgb[0], rgb[1],
rgb[2], 0.1)
@ -571,7 +581,7 @@ def create_lightholder(objname, height, px, py, pz, mat):
mymesh = bpy.data.meshes.new(objname)
mycylinder = bpy.data.objects.new(objname, mymesh)
bpy.context.scene.objects.link(mycylinder)
bpy.context.collection.objects.link(mycylinder)
mymesh.from_pydata(myvertex, [], myfaces)
mymesh.update(calc_edges=True)
@ -581,7 +591,7 @@ def create_lightholder(objname, height, px, py, pz, mat):
mycylinder.location.z = pz
# Materials
if mat and bpy.context.scene.render.engine == 'CYCLES':
if mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
mat = create_diffuse_material(mycylinder.name + "_material", True, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.1)
set_material(mycylinder, mat)
@ -609,7 +619,7 @@ def create_lightholder_strings(objname, height, px, py, pz, radio, shadeh, mat):
mymesh = bpy.data.meshes.new(objname)
mycylinder = bpy.data.objects.new(objname, mymesh)
bpy.context.scene.objects.link(mycylinder)
bpy.context.collection.objects.link(mycylinder)
mymesh.from_pydata(myvertex, [], myfaces)
mymesh.update(calc_edges=True)
@ -627,7 +637,7 @@ def create_lightholder_strings(objname, height, px, py, pz, radio, shadeh, mat):
box2.location = (-0.021, 0, height + 0.004)
# Materials
if mat and bpy.context.scene.render.engine == 'CYCLES':
if mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
mat = create_diffuse_material(mycylinder.name + "_material", True, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.1)
set_material(mycylinder, mat)
set_material(box1, mat)
@ -664,7 +674,7 @@ def create_lightshade(objname, height, px, py, pz, segments, radio1, radio2, ple
mymesh = bpy.data.meshes.new(objname)
mycylinder = bpy.data.objects.new(objname, mymesh)
bpy.context.scene.objects.link(mycylinder)
bpy.context.collection.objects.link(mycylinder)
mymesh.from_pydata(myvertex, [], myfaces)
mymesh.update(calc_edges=True)
@ -673,7 +683,7 @@ def create_lightshade(objname, height, px, py, pz, segments, radio1, radio2, ple
mycylinder.location.y = py
mycylinder.location.z = pz
# materials
if mat and bpy.context.scene.render.engine == 'CYCLES':
if mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
mymat = create_translucent_material(mycylinder.name + "_material", True, 0.8, 0.65, 0.45, 0.8, 0.65, 0.45,
opacity)
set_material(mycylinder, mymat)
@ -699,7 +709,7 @@ def create_box_segments(objname, height, shift):
mymesh = bpy.data.meshes.new(objname)
mysegment = bpy.data.objects.new(objname, mymesh)
bpy.context.scene.objects.link(mysegment)
bpy.context.collection.objects.link(mysegment)
mymesh.from_pydata(myvertex, [], myfaces)
mymesh.update(calc_edges=True)

View File

@ -49,11 +49,11 @@ def isboolean(myobject, childobject):
# ------------------------------------------------------
# Button: Action to link windows and doors
# ------------------------------------------------------
class AchmHoleAction(Operator):
class ARCHIMESH_OT_Hole(Operator):
bl_idname = "object.archimesh_cut_holes"
bl_label = "Auto Holes"
bl_description = "Enable windows and doors holes for any selected object (needs wall thickness)"
bl_category = 'Archimesh'
bl_category = 'View'
# ------------------------------
# Execute
@ -70,7 +70,7 @@ class AchmHoleAction(Operator):
# noinspection PyBroadException
try:
if obj["archimesh.hole_enable"]:
if obj.select is True or scene.archimesh_select_only is False:
if obj.select_get() is True or scene.archimesh_select_only is False:
listobj.extend([obj])
except:
continue
@ -149,7 +149,7 @@ class AchmHoleAction(Operator):
# noinspection PyBroadException
try:
if obj["archimesh.ctrl_base"]:
if obj.select is True or scene.archimesh_select_only is False:
if obj.select_get() is True or scene.archimesh_select_only is False:
# add boolean modifier
if isboolean(mybaseboard, obj) is False:
set_modifier_boolean(mybaseboard, obj)
@ -170,7 +170,7 @@ class AchmHoleAction(Operator):
# noinspection PyBroadException
try:
if obj["archimesh.ctrl_hole"]:
if obj.select is True or scene.archimesh_select_only is False:
if obj.select_get() is True or scene.archimesh_select_only is False:
# add boolean modifier
if isboolean(myshell, obj) is False:
set_modifier_boolean(myshell, obj)
@ -183,11 +183,11 @@ class AchmHoleAction(Operator):
# ------------------------------------------------------
# Button: Action to create room from grease pencil
# ------------------------------------------------------
class AchmPencilAction(Operator):
class ARCHIMESH_OT_Pencil(Operator):
bl_idname = "object.archimesh_pencil_room"
bl_label = "Room from Draw"
bl_description = "Create a room base on grease pencil strokes (draw from top view (7 key))"
bl_category = 'Archimesh'
bl_category = 'View'
# ------------------------------
# Execute
@ -387,12 +387,12 @@ class AchmPencilAction(Operator):
# ------------------------------------------------------------------
# Define panel class for main functions.
# ------------------------------------------------------------------
class ArchimeshMainPanel(Panel):
class ARCHIMESH_PT_Main(Panel):
bl_idname = "ARCHIMESH_PT_main"
bl_label = "Archimesh"
bl_space_type = "VIEW_3D"
bl_region_type = "TOOLS"
bl_category = "Create"
bl_region_type = "UI"
bl_category = "View"
bl_context = "objectmode"
# ------------------------------
@ -486,7 +486,7 @@ class ArchimeshMainPanel(Panel):
txt = 'Hide'
row.operator("archimesh.runopenglbutton", text=txt, icon=icon)
row = box.row()
row.prop(scene, "archimesh_gl_measure", toggle=True, icon="ALIGN")
row.prop(scene, "archimesh_gl_measure", toggle=True, icon="ALIGN_CENTER")
row.prop(scene, "archimesh_gl_name", toggle=True, icon="OUTLINER_OB_FONT")
row.prop(scene, "archimesh_gl_ghost", icon='GHOST_ENABLED')
row = box.row()
@ -514,11 +514,11 @@ class ArchimeshMainPanel(Panel):
# Defines button for enable/disable the tip display
#
# -------------------------------------------------------------
class AchmRunHintDisplayButton(Operator):
class ARCHIMESH_OT_HintDisplay(Operator):
bl_idname = "archimesh.runopenglbutton"
bl_label = "Display hint data manager"
bl_description = "Display additional information in the viewport"
bl_category = 'Archimesh'
bl_category = 'View'
_handle = None # keep function handler
@ -527,8 +527,8 @@ class AchmRunHintDisplayButton(Operator):
# ----------------------------------
@staticmethod
def handle_add(self, context):
if AchmRunHintDisplayButton._handle is None:
AchmRunHintDisplayButton._handle = SpaceView3D.draw_handler_add(draw_callback_px, (self, context),
if ARCHIMESH_OT_HintDisplay._handle is None:
ARCHIMESH_OT_HintDisplay._handle = SpaceView3D.draw_handler_add(draw_callback_px, (self, context),
'WINDOW',
'POST_PIXEL')
context.window_manager.archimesh_run_opengl = True
@ -539,9 +539,9 @@ class AchmRunHintDisplayButton(Operator):
# noinspection PyUnusedLocal
@staticmethod
def handle_remove(self, context):
if AchmRunHintDisplayButton._handle is not None:
SpaceView3D.draw_handler_remove(AchmRunHintDisplayButton._handle, 'WINDOW')
AchmRunHintDisplayButton._handle = None
if ARCHIMESH_OT_HintDisplay._handle is not None:
SpaceView3D.draw_handler_remove(ARCHIMESH_OT_HintDisplay._handle, 'WINDOW')
ARCHIMESH_OT_HintDisplay._handle = None
context.window_manager.archimesh_run_opengl = False
# ------------------------------

View File

@ -35,11 +35,11 @@ from .achm_tools import *
# Define UI class
# Rooms
# ------------------------------------------------------------------
class AchmRoof(Operator):
class ARCHIMESH_OT_Roof(Operator):
bl_idname = "mesh.archimesh_roof"
bl_label = "Roof"
bl_description = "Roof Generator"
bl_category = 'Archimesh'
bl_category = 'View'
bl_options = {'REGISTER', 'UNDO'}
# Define properties
@ -124,14 +124,14 @@ class AchmRoof(Operator):
y = tilesize_y * self.roof_scale * self.roof_height
buf = 'Size: {0:.2f} * {1:.2f} aprox.'.format(x, y)
box.label(buf)
box.label(text=buf)
box = layout.box()
box.prop(self, 'roof_thick')
box.prop(self, 'roof_angle')
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:
@ -158,7 +158,7 @@ class AchmRoof(Operator):
def create_roof_mesh(self):
# 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)
@ -166,10 +166,10 @@ def create_roof_mesh(self):
myroof = mydata[0]
# active object and deactivate others
if bpy.context.scene.objects.active is not None:
bpy.context.scene.objects.active.select_set(False)
if bpy.context.view_layer.objects.active is not None:
bpy.context.view_layer.objects.active.select_set(False)
bpy.context.scene.objects.active = myroof
bpy.context.view_layer.objects.active = myroof
myroof.select_set(True)
# Thicknes
@ -205,14 +205,14 @@ def create_roof_mesh(self):
myroof.rotation_euler = (radians(self.roof_angle), 0.0, 0.0)
# 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'}:
# material
mat = create_diffuse_material("Roof_material", False, 0.482, 0.061, 0.003, 0.581, 0.105, 0.068, 0.01)
set_material(myroof, mat)
bpy.ops.object.select_all(False)
myroof.select_set(True)
bpy.context.scene.objects.active = myroof
bpy.context.view_layer.objects.active = myroof
return
@ -243,7 +243,7 @@ def create_roof(self):
myobject = bpy.data.objects.new("Roof", mymesh)
myobject.location = bpy.context.scene.cursor_location
bpy.context.scene.objects.link(myobject)
bpy.context.collection.objects.link(myobject)
mymesh.from_pydata(verts, [], faces)
mymesh.update(calc_edges=True)

View File

@ -40,10 +40,10 @@ from .achm_tools import *
# ----------------------------------------------------------
# Export menu UI
# ----------------------------------------------------------
class AchmExportRoom(Operator, ExportHelper):
class ARCHIMESH_OT_ExportRoom(Operator, ExportHelper):
bl_idname = "io_export.roomdata"
bl_description = 'Export Room data (.dat)'
bl_category = 'Archimesh'
bl_category = 'View'
bl_label = "Export"
# From ExportHelper. Filter filenames.
@ -152,10 +152,10 @@ class AchmExportRoom(Operator, ExportHelper):
# ----------------------------------------------------------
# Import menu UI
# ----------------------------------------------------------
class AchmImportRoom(Operator, ImportHelper):
class ARCHIMESH_OT_ImportRoom(Operator, ImportHelper):
bl_idname = "io_import.roomdata"
bl_description = 'Import Room data (.dat)'
bl_category = 'Archimesh'
bl_category = 'View'
bl_label = "Import"
# From Helper. Filter filenames.
@ -312,11 +312,11 @@ class AchmImportRoom(Operator, ImportHelper):
# ------------------------------------------------------------------
# Define operator class to create rooms
# ------------------------------------------------------------------
class AchmRoom(Operator):
class ARCHIMESH_OT_Room(Operator):
bl_idname = "mesh.archimesh_room"
bl_label = "Room"
bl_description = "Generate room with walls, baseboard, floor and ceiling"
bl_category = 'Archimesh'
bl_category = 'View'
bl_options = {'REGISTER', 'UNDO'}
# -----------------------------------------------------
@ -326,7 +326,7 @@ class AchmRoom(Operator):
def draw(self, context):
layout = self.layout
row = layout.row()
row.label("Use Properties panel (N) to define parms", icon='INFO')
row.label(text="Use Properties panel (N) to define parms", icon='INFO')
row = layout.row(align=False)
row.operator("io_import.roomdata", text="Import", icon='COPYDOWN')
@ -355,7 +355,7 @@ def create_room(self, context):
roommesh = bpy.data.meshes.new("Room")
roomobject = bpy.data.objects.new("Room", roommesh)
roomobject.location = bpy.context.scene.cursor_location
bpy.context.scene.objects.link(roomobject)
bpy.context.collection.objects.link(roomobject)
roomobject.RoomGenerator.add()
roomobject.RoomGenerator[0].walls.add()
@ -363,8 +363,8 @@ def create_room(self, context):
shape_walls_and_create_children(roomobject, roommesh)
# we select, and activate, main object for the room.
bpy.context.view_layer.objects.active = roomobject
roomobject.select_set(True)
bpy.context.scene.objects.active = roomobject
# -----------------------------------------------------
@ -431,7 +431,7 @@ def update_room(self, context):
tmp_mesh.name = oldname
# and select, and activate, the main object of the room.
o.select_set(True)
bpy.context.scene.objects.active = o
bpy.context.view_layer.objects.active = o
# -----------------------------------------------------
@ -495,7 +495,7 @@ def shape_walls_and_create_children(myroom, tmp_mesh, update=False):
baseboardmesh = bpy.data.meshes.new("Baseboard")
mybase = bpy.data.objects.new("Baseboard", baseboardmesh)
mybase.location = (0, 0, 0)
bpy.context.scene.objects.link(mybase)
bpy.context.collection.objects.link(mybase)
mybase.parent = myroom
mybase.select_set(True)
mybase["archimesh.room_object"] = True
@ -544,7 +544,7 @@ def shape_walls_and_create_children(myroom, tmp_mesh, update=False):
movetotopsolidify(mybase)
# Create materials
if rp.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
if rp.crt_mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
# Wall material (two faces)
mat = create_diffuse_material("Wall_material", False, 0.765, 0.650, 0.588, 0.8, 0.621, 0.570, 0.1, True)
set_material(myroom, mat)
@ -571,7 +571,7 @@ def shape_walls_and_create_children(myroom, tmp_mesh, update=False):
# deactivate others
for o in bpy.data.objects:
if o.select is True and o.name != myroom.name:
if o.select_get() is True and o.name != myroom.name:
o.select_set(False)
@ -791,7 +791,7 @@ def make_curved_wall(myvertex, myfaces, size, wall_angle, lastx, lasty, height,
# ------------------------------------------------------------------------------
def create_floor(rp, typ, myroom):
bpy.context.scene.objects.active = myroom
bpy.context.view_layer.objects.active = myroom
myvertex = []
myfaces = []
@ -823,7 +823,7 @@ def create_floor(rp, typ, myroom):
myobject = bpy.data.objects.new(typ, mymesh)
myobject.location = (0, 0, 0)
bpy.context.scene.objects.link(myobject)
bpy.context.collection.objects.link(myobject)
mymesh.from_pydata(myvertex, [], myfaces)
mymesh.update(calc_edges=True)
@ -1144,7 +1144,7 @@ def add_shell(selobject, objname, rp):
myobject = bpy.data.objects.new(objname, mesh)
myobject.location = selobject.location
bpy.context.scene.objects.link(myobject)
bpy.context.collection.objects.link(myobject)
mesh.from_pydata(myvertex, [], myfaces)
mesh.update(calc_edges=True)
@ -1615,12 +1615,12 @@ def add_wall(idx, box, wall):
# ------------------------------------------------------------------
# Define panel class to modify rooms.
# ------------------------------------------------------------------
class AchmRoomGeneratorPanel(Panel):
class ARCHIMESH_PT_RoomGenerator(Panel):
bl_idname = "OBJECT_PT_room_generator"
bl_label = "Room"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = 'Archimesh'
bl_category = 'View'
# -----------------------------------------------------
# Verify if visible
@ -1692,6 +1692,6 @@ class AchmRoomGeneratorPanel(Panel):
row.prop(room, 'shell_bfactor', slider=True)
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(room, 'crt_mat')

View File

@ -70,11 +70,11 @@ bpy.utils.register_class(ShelvesProperties)
# Define UI class
# Shelves
# ------------------------------------------------------------------
class AchmShelves(Operator):
class ARCHIMESH_OT_Shelves(Operator):
bl_idname = "mesh.archimesh_shelves"
bl_label = "Shelves"
bl_description = "Shelves Generator"
bl_category = 'Archimesh'
bl_category = 'View'
bl_options = {'REGISTER', 'UNDO'}
thickness: FloatProperty(
@ -174,7 +174,7 @@ class AchmShelves(Operator):
add_shelves(self, box, idx + 1, self.shelves[idx])
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:
@ -262,7 +262,7 @@ def add_shelves(self, box, num, sh):
def create_shelves_mesh(self):
# 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)
# Create units
@ -311,14 +311,14 @@ def generate_shelves(self):
# deactivate others
for o in bpy.data.objects:
if o.select is True:
if o.select_get() is True:
o.select_set(False)
boxes[0].select_set(True)
bpy.context.scene.objects.active = boxes[0]
bpy.context.view_layer.objects.active = boxes[0]
# 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'}:
mat = create_diffuse_material("Shelves_material", False, 0.8, 0.8, 0.8)
for box in boxes:
set_material(box, mat)
@ -462,7 +462,7 @@ def create_unit(stype, objname, thickness, sthickness, sx, sy, sz, px, py, pz, l
myobject.location[0] = px
myobject.location[1] = py
myobject.location[2] = pz
bpy.context.scene.objects.link(myobject)
bpy.context.collection.objects.link(myobject)
mymesh.from_pydata(myvertex, [], myfaces)
mymesh.update(calc_edges=True)

View File

@ -35,11 +35,11 @@ from .achm_tools import *
# Define UI class
# Stairs
# ------------------------------------------------------------------
class AchmStairs(Operator):
class ARCHIMESH_OT_Stairs(Operator):
bl_idname = "mesh.archimesh_stairs"
bl_label = "Stairs"
bl_description = "Stairs Generator"
bl_category = 'Archimesh'
bl_category = 'View'
bl_options = {'REGISTER', 'UNDO'}
# Define properties
@ -178,7 +178,7 @@ class AchmStairs(Operator):
row.prop(self, 'side_gap')
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:
@ -206,7 +206,7 @@ def create_stairs_mesh(self):
# 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)
@ -217,7 +217,7 @@ def create_stairs_mesh(self):
mydata = create_stairs(self, "Stairs")
mystairs = mydata[0]
mystairs.select_set(True)
bpy.context.scene.objects.active = mystairs
bpy.context.view_layer.objects.active = mystairs
remove_doubles(mystairs)
set_normals(mystairs)
set_modifier_mirror(mystairs, "X")
@ -240,14 +240,14 @@ def create_stairs_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'}:
# Stairs material
mat = create_diffuse_material("Stairs_material", False, 0.8, 0.8, 0.8)
set_material(mystairs, mat)
bpy.ops.object.select_all(False)
mystairs.select_set(True)
bpy.context.scene.objects.active = mystairs
bpy.context.view_layer.objects.active = mystairs
return
@ -274,7 +274,7 @@ def create_stairs(self, objname):
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)
@ -422,7 +422,7 @@ def create_bezier(objname, points, origin):
myobject.location = origin
myobject.rotation_euler[2] = radians(90)
bpy.context.scene.objects.link(myobject)
bpy.context.collection.objects.link(myobject)
polyline = curvedata.splines.new('BEZIER')
polyline.bezier_points.add(len(points) - 1)

View File

@ -44,7 +44,7 @@ def get_blendunits(units):
# False= faces to outside
# --------------------------------------------------------------------
def set_normals(myobject, direction=False):
bpy.context.scene.objects.active = myobject
bpy.context.view_layer.objects.active = myobject
# go edit mode
bpy.ops.object.mode_set(mode='EDIT')
# select all faces
@ -59,7 +59,7 @@ def set_normals(myobject, direction=False):
# Remove doubles
# --------------------------------------------------------------------
def remove_doubles(myobject):
bpy.context.scene.objects.active = myobject
bpy.context.view_layer.objects.active = myobject
# go edit mode
bpy.ops.object.mode_set(mode='EDIT')
# select all faces
@ -76,12 +76,12 @@ def remove_doubles(myobject):
def set_smooth(myobject):
# deactivate others
for o in bpy.data.objects:
if o.select is True:
if o.select_get() is True:
o.select_set(False)
myobject.select_set(True)
bpy.context.scene.objects.active = myobject
if bpy.context.scene.objects.active.name == myobject.name:
bpy.context.view_layer.objects.active = myobject
if bpy.context.view_layer.objects.active.name == myobject.name:
bpy.ops.object.shade_smooth()
@ -89,8 +89,8 @@ def set_smooth(myobject):
# Add modifier (subdivision)
# --------------------------------------------------------------------
def set_modifier_subsurf(myobject):
bpy.context.scene.objects.active = myobject
if bpy.context.scene.objects.active.name == myobject.name:
bpy.context.view_layer.objects.active = myobject
if bpy.context.view_layer.objects.active.name == myobject.name:
bpy.ops.object.modifier_add(type='SUBSURF')
for mod in myobject.modifiers:
if mod.type == 'SUBSURF':
@ -103,25 +103,25 @@ def set_modifier_subsurf(myobject):
def set_modifier_mirror(myobject, axis="Y"):
bpy.ops.object.select_all(False)
myobject.select_set(True)
bpy.context.scene.objects.active = myobject
if bpy.context.scene.objects.active.name == myobject.name:
bpy.context.view_layer.objects.active = myobject
if bpy.context.view_layer.objects.active.name == myobject.name:
bpy.ops.object.modifier_add(type='MIRROR')
for mod in myobject.modifiers:
if mod.type == 'MIRROR':
if axis == "X":
mod.use_x = True
mod.use_axis[0] = True
else:
mod.use_x = False
mod.use__axis[0] = False
if axis == "Y":
mod.use_y = True
mod.use_axis[1] = True
else:
mod.use_y = False
mod.use_axis[1] = False
if axis == "Z":
mod.use_z = True
mod.use_axis[2] = True
else:
mod.use_z = False
mod.use_axis[2] = False
mod.use_clip = True
@ -132,8 +132,8 @@ def set_modifier_mirror(myobject, axis="Y"):
def set_modifier_array(myobject, axis, move, repeat, fix=False, fixmove=0, zmove=0):
bpy.ops.object.select_all(False)
myobject.select_set(True)
bpy.context.scene.objects.active = myobject
if bpy.context.scene.objects.active.name == myobject.name:
bpy.context.view_layer.objects.active = myobject
if bpy.context.view_layer.objects.active.name == myobject.name:
bpy.ops.object.modifier_add(type='ARRAY')
for mod in myobject.modifiers:
if mod.type == 'ARRAY':
@ -162,8 +162,8 @@ def set_modifier_array(myobject, axis, move, repeat, fix=False, fixmove=0, zmove
# Add modifier (curve)
# --------------------------------------------------------------------
def set_modifier_curve(myobject, mycurve):
bpy.context.scene.objects.active = myobject
if bpy.context.scene.objects.active.name == myobject.name:
bpy.context.view_layer.objects.active = myobject
if bpy.context.view_layer.objects.active.name == myobject.name:
bpy.ops.object.modifier_add(type='CURVE')
for mod in myobject.modifiers:
if mod.type == 'CURVE':
@ -175,8 +175,8 @@ def set_modifier_curve(myobject, mycurve):
# Add modifier (solidify)
# --------------------------------------------------------------------
def set_modifier_solidify(myobject, width):
bpy.context.scene.objects.active = myobject
if bpy.context.scene.objects.active.name == myobject.name:
bpy.context.view_layer.objects.active = myobject
if bpy.context.view_layer.objects.active.name == myobject.name:
bpy.ops.object.modifier_add(type='SOLIDIFY')
for mod in myobject.modifiers:
if mod.type == 'SOLIDIFY':
@ -190,8 +190,8 @@ def set_modifier_solidify(myobject, width):
# Add modifier (boolean)
# --------------------------------------------------------------------
def set_modifier_boolean(myobject, bolobject):
bpy.context.scene.objects.active = myobject
if bpy.context.scene.objects.active.name == myobject.name:
bpy.context.view_layer.objects.active = myobject
if bpy.context.view_layer.objects.active.name == myobject.name:
bpy.ops.object.modifier_add(type='BOOLEAN')
mod = myobject.modifiers[len(myobject.modifiers) - 1]
mod.operation = 'DIFFERENCE'
@ -202,8 +202,8 @@ def set_modifier_boolean(myobject, bolobject):
# Set material to object
# --------------------------------------------------------------------
def set_material(myobject, mymaterial):
bpy.context.scene.objects.active = myobject
if bpy.context.scene.objects.active.name == myobject.name:
bpy.context.view_layer.objects.active = myobject
if bpy.context.view_layer.objects.active.name == myobject.name:
myobject.data.materials.append(mymaterial)
@ -211,10 +211,10 @@ def set_material(myobject, mymaterial):
# Set material to selected faces
# --------------------------------------------------------------------
def set_material_faces(myobject, idx):
bpy.context.scene.objects.active = myobject
bpy.context.view_layer.objects.active = myobject
myobject.select_set(True)
bpy.context.object.active_material_index = idx
if bpy.context.scene.objects.active.name == myobject.name:
if bpy.context.view_layer.objects.active.name == myobject.name:
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.object.material_slot_assign()
# Deselect
@ -227,8 +227,8 @@ def set_material_faces(myobject, idx):
# --------------------------------------------------------------------
def select_faces(myobject, selface, clear):
myobject.select_set(True)
bpy.context.scene.objects.active = myobject
if bpy.context.scene.objects.active.name == myobject.name:
bpy.context.view_layer.objects.active = myobject
if bpy.context.view_layer.objects.active.name == myobject.name:
# deselect everything
if clear:
bpy.ops.object.mode_set(mode='EDIT')
@ -244,8 +244,8 @@ def select_faces(myobject, selface, clear):
# --------------------------------------------------------------------
def select_vertices(myobject, selvertices, clear=True):
myobject.select_set(True)
bpy.context.scene.objects.active = myobject
if bpy.context.scene.objects.active.name == myobject.name:
bpy.context.view_layer.objects.active = myobject
if bpy.context.view_layer.objects.active.name == myobject.name:
# deselect everything
if clear:
bpy.ops.object.mode_set(mode='EDIT')
@ -273,8 +273,8 @@ def mark_seam(myobject):
# noinspection PyBroadException
try:
myobject.select_set(True)
bpy.context.scene.objects.active = myobject
if bpy.context.scene.objects.active.name == myobject.name:
bpy.context.view_layer.objects.active = myobject
if bpy.context.view_layer.objects.active.name == myobject.name:
bpy.ops.object.mode_set(mode='EDIT', toggle=False)
bpy.ops.mesh.mark_seam()
bpy.ops.object.mode_set(mode='OBJECT')
@ -289,8 +289,8 @@ def unwrap_mesh(myobject, allfaces=True):
# noinspection PyBroadException
try:
myobject.select_set(True)
bpy.context.scene.objects.active = myobject
if bpy.context.scene.objects.active.name == myobject.name:
bpy.context.view_layer.objects.active = myobject
if bpy.context.view_layer.objects.active.name == myobject.name:
# Unwrap
bpy.ops.object.mode_set(mode='EDIT', toggle=False)
if allfaces is True:
@ -886,7 +886,7 @@ def parentobject(parentobj, childobj):
# noinspection PyBroadException
try:
bpy.ops.object.select_all(action='DESELECT')
bpy.context.scene.objects.active = parentobj
bpy.context.view_layer.objects.active = parentobj
parentobj.select_set(True)
childobj.select_set(True)
bpy.ops.object.parent_set(type='OBJECT', keep_transform=False)
@ -923,7 +923,7 @@ def create_control_box(objname, x, y, z, tube=True):
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)

View File

@ -34,11 +34,11 @@ from .achm_tools import *
# ------------------------------------------------------------------
# Define operator class to create object
# ------------------------------------------------------------------
class AchmVenetian(Operator):
class ARCHIMESH_OT_Venetian(Operator):
bl_idname = "mesh.archimesh_venetian"
bl_label = "Venetian blind"
bl_description = "Venetian"
bl_category = 'Archimesh'
bl_category = 'View'
bl_options = {'REGISTER', 'UNDO'}
# -----------------------------------------------------
@ -48,7 +48,7 @@ class AchmVenetian(Operator):
def draw(self, context):
layout = self.layout
row = layout.row()
row.label("Use Properties panel (N) to define parms", icon='INFO')
row.label(text="Use Properties panel (N) to define parms", icon='INFO')
# -----------------------------------------------------
# Execute
@ -77,7 +77,7 @@ def create_object(self, context):
mainmesh = bpy.data.meshes.new("VenetianFrane")
mainobject = bpy.data.objects.new("VenetianFrame", mainmesh)
mainobject.location = bpy.context.scene.cursor_location
bpy.context.scene.objects.link(mainobject)
bpy.context.collection.objects.link(mainobject)
mainobject.VenetianObjectGenerator.add()
# we shape the main object and create other objects as children
@ -85,7 +85,7 @@ def create_object(self, context):
# we select, and activate, main object
mainobject.select_set(True)
bpy.context.scene.objects.active = mainobject
bpy.context.view_layer.objects.active = mainobject
# ------------------------------------------------------------------------------
@ -124,7 +124,7 @@ def update_object(self, context):
tmp_mesh.name = oldname
# and select, and activate, the main object
o.select_set(True)
bpy.context.scene.objects.active = o
bpy.context.view_layer.objects.active = o
# ------------------------------------------------------------------------------
@ -138,7 +138,7 @@ def shape_mesh_and_create_children(mainobject, tmp_mesh, update=False):
mat = None
plastic = None
if mp.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
if mp.crt_mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
rgb = mp.objcol
plastic = create_diffuse_material("Plastic_venetian_material", True, rgb[0], rgb[1], rgb[2], rgb[0], rgb[1],
rgb[2], 0.2)
@ -149,7 +149,7 @@ def shape_mesh_and_create_children(mainobject, tmp_mesh, update=False):
create_venetian_top(tmp_mesh, mp.width + 0.002, mp.depth + 0.002, -0.06)
# materials
if mp.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
if mp.crt_mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
set_material(mainobject, plastic)
# --------------------------------------------------------------------------------
# segments
@ -169,7 +169,7 @@ def shape_mesh_and_create_children(mainobject, tmp_mesh, update=False):
set_normals(myslats)
set_smooth(myslats)
if mp.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
if mp.crt_mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
set_material(myslats, plastic)
# ------------------------
# Strings (Middle)
@ -201,7 +201,7 @@ def shape_mesh_and_create_children(mainobject, tmp_mesh, update=False):
mycurver.location.y = 0
mycurver.location.z = 0
if mp.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
if mp.crt_mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
mat = create_diffuse_material("String_material", False, 0.674, 0.617, 0.496, 0.1, 0.1, 0.1, 0.01)
set_material(mycurvel, mat)
set_material(mycurvec, mat)
@ -237,7 +237,7 @@ def shape_mesh_and_create_children(mainobject, tmp_mesh, update=False):
mycurverf.location.y = ((-mp.depth / 2) * cos(radians(mp.angle))) - 0.001
mycurverf.location.z = 0
if mp.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
if mp.crt_mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
set_material(mycurvelf, mat)
set_material(mycurvecf, mat)
set_material(mycurverf, mat)
@ -274,7 +274,7 @@ def shape_mesh_and_create_children(mainobject, tmp_mesh, update=False):
mycurverb.location.y = ((mp.depth / 2) * cos(radians(mp.angle))) + 0.001
mycurverb.location.z = 0
if mp.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
if mp.crt_mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
set_material(mycurvelb, mat)
set_material(mycurvecb, mat)
set_material(mycurverb, mat)
@ -290,7 +290,7 @@ def shape_mesh_and_create_children(mainobject, tmp_mesh, update=False):
mybase.rotation_euler = (radians(angleused), 0, 0)
# materials
if mp.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
if mp.crt_mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
set_material(mybase, plastic)
# ------------------
# Stick
@ -301,7 +301,7 @@ def shape_mesh_and_create_children(mainobject, tmp_mesh, update=False):
mystick.location.y = -mp.depth / 2 - 0.003
mystick.location.z = -0.03
# materials
if mp.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
if mp.crt_mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
matstick = create_diffuse_material("Stick_material", False, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.04)
set_material(mybase, matstick)
@ -314,11 +314,11 @@ def shape_mesh_and_create_children(mainobject, tmp_mesh, update=False):
mystring.location.y = -mp.depth / 2 - 0.003
mystring.location.z = -0.03
if mp.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
if mp.crt_mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
set_material(mystring, mat)
# deactivate others
for o in bpy.data.objects:
if o.select is True and o.name != mainobject.name:
if o.select_get() is True and o.name != mainobject.name:
o.select_set(False)
return
@ -376,12 +376,12 @@ Object.VenetianObjectGenerator = CollectionProperty(type=ObjectProperties)
# ------------------------------------------------------------------
# Define panel class to modify object
# ------------------------------------------------------------------
class AchmVenetianObjectgeneratorpanel(Panel):
class ARCHIMESH_PT_VenetianObjectgenerator(Panel):
bl_idname = "OBJECT_PT_venetian_generator"
bl_label = "Venetian"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = 'Archimesh'
bl_category = 'View'
# -----------------------------------------------------
# Verify if visible
@ -430,7 +430,7 @@ class AchmVenetianObjectgeneratorpanel(Panel):
row.prop(myobjdat, 'ratio', slider=True)
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(myobjdat, 'crt_mat')
if myobjdat.crt_mat:
@ -518,7 +518,7 @@ def create_slat_mesh(objname, width, depth, height, angle, ratio):
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)
@ -644,7 +644,7 @@ def create_venetian_base(objname, x, y, z):
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)
@ -809,7 +809,7 @@ def get_venetian_stick(objname, 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)
@ -1375,7 +1375,7 @@ def get_venetian_strings(objname, 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)
@ -1396,7 +1396,7 @@ def create_bezier(objname, points, origin, depth=0.001, fill='FULL'):
myobject = bpy.data.objects.new(objname, curvedata)
myobject.location = origin
bpy.context.scene.objects.link(myobject)
bpy.context.collection.objects.link(myobject)
polyline = curvedata.splines.new('BEZIER')
polyline.bezier_points.add(len(points) - 1)

View File

@ -34,11 +34,11 @@ from .achm_tools import *
# ------------------------------------------------------------------
# Define operator class to create object
# ------------------------------------------------------------------
class AchmWindows(Operator):
class ARCHIMESH_OT_Windows(Operator):
bl_idname = "mesh.archimesh_window"
bl_label = "Rail Windows"
bl_description = "Rail Windows Generator"
bl_category = 'Archimesh'
bl_category = 'View'
bl_options = {'REGISTER', 'UNDO'}
# -----------------------------------------------------
@ -48,7 +48,7 @@ class AchmWindows(Operator):
def draw(self, context):
layout = self.layout
row = layout.row()
row.label("Use Properties panel (N) to define parms", icon='INFO')
row.label(text="Use Properties panel (N) to define parms", icon='INFO')
# -----------------------------------------------------
# Execute
@ -77,7 +77,7 @@ def create_object(self, context):
mainmesh = bpy.data.meshes.new("WindowFrane")
mainobject = bpy.data.objects.new("WindowFrame", mainmesh)
mainobject.location = bpy.context.scene.cursor_location
bpy.context.scene.objects.link(mainobject)
bpy.context.collection.objects.link(mainobject)
mainobject.WindowObjectGenerator.add()
# we shape the main object and create other objects as children
@ -85,7 +85,7 @@ def create_object(self, context):
# we select, and activate, main object
mainobject.select_set(True)
bpy.context.scene.objects.active = mainobject
bpy.context.view_layer.objects.active = mainobject
# ------------------------------------------------------------------------------
@ -120,7 +120,7 @@ def update_object(self, context):
# noinspection PyBroadException
try:
# clear child data
child.hide = False # must be visible to avoid bug
child.hide_viewport = False # must be visible to avoid bug
child.hide_render = False # must be visible to avoid bug
old = child.data
child.select_set(True)
@ -149,7 +149,7 @@ def update_object(self, context):
tmp_mesh.name = oldname
# and select, and activate, the main object
o.select_set(True)
bpy.context.scene.objects.active = o
bpy.context.view_layer.objects.active = o
# ------------------------------------------------------------------------------
@ -217,9 +217,9 @@ def shape_mesh_and_create_children(mainobject, tmp_mesh, update=False):
myctrl.location.y = -mp.depth * 3 / 2
myctrl.location.z = 0
myctrl.display_type = 'BOUNDS'
myctrl.hide = False
myctrl.hide_viewport = False
myctrl.hide_render = True
if bpy.context.scene.render.engine == 'CYCLES':
if bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
myctrl.cycles_visibility.camera = False
myctrl.cycles_visibility.diffuse = False
myctrl.cycles_visibility.glossy = False
@ -232,7 +232,7 @@ def shape_mesh_and_create_children(mainobject, tmp_mesh, update=False):
# deactivate others
for o in bpy.data.objects:
if o.select is True and o.name != mainobject.name:
if o.select_get() is True and o.name != mainobject.name:
o.select_set(False)
return
@ -422,12 +422,12 @@ Object.WindowObjectGenerator = CollectionProperty(type=ObjectProperties)
# ------------------------------------------------------------------
# Define panel class to modify object
# ------------------------------------------------------------------
class AchmWindowObjectgeneratorpanel(Panel):
class ARCHIMESH_PT_WindowObjectgenerator(Panel):
bl_idname = "OBJECT_PT_window_generator"
bl_label = "Window Rail"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = 'Archimesh'
bl_category = 'View'
# -----------------------------------------------------
# Verify if visible
@ -514,7 +514,7 @@ class AchmWindowObjectgeneratorpanel(Panel):
row.prop(myobjdat, 'blind_back')
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(myobjdat, 'crt_mat')
else:
@ -529,7 +529,7 @@ def generate_rail_window(myframe, mp, mymesh):
myloc = bpy.context.scene.cursor_location
alummat = None
if mp.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
if mp.crt_mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
alummat = create_diffuse_material("Window_material", False, 0.8, 0.8, 0.8, 0.6, 0.6, 0.6, 0.15)
# Frame
@ -620,7 +620,7 @@ def generate_leaf_window(myframe, mp, mymesh):
myloc = bpy.context.scene.cursor_location
alummat = None
if mp.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
if mp.crt_mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
alummat = create_diffuse_material("Window_material", False, 0.8, 0.8, 0.8, 0.6, 0.6, 0.6, 0.15)
# Frame
@ -719,11 +719,11 @@ def generate_leaf_window(myframe, mp, mymesh):
# deactivate others
for o in bpy.data.objects:
if o.select is True:
if o.select_get() is True:
o.select_set(False)
myframe.select_set(True)
bpy.context.scene.objects.active = myframe
bpy.context.view_layer.objects.active = myframe
return myframe
@ -906,7 +906,7 @@ def create_rail_window_frame(mywindow, mymesh, sx, sy, sz, frame, mat, matdata,
mymesh.from_pydata(myvertex, [], myfaces)
mymesh.update(calc_edges=True)
if mat and bpy.context.scene.render.engine == 'CYCLES':
if mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
set_material(mywindow, matdata)
# --------------
# Blind Box
@ -919,7 +919,7 @@ def create_rail_window_frame(mywindow, mymesh, sx, sy, sz, frame, mat, matdata,
mybox.location.x = 0
mybox.location.y = -blind_back - sy
mybox.location.z = sz
if mat and bpy.context.scene.render.engine == 'CYCLES':
if mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
set_material(mybox, matdata)
# Lock
mybox.lock_location = (True, True, True)
@ -1030,7 +1030,7 @@ def create_leaf_window_frame(mywindow, mymesh, sx, sy, sz, frame, frame_l, leafr
mymesh.from_pydata(myvertex, [], myfaces)
mymesh.update(calc_edges=True)
if mat and bpy.context.scene.render.engine == 'CYCLES':
if mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
set_material(mywindow, matdata)
# --------------
@ -1044,7 +1044,7 @@ def create_leaf_window_frame(mywindow, mymesh, sx, sy, sz, frame, frame_l, leafr
mybox.location.x = 0
mybox.location.y = -blind_back - sy
mybox.location.z = sz
if mat and bpy.context.scene.render.engine == 'CYCLES':
if mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
set_material(mybox, matdata)
# Lock
mybox.lock_location = (True, True, True)
@ -1200,7 +1200,7 @@ def create_rail_window_leaf(objname, hand, sx, sy, sz, f, px, py, pz, mat, matda
mywindow.location[0] = px
mywindow.location[1] = py
mywindow.location[2] = pz
bpy.context.scene.objects.link(mywindow)
bpy.context.collection.objects.link(mywindow)
mymesh.from_pydata(myvertex, [], myfaces)
mymesh.update(calc_edges=True)
@ -1226,7 +1226,7 @@ def create_rail_window_leaf(objname, hand, sx, sy, sz, f, px, py, pz, mat, matda
else:
myhandle.location.z = 1
if mat and bpy.context.scene.render.engine == 'CYCLES':
if mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
set_material(mywindow, matdata)
# Glass
glass = create_glass_material("Glass_material", False)
@ -1299,7 +1299,7 @@ def create_leaf_window_leaf(objname, hand, sx, sy, sz, f, px, py, pz, mat, matda
mywindow.location[0] = px
mywindow.location[1] = py
mywindow.location[2] = pz
bpy.context.scene.objects.link(mywindow)
bpy.context.collection.objects.link(mywindow)
mymesh.from_pydata(myvertex, [], myfaces)
mymesh.update(calc_edges=True)
@ -1330,7 +1330,7 @@ def create_leaf_window_leaf(objname, hand, sx, sy, sz, f, px, py, pz, mat, matda
set_smooth(myhandle)
set_modifier_subsurf(myhandle)
if mat and bpy.context.scene.render.engine == 'CYCLES':
if mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
set_material(mywindow, matdata)
# Glass
glass = create_glass_material("Glass_material", False)
@ -1751,13 +1751,13 @@ def create_leaf_handle(objname, mat):
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)
# Create materials
if mat and bpy.context.scene.render.engine == 'CYCLES':
if mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
alumat = create_glossy_material("Handle_material", False, 0.733, 0.779, 0.8)
set_material(myobject, alumat)
@ -2092,13 +2092,13 @@ def create_rail_handle(objname, mat):
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)
# Create materials
if mat and bpy.context.scene.render.engine == 'CYCLES':
if mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
plastic = create_diffuse_material("Plastic_Handle_material", False, 0.01, 0.01, 0.01, 0.082, 0.079, 0.02, 0.01)
set_material(myobject, plastic)
@ -2130,12 +2130,12 @@ def create_sill(objname, x, y, z, mat):
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)
if mat and bpy.context.scene.render.engine == 'CYCLES':
if mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
mymat = create_diffuse_material("Sill_material", False, 0.8, 0.8, 0.8)
set_material(myobject, mymat)
@ -2168,7 +2168,7 @@ def create_blind_box(objname, x, y, z):
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)
@ -2228,12 +2228,12 @@ def create_blind_rail(objname, sx, sz, px, py, pz, mat, matdata, blind_rail):
myblind.location[0] = px
myblind.location[1] = py
myblind.location[2] = pz
bpy.context.scene.objects.link(myblind)
bpy.context.collection.objects.link(myblind)
mymesh.from_pydata(myvertex, [], myfaces)
mymesh.update(calc_edges=True)
if mat and bpy.context.scene.render.engine == 'CYCLES':
if mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
set_material(myblind, matdata)
return myblind
@ -2290,14 +2290,14 @@ def create_blind(objname, sx, sz, px, py, pz, mat, blind_ratio):
myblind.location[0] = px
myblind.location[1] = py
myblind.location[2] = pz
bpy.context.scene.objects.link(myblind)
bpy.context.collection.objects.link(myblind)
mymesh.from_pydata(myvertex, [], myfaces)
mymesh.update(calc_edges=True)
myblind.lock_location = (True, True, False) # only Z axis
if mat and bpy.context.scene.render.engine == 'CYCLES':
if mat and bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
mat = create_diffuse_material("Blind_plastic_material", False, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.15)
set_material(myblind, mat)

View File

@ -196,11 +196,11 @@ def set_defaults(s):
# ------------------------------------------------------------------
# Define operator class to create window panels
# ------------------------------------------------------------------
class AchmWinPanel(Operator):
class ARCHIMESH_PT_Win(Operator):
bl_idname = "mesh.archimesh_winpanel"
bl_label = "Panel Window"
bl_description = "Generate editable flat windows"
bl_category = 'Archimesh'
bl_category = 'View'
bl_options = {'REGISTER', 'UNDO'}
# -----------------------------------------------------
@ -210,7 +210,7 @@ class AchmWinPanel(Operator):
def draw(self, context):
layout = self.layout
row = layout.row()
row.label("Use Properties panel (N) to define parms", icon='INFO')
row.label(text="Use Properties panel (N) to define parms", icon='INFO')
# -----------------------------------------------------
# Execute
@ -237,7 +237,7 @@ def create_window():
window_object = bpy.data.objects.new("Window", window_mesh)
# Link object to scene
bpy.context.scene.objects.link(window_object)
bpy.context.collection.objects.link(window_object)
window_object.WindowPanelGenerator.add()
window_object.location = bpy.context.scene.cursor_location
@ -246,17 +246,17 @@ def create_window():
# deactivate others
for o in bpy.data.objects:
if o.select is True and o.name != window_object.name:
if o.select_get() is True and o.name != window_object.name:
o.select_set(False)
# Select, and activate object
window_object.select_set(True)
bpy.context.scene.objects.active = window_object
bpy.context.view_layer.objects.active = window_object
do_ctrl_box(window_object)
# Reselect
window_object.select_set(True)
bpy.context.scene.objects.active = window_object
bpy.context.view_layer.objects.active = window_object
# ------------------------------------------------------------------------------
@ -291,7 +291,7 @@ def update_window(self, context):
# noinspection PyBroadException
try:
# clear child data
child.hide = False # must be visible to avoid bug
child.hide_viewport = False # must be visible to avoid bug
child.hide_render = False # must be visible to avoid bug
old = child.data
child.select_set(True)
@ -316,17 +316,17 @@ def update_window(self, context):
tmp_mesh.name = oldname
# deactivate others
for ob in bpy.data.objects:
if ob.select is True and ob.name != o.name:
if ob.select_get() is True and ob.name != o.name:
ob.select_set(False)
# and select, and activate, the object.
o.select_set(True)
bpy.context.scene.objects.active = o
bpy.context.view_layer.objects.active = o
do_ctrl_box(o)
# Reselect
o.select_set(True)
bpy.context.scene.objects.active = o
bpy.context.view_layer.objects.active = o
# ------------------------------------------------------------------------------
@ -395,9 +395,9 @@ def do_ctrl_box(myobject):
myctrl.location.y = 0
myctrl.location.z = 0
myctrl.display_type = 'WIRE'
myctrl.hide = False
myctrl.hide_viewport = False
myctrl.hide_render = True
if bpy.context.scene.render.engine == 'CYCLES':
if bpy.context.scene.render.engine in {'CYCLES', 'BLENDER_EEVEE'}:
myctrl.cycles_visibility.camera = False
myctrl.cycles_visibility.diffuse = False
myctrl.cycles_visibility.glossy = False
@ -1541,7 +1541,7 @@ def create_ctrl_box(parentobj, objname):
myobj = bpy.data.objects.new(objname, mymesh)
myobj.location = bpy.context.scene.cursor_location
bpy.context.scene.objects.link(myobj)
bpy.context.collection.objects.link(myobj)
mymesh.from_pydata(myvertex, [], myfaces)
mymesh.update(calc_edges=True)
@ -1568,7 +1568,21 @@ class GeneralPanelProperties(PropertyGroup):
description='Predefined types',
update=update_using_default,
)
son = prs
son: EnumProperty(
items=(
('1', "WINDOW 250X200", ""),
('2', "WINDOW 200X200", ""),
('3', "WINDOW 180X200", ""),
('4', "WINDOW 180X160", ""),
('5', "WINDOW 160X160", ""),
('6', "WINDOW 50X50", ""),
('7', "DOOR 80X250", ""),
('8', "DOOR 80X230", ""),
),
name="",
description='Predefined types',
update=update_using_default,
)
gen: IntProperty(
name='H Count', min=1, max=8, default=3,
description='Horizontal Panes',
@ -1771,12 +1785,12 @@ Object.WindowPanelGenerator = CollectionProperty(type=GeneralPanelProperties)
# ------------------------------------------------------------------
# Define panel class to modify myobjects.
# ------------------------------------------------------------------
class AchmWindowEditPanel(Panel):
class ARCHIMESH_PT_WindowEdit(Panel):
bl_idname = "ARCHIMESH_PT_window_edit"
bl_label = "Window Panel"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = 'Window'
bl_category = 'View'
# -----------------------------------------------------
# Verify if visible