__init__.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:CutAwayShader 作者: i-Reboot 项目源码 文件源码
def select_all_objects_using_this_unique_pynode_id(self, unique_pynode_id_str, jump_node_editor_to_active_material_bool):
        # Get a list of the objects in the scene that use this pynode.
        obj_list, matslot_list = self.get_all_objs_using_pynode(unique_pynode_id_str)

        # No objects with using a material with the pynode of the given unique id was found.
        # exit with a False (This is probably an orphaned child node)
        if (len(obj_list) == 0):
            return False

        if (jump_node_editor_to_active_material_bool):
            bpy.context.space_data.pin = False

        # we need to be in object mode to do this work
        # save the area type -- should be node editor since a pynode button was pressed.
        # the cursor bpy ops only work from the 3d view context. So, switch to this.
        bpy.ops.object.mode_set(mode='OBJECT')
        original_areatype = bpy.context.area.type
        bpy.context.area.type = "VIEW_3D"


        if (jump_node_editor_to_active_material_bool):
            saved_3d_layers_setting_list = self.save_3d_view_layer_settings(bpy.context.space_data.layers)
            bpy.context.space_data.layers = [True] * 20

        #bpy.ops.object.select_all(action='DESELECT')  

        # Select all objects in the scene that use this pynode.
        # Enable layers the object is on if they are disabled
        for obj in obj_list:
            for i in range (len(bpy.context.scene.layers)):
                if obj.layers[i] == True:
                    bpy.context.scene.layers[i] = True
                    break
            obj.select = True
            # make the node editor jump to the objects active material. (Used for child node button "Jump to Parent Node"
            if(jump_node_editor_to_active_material_bool):
                bpy.context.scene.objects.active = obj
                self.restore_3d_view_layer_settings(bpy.context.space_data.layers, saved_3d_layers_setting_list)

        # switch back to the users original context
        bpy.context.area.type = original_areatype

        # We found object(s) using a material with the pynode of the given unique id - so return true
        return True


    # The user has clicked the "Jump to Parent Node" button on a child pynode.
    # Change the node view to show the parent pynode
    # If this is called we are a child node
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号