def hide_unhide(self, context, type_op): n = context.node k = n.basemesh_name + "_" # maybe do hash+(obj_name + treename) child = lambda obj: obj.type == "MESH" and obj.name.startswith(k) objs = list(filter(child, bpy.data.objects)) if type_op == 'hide_view': for obj in objs: obj.hide = n.state_view n.state_view = not n.state_view elif type_op == 'hide_render': for obj in objs: obj.hide_render = n.state_render n.state_render = not n.state_render elif type_op == 'hide_select': for obj in objs: obj.hide_select = n.state_select n.state_select = not n.state_select elif type_op == 'mesh_select': for obj in objs: obj.select = n.select_state_mesh n.select_state_mesh = not n.select_state_mesh elif type_op == 'random_mesh_name': n.basemesh_name = get_random_init()
def hide_unhide(self, context, type_op): n = context.node k = n.basemesh_name + "_" child = lambda obj: obj.type == "MESH" and obj.name.startswith(k) objs = list(filter(child, bpy.data.objects)) if type_op in {'hide', 'hide_render', 'hide_select'}: op_value = getattr(n, type_op) for obj in objs: setattr(obj, type_op, op_value) setattr(n, type_op, not op_value) elif type_op == 'mesh_select': for obj in objs: obj.select = n.select_state_mesh n.select_state_mesh = not n.select_state_mesh elif type_op == 'random_mesh_name': n.basemesh_name = get_random_init() elif type_op == 'add_material': mat = bpy.data.materials.new('sv_material') mat.use_nodes = True mat.use_fake_user = True # usually handy n.material = mat.name
def hide_unhide(self, context, type_op): n = context.node k = n.basemesh_name + "_" child = lambda obj: obj.type == "FONT" and obj.name.startswith(k) objs = list(filter(child, bpy.data.objects)) if type_op in {'hide', 'hide_render', 'hide_select'}: op_value = getattr(n, type_op) for obj in objs: setattr(obj, type_op, op_value) setattr(n, type_op, not op_value) elif type_op == 'typography_select': for obj in objs: obj.select = n.select_state_mesh n.select_state_mesh = not n.select_state_mesh elif type_op == 'random_mesh_name': n.basemesh_name = get_random_init() elif type_op == 'add_material': mat = bpy.data.materials.new('sv_material') mat.use_nodes = True mat.use_fake_user = True # usually handy n.material = mat.name
def dispatch(self, context, type_op): n = context.node objs = get_children(n, kind='CURVE') # find a simpler way to do this :) if type_op in {'hide', 'hide_render', 'hide_select', 'select'}: for obj in objs: setattr(obj, type_op, getattr(n, type_op)) setattr(n, type_op, not getattr(n, type_op)) elif type_op == 'random_mesh_name': n.basemesh_name = get_random_init() elif type_op == 'add_material': mat = bpy.data.materials.new('sv_material') mat.use_nodes = True n.material = mat.name print(mat.name)
def dispatch(self, context, type_op): n = context.node k = n.basemesh_name + "_" # maybe do hash+(obj_name + treename) child = lambda obj: obj.type == "CURVE" and obj.name.startswith(k) objs = list(filter(child, bpy.data.objects)) # find a simpler way to do this :) if type_op in {'hide', 'hide_render', 'hide_select', 'select'}: for obj in objs: setattr(obj, type_op, getattr(n, type_op)) setattr(n, type_op, not getattr(n, type_op)) elif type_op == 'random_mesh_name': n.basemesh_name = get_random_init() elif type_op == 'add_material': mat = bpy.data.materials.new('sv_material') mat.use_nodes = True n.material = mat.name print(mat.name)
def hide_unhide(self, context, type_op): n = context.node k = n.basemesh_name + "_" child = lambda obj: obj.type == "MESH" and obj.name.startswith(k) objs = list(filter(child, bpy.data.objects)) if type_op in {'hide', 'hide_render', 'hide_select'}: op_value = getattr(n, type_op) for obj in objs: setattr(obj, type_op, op_value) setattr(n, type_op, not op_value) elif type_op == 'mesh_select': for obj in objs: obj.select = n.select_state_mesh n.select_state_mesh = not n.select_state_mesh elif type_op == 'random_mesh_name': n.basemesh_name = get_random_init() elif type_op == 'add_material': mat = bpy.data.materials.new('sv_material') mat.use_nodes = True mat.use_fake_user = True # usually handy nodes = mat.node_tree.nodes n.material = mat.name if bpy.context.scene.render.engine == 'CYCLES': # add attr node to the left of diffuse BSDF + connect it diffuse_node = nodes['Diffuse BSDF'] attr_node = nodes.new('ShaderNodeAttribute') attr_node.location = (-170, 300) attr_node.attribute_name = 'SvCol' links = mat.node_tree.links links.new(attr_node.outputs[0], diffuse_node.inputs[0])
def dispatch(self, context, type_op): n = context.node k = n.basemesh_name + "_" # maybe do hash+(obj_name + treename) child = lambda obj: obj.type == "CURVE" and obj.name.startswith(k) objs = list(filter(child, bpy.data.objects)) if type_op == 'hide_view': for obj in objs: obj.hide = n.state_view n.state_view = not n.state_view elif type_op == 'hide_render': for obj in objs: obj.hide_render = n.state_render n.state_render = not n.state_render elif type_op == 'hide_select': for obj in objs: obj.hide_select = n.state_select n.state_select = not n.state_select elif type_op == 'mesh_select': for obj in objs: obj.select = n.select_state_mesh n.select_state_mesh = not n.select_state_mesh elif type_op == 'random_mesh_name': n.basemesh_name = get_random_init() elif type_op == 'add_material': mat = bpy.data.materials.new('sv_material') mat.use_nodes = True n.material = mat.name print(mat.name)
def copy(new_node, node): new_node.basemesh_name = get_random_init()
def copy(self, other): self.basemesh_name = get_random_init()