Select backface(Max/Maya style)

Modify addon borderocclusion. Thank Darcvizer.

it allows you to select elements without transparency

BorderOcclusion.zip (2.4 KB)

7 Likes

Hi.

Thank you very much for your script.

I noticed that your .py file doesn’t contain the usual GPL license paragraph.
As you may already know, Blender addons must be released under a GPL compatible license.

From https://www.blender.org/about/license/ :

Sharing or selling Blender add-ons (Python scripts)

Blender’s Python API is an integral part of Blender, used to define the UI or develop tools for example. The GNU GPL license therefore requires that such scripts (if published) are being shared under a GPL GPL compatible license. You are free to sell such scripts, but the sales then is restricted to the download service itself. Your customers will receive the script under the same license, with the same free conditions as everyone has for Blender. Sharing Blender or its scripts is always OK and not piracy.

Here is an example of GPL license paragraph that you could add at the top of your .py files:

# ----- BEGIN GPL LICENSE BLOCK -----
#
#  This program is free software; you can redistribute it and/or
#  modify it under the terms of the GNU General Public License
#  as published by the Free Software Foundation; either version 2
#  of the License, or (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software Foundation,
#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ----- END GPL LICENSE BLOCK -----

Thanks !

I don’t know anything about the license. For me, the main thing is that the script works in versions 2.80, 2.81

I don’t know anything about the license. For me, the main thing is that the script works in versions 2.80, 2.81

Just add the ----- BEGIN GPL LICENSE BLOCK ----- paragraph at the top of your .py files.
:slight_smile:

Hi, I get this error switching to the last mode

Traceback (most recent call last):
File “C:\Users\xdani\AppData\Roaming\Blender Foundation\Blender\2.83\scripts\addons\BorderOcclusion.py”, line 29, in execute
bpy.ops.preferences.addon_enable(module=“BorderOcclusionLasso”)
File “D:\Descargas\d60a646887b24f2a854df655344b2d73\blender-2.83.0-git20200118.20128d9acd02-windows64\2.83\scripts\modules\bpy\ops.py”, line 201, in call
ret = op_call(self.idname_py(), None, kw)
RuntimeError: Error: Traceback (most recent call last):
File “D:\Descargas\d60a646887b24f2a854df655344b2d73\blender-2.83.0-git20200118.20128d9acd02-windows64\2.83\scripts\modules\addon_utils.py”, line 351, in enable
mod = import(module_name)
File “C:\Users\xdani\AppData\Roaming\Blender Foundation\Blender\2.83\scripts\addons\BorderOcclusionLasso.py”, line 20
bpy.data.screens[“Layout”].shading.xray_alpha = 1
^
TabError: inconsistent use of tabs and spaces in indentation

location: :-1

Better turn to this person(https://blenderartists.org/u/darcvizer/summary). He is the author of the original version.

“TabError: inconsistent use of tabs and spaces in indentation.” literally means what it says. The script file either needs to use 4 spaces or 1 tab to do line indents. You cannot mix both in the same file.

In BorderOcclusionLasso.py line 20 and 21 are using spaces to indent when the rest of the file is using tabs. Change that and it should work.

Edit: (Note: Those two lines are double indented so you need to replace 8 spaces with 2 tabs.)

Edit2: Actually there’s some other weirdness in that file with those two lines being inconsistent with the Box file and also maybe it would be wise to reset the x-ray opacity back to 0.5 to clean up after ourselves, and set show_faces back to true.

# ----- BEGIN GPL LICENSE BLOCK -----
#
#  This program is free software; you can redistribute it and/or
#  modify it under the terms of the GNU General Public License
#  as published by the Free Software Foundation; either version 2
#  of the License, or (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software Foundation,
#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ----- END GPL LICENSE BLOCK -----

import bpy
from bpy.types import Operator, Macro
bl_info = {
"name": "BorderOcclusionLasso",
"location": "View3D > Add > Mesh > Border Occlusion",
"description": "Drag mause for seletion back and front faces by dorder",
"author": "Vladislav Kindushov",
"version": (0,4),
"blender": (2, 80, 0),
"category": "Mesh",
}

class BorderOn(bpy.types.Operator):
    """Border Occlusion selection """
    bl_idname = "view3d.border_on"
    bl_label = "BorderOn"

    def execute(self, context):
        context.space_data.shading.show_xray = True
        context.space_data.shading.xray_alpha = 1
        context.space_data.overlay.show_faces = False
        print("sosok")
        return {'FINISHED'}

class BorderOff(bpy.types.Operator):
    """Border Occlusion selection """
    bl_idname = "view3d.border_off"
    bl_label = "BorderOff"

    def execute(self, context):
        context.space_data.shading.show_xray = False
        context.space_data.shading.xray_alpha = 0.5
        context.space_data.overlay.show_faces = True
        return {'FINISHED'}


class OcclusionMacro(Macro):
    bl_idname = 'view3d.occlusion_macro'
    bl_label = 'Occlusion Macro'
    bl_options = {'REGISTER', 'UNDO'}




classes = (BorderOn, BorderOff, OcclusionMacro)



def register():
    global Mode
    for c in classes:
        bpy.utils.register_class(c)
    OcclusionMacro.define("VIEW3D_OT_border_on")

    OcclusionMacro.define("VIEW3D_OT_select_lasso")

    OcclusionMacro.define('VIEW3D_OT_border_off')


def unregister():
    for c in reversed(classes):
        bpy.utils.unregister_class(c)


if __name__ == "__main__":
    register()

I’d add context.space_data.shading.xray_alpha = 0.5 into the BorderOcclusionBox.py file too in the BorderOff section (between line 32 and 33 to become the new line 33).

You can become a co-author.

Hi.

With Blender version: 2.82a and the Addon version: 0.3, when I try to activate the Border Occlusion Lasso addon, I get this error:

Traceback (most recent call last):
  File "E:\blender\blender-2.82a-portable\2.82\scripts\modules\addon_utils.py", line 351, in enable
    mod = __import__(module_name)
  File "E:\blender\blender-2.82a-portable\2.82\scripts\addons\BorderOcclusionLasso.py", line 20
    bpy.data.screens["Layout"].shading.xray_alpha = 1
                                                    ^
TabError: inconsistent use of tabs and spaces in indentation

Just like bloox64, when I click on this icon, I get this error:

Annotation 2020-03-22 125536

Traceback (most recent call last):
  File "E:\blender\blender-2.82a-portable\2.82\scripts\addons\BorderOcclusion.py", line 29, in execute
    bpy.ops.preferences.addon_enable(module="BorderOcclusionLasso")
  File "E:\blender\blender-2.82a-portable\2.82\scripts\modules\bpy\ops.py", line 201, in __call__
    ret = op_call(self.idname_py(), None, kw)
RuntimeError: Error: Traceback (most recent call last):
  File "E:\blender\blender-2.82a-portable\2.82\scripts\modules\addon_utils.py", line 351, in enable
    mod = __import__(module_name)
  File "E:\blender\blender-2.82a-portable\2.82\scripts\addons\BorderOcclusionLasso.py", line 20
    bpy.data.screens["Layout"].shading.xray_alpha = 1
                                                    ^
TabError: inconsistent use of tabs and spaces in indentation

location: <unknown location>:-1