0
$\begingroup$

To preface, I am still new to Blender, and not knowledgeable with scripting; so, if you offer a script to use, please tell me which method to use to run it (saving as a .py file, or running it as a script within Blender, etc).

I use Blender only to create mods for American Truck Simulator/Euro Truck Simulator 2, and I hate having to select each material individually and uncheck the "Backface Culling" box every time I start up Blender or open a project file. I prefer to not see through solid objects in my workflow (unless it's a transparent object like glass).

I've searched on how to do this and found nothing relatable or pertinent. There was one post where someone offered a script to run, which I've tried, but that did nothing.

I was running version 2.8 last month and found that it would remember keeping "Backface Culling" disabled every time I created a new mesh, start up Blender, or even load a file, unless there was an option I selected but can't remember now.

Surely, there must be an option buried somewhere (or vaguely listed) to allow this.

$\endgroup$
3
  • $\begingroup$ Are you speaking about material setting or solid viewport setting? Both disabled by default. You have posted a lot of text, but I still not sure. Maybe some screenshots would be helpful. $\endgroup$
    – Crantisz
    Commented Oct 25, 2022 at 20:34
  • $\begingroup$ Looks like you import files and the importer sets this by default. That format it is? $\endgroup$
    – Crantisz
    Commented Oct 25, 2022 at 20:39
  • $\begingroup$ @Crantisz Solid Viewport Shading will show all objects as solid regardless of culling. I did mention in my second part that it was the material. I don't know what you mean by "disabled by default" as it is not. And, I don't import, I can create a brand new mesh and the Backface Culling option will still be automatically checked. I didn't have that issue with v2.8. imgur.com/HzG48rU $\endgroup$
    – ChiliBeef
    Commented Oct 26, 2022 at 12:45

1 Answer 1

0
$\begingroup$

Change show_transparent_back to use_backface_culling:

import bpy

for eachMat in bpy.data.materials:
    
    eachMat.use_backface_culling = False

You can also use operator template

bl_info = {
    "name": "Set Backface culling",
    "author": "Your Name Here",
    "version": (1, 0),
    "blender": (2, 80, 0),
    "location": "F3",
    "description": "Set Backface culling to false in all materials",
    "warning": "",
    "doc_url": "",
    "category": "Object",
}



import bpy


def main(context):
    for eachMat in bpy.data.materials:
        eachMat.use_backface_culling = False


class SimpleOperator(bpy.types.Operator):
    """Set Backface culling to false in all materials"""
    bl_idname = "object.set_backface"
    bl_label = "Set Backface culling to false in all materials"

    @classmethod
    def poll(cls, context):
        return context.active_object is not None

    def execute(self, context):
        main(context)
        return {'FINISHED'}


def register():
    bpy.utils.register_class(SimpleOperator)


def unregister():
    bpy.utils.unregister_class(SimpleOperator)



if __name__ == "__main__":
    register()

Then install this file as an addon add it to quick favorites using F3:

enter image description here

And you will have it in one click in Q menu:

enter image description here

$\endgroup$
3
  • $\begingroup$ That first code, where am I supposed to put that? Do I make that as a .py file in the Addons folder? Or, do I run it in the Scripting tab of Blender? $\endgroup$
    – ChiliBeef
    Commented Oct 26, 2022 at 12:51
  • $\begingroup$ I tried that second code, but it doesn't show up in the search field when hitting F3. Also, it doesn't show up in my Add-ons search. It said it was successfully installed but I cannot find it anywhere. $\endgroup$
    – ChiliBeef
    Commented Oct 26, 2022 at 13:00
  • $\begingroup$ Okay, I didn't realize that there was extra code at the beginning of the second script you provided. Scrolling with the mouse wheel made it disappear. However, while that did show up in the Add-ons selection, and I was able to enable it, it does not show up in the search when hitting F3. $\endgroup$
    – ChiliBeef
    Commented Oct 26, 2022 at 13:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .