0

I am trying get the state of the checkbox in my animation subpanel and would like to set myBool to it's state.

Here is my code:

import bpy
import os
from bpy_extras.io_utils import ExportHelper
from bpy.props import (StringProperty, CollectionProperty, BoolProperty, EnumProperty)
from bpy.types import (Operator, OperatorFileListElement,)
import textwrap

class WorldOriginExport(Operator, ExportHelper): bl_label = 'Export' bl_idname = 'object.world_origin_export' bl_description = textwrap.fill('Moves each selected object to the worlds origin and exports them as a gltf separate', 80) bl_options = {'PRESET', 'UNDO', 'REGISTER'} files = CollectionProperty(name = 'File Path', type = OperatorFileListElement,) directory = StringProperty(subtype = 'DIR_PATH',) filename_ext = '.gltf'

myBool = False

@classmethod
def poll(cls, context):
    sfile = context.space_data
    operator = sfile.active_operator
    return operator.bl_idname == 'OBJECT_OT_world_origin_export'


def draw(self, context):
    layout = self.layout
    layout.use_property_split = False
    layout.use_property_decorate = False  # No animation.

    sfile = context.space_data
    operator = sfile.active_operator


def execute(self, context):
    bpy.ops.export_scene.gltf(filepath = folder_path + os.sep + sel.name)
    return {'FINISHED'}



class GltfSeparate_PT_Panel(bpy.types.Panel): bl_space_type = 'FILE_BROWSER' bl_region_type = 'TOOL_PROPS' bl_label = 'glTF Separate' bl_options = {'DEFAULT_CLOSED'}

@classmethod
def poll(cls, context):
    sfile = context.space_data
    operator = sfile.active_operator
    return operator.bl_idname == 'OBJECT_OT_world_origin_export'


def draw(self, context):
    layout = self.layout
    layout.use_property_split = True
    layout.use_property_decorate = False  # No animation.



class GltfSeparateAnimation_PT_Panel(bpy.types.Panel): bl_space_type = 'FILE_BROWSER' bl_region_type = 'TOOL_PROPS' bl_label = 'Animation1' bl_parent_id = 'GltfSeparate_PT_Panel' bl_options = {'DEFAULT_CLOSED'}

@classmethod
def poll(cls, context):
    sfile = context.space_data
    operator = sfile.active_operator
    return operator.bl_idname == 'OBJECT_OT_world_origin_export'


def draw(self, context):
    layout = self.layout
    layout.use_property_split = True
    layout.use_property_decorate = False  # No animation.



class GltfSeparateAnimationAnimation_PT_Panel(bpy.types.Panel): bl_space_type = 'FILE_BROWSER' bl_region_type = 'TOOL_PROPS' bl_label = '' bl_parent_id = 'GltfSeparateAnimation_PT_Panel' bl_options = {'DEFAULT_CLOSED'}

@classmethod
def poll(cls, context):
    sfile = context.space_data
    operator = sfile.active_operator
    return operator.bl_idname == 'OBJECT_OT_world_origin_export'


def draw(self, context):
    layout = self.layout
    layout.use_property_split = True
    layout.use_property_decorate = False  # No animation.


def draw_header(self, context):
    scene = context.scene
    self.layout.prop(scene, "use_gravity", text = 'Animation2')



def register(): bpy.utils.register_class(WorldOriginExport) bpy.utils.register_class(GltfSeparate_PT_Panel) bpy.utils.register_class(GltfSeparateAnimation_PT_Panel) bpy.utils.register_class(GltfSeparateAnimationAnimation_PT_Panel)

def unregister(): bpy.utils.unregister_class(GltfSeparateAnimationAnimation_PT_Panel) bpy.utils.unregister_class(GltfSeparateAnimation_PT_Panel) bpy.utils.unregister_class(GltfSeparate_PT_Panel) bpy.utils.unregister_class(WorldOriginExport)

if name == 'main': register() bpy.ops.object.world_origin_export('INVOKE_DEFAULT')

Lala_Ghost
  • 457
  • 4
  • 17
  • 1
    My explanation was too compressed? Didn't you see my edit? TLDR; To get a checkbox you'd have to declare a property rather then a regular python variable and then get a reference to active operator (in your case) to get the actual value from: https://pasteall.org/0ZJi You're welcome. – brockmann Mar 31 '21 at 14:49
  • Yeah, I could not do much with the short answer since I am quite new to Python in Blender The second link helped a bit but did not solved it I will look into it tomorrow Thanks for all your help! – Lala_Ghost Mar 31 '21 at 14:57
  • 1
    Click the pasteall link in my first comment, copy paste, done. – brockmann Mar 31 '21 at 14:58

0 Answers0