Archimesh: Fix error when Cycles is not enabled

Now if cycles render is not enabled or not selected, the materials are
not created.
This commit is contained in:
Antonio Vazquez 2016-08-09 18:01:14 +02:00
parent ce2ced1598
commit f3a93f08e8
14 changed files with 89 additions and 104 deletions

View File

@ -137,6 +137,8 @@ class AchmBooks(Operator):
row.prop(self, 'afn', slider=True)
box = layout.box()
if not context.scene.render.engine == 'CYCLES':
box.enabled = False
box.prop(self, 'crt_mat')
if self.crt_mat:
row = box.row()
@ -201,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,
self.crt_mat if bpy.context.scene.render.engine == 'CYCLES' else False,
self.rX, self.rY, self.rZ, self.rot, ox, oy, oz, ot,
self.objcol, self.rC)
boxes.extend([mydata[0]])

View File

@ -322,6 +322,8 @@ class AchmColumn(bpy.types.Operator):
row.prop(self, 'ramp')
box = layout.box()
if not context.scene.render.engine == 'CYCLES':
box.enabled = False
box.prop(self, 'crt_mat')
else:
row = layout.row()
@ -528,7 +530,7 @@ def create_column_mesh(self):
# ------------------------
# Create materials
# ------------------------
if self.crt_mat:
if self.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
# 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)

View File

@ -134,6 +134,8 @@ class AchmJapan(Operator):
row.prop(self, 'open05', slider=True)
box = layout.box()
if not context.scene.render.engine == 'CYCLES':
box.enabled = False
box.prop(self, 'crt_mat')
if self.crt_mat:
box.label("* Remember to verify fabric texture folder")
@ -218,6 +220,8 @@ class AchmRoller(Operator):
row.prop(self, 'height')
box = layout.box()
if not context.scene.render.engine == 'CYCLES':
box.enabled = False
box.prop(self, 'crt_mat')
if self.crt_mat:
box.label("* Remember to verify fabric texture folder")
@ -352,7 +356,7 @@ def generate_japan(self):
posz = -0.008
x = 1
fabricmat = None
if self.crt_mat:
if self.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
fabricmat = create_fabric_material("Fabric_material", False, 0.653, 0.485, 0.265,
0.653, 0.485, 0.265)
@ -392,7 +396,7 @@ def generate_japan(self):
mycurve2.location.y = -0.01
mycurve2.location.z = 0.005
if self.crt_mat:
if self.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
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)
@ -627,7 +631,7 @@ def generate_roller(self):
# Roller Top
# ------------------
fabricsolid = None
if self.crt_mat:
if self.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
fabricsolid = create_diffuse_material("Fabric_solid_material", False, 0.653, 0.485, 0.265)
myroller = create_roller_rail("Roller",
@ -643,7 +647,7 @@ def generate_roller(self):
# Sides
# --------------------------------------------------------------------------------
plastic = None
if self.crt_mat:
if self.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
plastic = create_diffuse_material("Plastic_roller_material", False, 0.653, 0.485, 0.265, 0.653, 0.485, 0.265,
0.2)
@ -665,7 +669,7 @@ def generate_roller(self):
# Panel
# --------------------------------------------------------------------------------
fabricmat = None
if self.crt_mat:
if self.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
fabricmat = create_fabric_material("Fabric_translucent_material", False, 0.653, 0.485, 0.265, 0.653, 0.485,
0.265)
@ -703,7 +707,7 @@ def generate_roller(self):
mycurve.location.x = self.width + 0.015
mycurve.location.y = 0
mycurve.location.z = -0.38
if self.crt_mat:
if self.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
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)

View File

@ -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:
if mp.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
mat = create_diffuse_material("Door_material", False, 0.8, 0.8, 0.8)
set_material(mainobject, mat)
@ -236,12 +236,13 @@ def shape_children(mainobject, update=False):
myctrl.draw_type = 'BOUNDS'
myctrl.hide = False
myctrl.hide_render = True
myctrl.cycles_visibility.camera = False
myctrl.cycles_visibility.diffuse = False
myctrl.cycles_visibility.glossy = False
myctrl.cycles_visibility.transmission = False
myctrl.cycles_visibility.scatter = False
myctrl.cycles_visibility.shadow = False
if bpy.context.scene.render.engine == 'CYCLES':
myctrl.cycles_visibility.camera = False
myctrl.cycles_visibility.diffuse = False
myctrl.cycles_visibility.glossy = False
myctrl.cycles_visibility.transmission = False
myctrl.cycles_visibility.scatter = False
myctrl.cycles_visibility.shadow = False
# Create control box for baseboard
myctrlbase = create_control_box("CTRL_Baseboard",
@ -258,16 +259,17 @@ def shape_children(mainobject, update=False):
myctrlbase.draw_type = 'BOUNDS'
myctrlbase.hide = False
myctrlbase.hide_render = True
myctrlbase.cycles_visibility.camera = False
myctrlbase.cycles_visibility.diffuse = False
myctrlbase.cycles_visibility.glossy = False
myctrlbase.cycles_visibility.transmission = False
myctrlbase.cycles_visibility.scatter = False
myctrlbase.cycles_visibility.shadow = False
if bpy.context.scene.render.engine == 'CYCLES':
myctrlbase.cycles_visibility.camera = False
myctrlbase.cycles_visibility.diffuse = False
myctrlbase.cycles_visibility.glossy = False
myctrlbase.cycles_visibility.transmission = False
myctrlbase.cycles_visibility.scatter = False
myctrlbase.cycles_visibility.shadow = False
mat = create_transparent_material("hidden_material", False)
set_material(myctrl, mat)
set_material(myctrlbase, mat)
mat = create_transparent_material("hidden_material", False)
set_material(myctrl, mat)
set_material(myctrlbase, mat)
# deactivate others
for o in bpy.data.objects:
@ -457,6 +459,8 @@ class AchmDoorObjectgeneratorpanel(Panel):
layout.prop(myobjdat, 'handle')
box = layout.box()
if not context.scene.render.engine == 'CYCLES':
box.enabled = False
box.prop(myobjdat, 'crt_mat')
else:
row = layout.row()
@ -539,7 +543,7 @@ def make_one_door(self, myframe, width, openside):
set_smooth(handle2)
set_modifier_subsurf(handle2)
# Create materials
if self.crt_mat:
if self.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
# Door material
mat = create_diffuse_material("Door_material", False, 0.8, 0.8, 0.8)
set_material(mydoor, mat)

View File

@ -522,6 +522,8 @@ class AchmKitchen(Operator):
add_cabinet(self, box, idx + 1, self.cabinets[idx])
box = layout.box()
if not context.scene.render.engine == 'CYCLES':
box.enabled = False
box.prop(self, 'crt_mat')
else:
row = layout.row()
@ -831,7 +833,7 @@ def generate_cabinets(self):
set_normals(base)
# Create materials
if self.crt_mat:
if self.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
mat = create_diffuse_material("Cabinet_material", False, 0.8, 0.8, 0.8)
for box in boxes:
set_material(box, mat)

View File

@ -354,6 +354,8 @@ class AchmLamp(Operator):
row.prop(self, 'tr03')
box = layout.box()
if not context.scene.render.engine == 'CYCLES':
box.enabled = False
box.prop(self, 'crt_mat')
if self.crt_mat:
row = box.row()
@ -484,7 +486,7 @@ def generate_lamp(self):
mybulb.name = "Lamp_Bulb"
mybulb.parent = myholder
mybulb.location = (0, 0, radbulb + self.holder + 0.04)
if self.crt_mat:
if self.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
mat = create_emission_material(mybulb.name, True, 0.8, 0.8, 0.8, self.energy)
set_material(mybulb, mat)

View File

@ -131,6 +131,8 @@ class AchmRoof(Operator):
box.prop(self, 'roof_angle')
box = layout.box()
if not context.scene.render.engine == 'CYCLES':
box.enabled = False
box.prop(self, 'crt_mat')
else:
row = layout.row()
@ -203,7 +205,7 @@ def create_roof_mesh(self):
myroof.rotation_euler = (radians(self.roof_angle), 0.0, 0.0)
# Create materials
if self.crt_mat:
if self.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
# 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)

View File

@ -542,7 +542,7 @@ def shape_walls_and_create_children(myroom, tmp_mesh, update=False):
movetotopsolidify(mybase)
# Create materials
if rp.crt_mat:
if rp.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
# 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)
@ -1698,4 +1698,6 @@ class AchmRoomGeneratorPanel(Panel):
row.prop(room, 'shell_bfactor', slider=True)
box = layout.box()
if not context.scene.render.engine == 'CYCLES':
box.enabled = False
box.prop(room, 'crt_mat')

View File

@ -174,6 +174,8 @@ class AchmShelves(Operator):
add_shelves(self, box, idx + 1, self.shelves[idx])
box = layout.box()
if not context.scene.render.engine == 'CYCLES':
box.enabled = False
box.prop(self, 'crt_mat')
else:
row = layout.row()
@ -316,7 +318,7 @@ def generate_shelves(self):
bpy.context.scene.objects.active = boxes[0]
# Create materials
if self.crt_mat:
if self.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
mat = create_diffuse_material("Shelves_material", False, 0.8, 0.8, 0.8)
for box in boxes:
set_material(box, mat)

View File

@ -178,6 +178,8 @@ class AchmStairs(Operator):
row.prop(self, 'side_gap')
box = layout.box()
if not context.scene.render.engine == 'CYCLES':
box.enabled = False
box.prop(self, 'crt_mat')
else:
row = layout.row()
@ -238,7 +240,7 @@ def create_stairs_mesh(self):
# ------------------------
# Create materials
# ------------------------
if self.crt_mat:
if self.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
# Stairs material
mat = create_diffuse_material("Stairs_material", False, 0.8, 0.8, 0.8)
set_material(mystairs, mat)

View File

@ -327,11 +327,6 @@ def create_diffuse_material(matname, replace, r, g, b, rv=0.8, gv=0.8, bv=0.8, m
if m.name == matname:
return m
# Create material
scn = bpy.context.scene
# Set cycles render engine if not selected
if not scn.render.engine == 'CYCLES':
scn.render.engine = 'CYCLES'
mat = bpy.data.materials.new(matname)
mat.diffuse_color = (rv, gv, bv) # viewport color
mat.use_nodes = True
@ -416,11 +411,6 @@ def create_translucent_material(matname, replace, r, g, b, rv=0.8, gv=0.8, bv=0.
if m.name == matname:
return m
# Create material
scn = bpy.context.scene
# Set cycles render engine if not selected
if not scn.render.engine == 'CYCLES':
scn.render.engine = 'CYCLES'
mat = bpy.data.materials.new(matname)
mat.diffuse_color = (rv, gv, bv) # viewport color
mat.use_nodes = True
@ -473,11 +463,6 @@ def create_glass_material(matname, replace, rv=0.333, gv=0.342, bv=0.9):
if m.name == matname:
return m
# Create material
scn = bpy.context.scene
# Set cycles render engine if not selected
if not scn.render.engine == 'CYCLES':
scn.render.engine = 'CYCLES'
mat = bpy.data.materials.new(matname)
mat.use_nodes = True
mat.diffuse_color = (rv, gv, bv)
@ -557,11 +542,6 @@ def create_transparent_material(matname, replace, r=1, g=1, b=1, alpha=0):
if m.name == matname:
return m
# Create material
scn = bpy.context.scene
# Set cycles render engine if not selected
if not scn.render.engine == 'CYCLES':
scn.render.engine = 'CYCLES'
mat = bpy.data.materials.new(matname)
mat.use_nodes = True
mat.diffuse_color = (r, g, b)
@ -598,11 +578,6 @@ def create_glossy_material(matname, replace, r, g, b, rv=0.578, gv=0.555, bv=0.7
if m.name == matname:
return m
# Create material
scn = bpy.context.scene
# Set cycles render engine if not selected
if not scn.render.engine == 'CYCLES':
scn.render.engine = 'CYCLES'
mat = bpy.data.materials.new(matname)
mat.use_nodes = True
mat.diffuse_color = (rv, gv, bv)
@ -640,11 +615,6 @@ def create_emission_material(matname, replace, r, g, b, energy):
if m.name == matname:
return m
# Create material
scn = bpy.context.scene
# Set cycles render engine if not selected
if not scn.render.engine == 'CYCLES':
scn.render.engine = 'CYCLES'
mat = bpy.data.materials.new(matname)
mat.use_nodes = True
nodes = mat.node_tree.nodes
@ -681,11 +651,6 @@ def create_old_glass_material(matname, replace, rv=0.352716, gv=0.760852, bv=0.9
if m.name == matname:
return m
# Create material
scn = bpy.context.scene
# Set cycles render engine if not selected
if not scn.render.engine == 'CYCLES':
scn.render.engine = 'CYCLES'
mat = bpy.data.materials.new(matname)
mat.use_nodes = True
mat.diffuse_color = (rv, gv, bv)
@ -759,11 +724,6 @@ def create_brick_material(matname, replace, r, g, b, rv=0.8, gv=0.636, bv=0.315)
if m.name == matname:
return m
# Create material
scn = bpy.context.scene
# Set cycles render engine if not selected
if not scn.render.engine == 'CYCLES':
scn.render.engine = 'CYCLES'
mat = bpy.data.materials.new(matname)
mat.use_nodes = True
mat.diffuse_color = (rv, gv, bv)
@ -820,11 +780,6 @@ def create_fabric_material(matname, replace, r, g, b, rv=0.8, gv=0.636, bv=0.315
if m.name == matname:
return m
# Create material
scn = bpy.context.scene
# Set cycles render engine if not selected
if not scn.render.engine == 'CYCLES':
scn.render.engine = 'CYCLES'
mat = bpy.data.materials.new(matname)
mat.use_nodes = True
mat.diffuse_color = (rv, gv, bv)

View File

@ -138,7 +138,7 @@ def shape_mesh_and_create_children(mainobject, tmp_mesh, update=False):
mat = None
plastic = None
if mp.crt_mat:
if mp.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
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:
if mp.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
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:
if mp.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
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:
if mp.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
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:
if mp.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
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:
if mp.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
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:
if mp.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
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:
if mp.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
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,7 +314,7 @@ 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:
if mp.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
set_material(mystring, mat)
# deactivate others
for o in bpy.data.objects:
@ -430,6 +430,8 @@ class AchmVenetianObjectgeneratorpanel(Panel):
row.prop(myobjdat, 'ratio', slider=True)
box = layout.box()
if not context.scene.render.engine == 'CYCLES':
box.enabled = False
box.prop(myobjdat, 'crt_mat')
if myobjdat.crt_mat:
row = box.row()

View File

@ -219,15 +219,16 @@ def shape_mesh_and_create_children(mainobject, tmp_mesh, update=False):
myctrl.draw_type = 'BOUNDS'
myctrl.hide = False
myctrl.hide_render = True
myctrl.cycles_visibility.camera = False
myctrl.cycles_visibility.diffuse = False
myctrl.cycles_visibility.glossy = False
myctrl.cycles_visibility.transmission = False
myctrl.cycles_visibility.scatter = False
myctrl.cycles_visibility.shadow = False
if bpy.context.scene.render.engine == 'CYCLES':
myctrl.cycles_visibility.camera = False
myctrl.cycles_visibility.diffuse = False
myctrl.cycles_visibility.glossy = False
myctrl.cycles_visibility.transmission = False
myctrl.cycles_visibility.scatter = False
myctrl.cycles_visibility.shadow = False
mat = create_transparent_material("hidden_material", False)
set_material(myctrl, mat)
mat = create_transparent_material("hidden_material", False)
set_material(myctrl, mat)
# deactivate others
for o in bpy.data.objects:
@ -513,6 +514,8 @@ class AchmWindowObjectgeneratorpanel(Panel):
row.prop(myobjdat, 'blind_back')
box = layout.box()
if not context.scene.render.engine == 'CYCLES':
box.enabled = False
box.prop(myobjdat, 'crt_mat')
else:
row = layout.row()
@ -526,7 +529,7 @@ def generate_rail_window(myframe, mp, mymesh):
myloc = bpy.context.scene.cursor_location
alummat = None
if mp.crt_mat:
if mp.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
alummat = create_diffuse_material("Window_material", False, 0.8, 0.8, 0.8, 0.6, 0.6, 0.6, 0.15)
# Frame
@ -617,7 +620,7 @@ def generate_leaf_window(myframe, mp, mymesh):
myloc = bpy.context.scene.cursor_location
alummat = None
if mp.crt_mat:
if mp.crt_mat and bpy.context.scene.render.engine == 'CYCLES':
alummat = create_diffuse_material("Window_material", False, 0.8, 0.8, 0.8, 0.6, 0.6, 0.6, 0.15)
# Frame
@ -1223,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 is True:
if mat is True and bpy.context.scene.render.engine == 'CYCLES':
set_material(mywindow, matdata)
# Glass
glass = create_glass_material("Glass_material", False)

View File

@ -397,15 +397,16 @@ def do_ctrl_box(myobject):
myctrl.draw_type = 'WIRE'
myctrl.hide = False
myctrl.hide_render = True
myctrl.cycles_visibility.camera = False
myctrl.cycles_visibility.diffuse = False
myctrl.cycles_visibility.glossy = False
myctrl.cycles_visibility.transmission = False
myctrl.cycles_visibility.scatter = False
myctrl.cycles_visibility.shadow = False
if bpy.context.scene.render.engine == 'CYCLES':
myctrl.cycles_visibility.camera = False
myctrl.cycles_visibility.diffuse = False
myctrl.cycles_visibility.glossy = False
myctrl.cycles_visibility.transmission = False
myctrl.cycles_visibility.scatter = False
myctrl.cycles_visibility.shadow = False
mat = create_transparent_material("hidden_material", False)
set_material(myctrl, mat)
mat = create_transparent_material("hidden_material", False)
set_material(myctrl, mat)
# ------------------------------------------------------------------------------