yyc12345
1a2dd08092
- sync PyBMap work. use different library name in different OS. - add BMap encoding default value according to different OS (Windows and non-Windows) because non-Windows OS, we use libiconv as encoding converter. - move all pointer properties to a single module and give corresponding visitor. - add shared importer exporter parameters module thus bmfile import/export also can ref it.
52 lines
1.9 KiB
Python
52 lines
1.9 KiB
Python
import bpy
|
|
|
|
## Intent
|
|
# Operator is not allowed to register Pointer Properties.
|
|
# The solution is register pointer properties in Scene and reference it when drawing operator window.
|
|
# This module contains all pointer properties used by other operators.
|
|
|
|
class BBP_PG_ptrprop_resolver(bpy.types.PropertyGroup):
|
|
rail_uv_material: bpy.props.PointerProperty(
|
|
name = "Material",
|
|
description = "The material used for rail",
|
|
type = bpy.types.Material,
|
|
)
|
|
|
|
export_collection: bpy.props.PointerProperty(
|
|
type = bpy.types.Collection,
|
|
name = "Collection",
|
|
description = "The collection exported. Nested collections allowed."
|
|
)
|
|
|
|
export_object: bpy.props.PointerProperty(
|
|
type = bpy.types.Object,
|
|
name = "Object",
|
|
description = "The object exported"
|
|
)
|
|
|
|
def get_ptrprop_resolver() -> BBP_PG_ptrprop_resolver:
|
|
return bpy.context.scene.bbp_ptrprop_resolver
|
|
|
|
def get_rail_uv_material() -> bpy.types.Material:
|
|
return get_ptrprop_resolver().rail_uv_material
|
|
def draw_rail_uv_material(layout: bpy.types.UILayout) -> None:
|
|
layout.prop(get_ptrprop_resolver(), 'rail_uv_material')
|
|
|
|
def get_export_collection() -> bpy.types.Collection:
|
|
return get_ptrprop_resolver().export_collection
|
|
def draw_export_collection(layout: bpy.types.UILayout) -> None:
|
|
layout.prop(get_ptrprop_resolver(), 'export_collection')
|
|
|
|
def get_export_object() -> bpy.types.Object:
|
|
return get_ptrprop_resolver().export_object
|
|
def draw_export_object(layout: bpy.types.UILayout) -> None:
|
|
layout.prop(get_ptrprop_resolver(), 'export_object')
|
|
|
|
def register():
|
|
bpy.utils.register_class(BBP_PG_ptrprop_resolver)
|
|
bpy.types.Scene.bbp_ptrprop_resolver = bpy.props.PointerProperty(type = BBP_PG_ptrprop_resolver)
|
|
|
|
def unregister():
|
|
del bpy.types.Scene.bbp_ptrprop_resolver
|
|
bpy.utils.unregister_class(BBP_PG_ptrprop_resolver)
|