Defining a private execution context

Hello,

I’d like to define some kind of private context in my python addon. Normally, it could be scene or object… but i want to be sure that none of the properties involve conflicts with another addon.
How to define that ? Another class in bpy.struct ? And if so, how to code it ?

Thanks,

any vars defined in a function or class is private or local
unless re defined by global vars!

what do you mean by context !

can you elaborate more !

happy bl

I mean the contexts used as arguments in the draw (Panels) or execute (Operators) function. What i have seen is they are based on the bpy.types elements. For instance object or scene. But so the properties defined on them can be conflictual with other addons (am i right ?). That why i’d like to make my own context class, but i dont know how to do that.

can you show a specific example for panel or operators

prop are independent from other operators
but may be with example it will clarify it

if you use full name for vars they wont interfere with other addons!
I mean name = module. var

thanks
happy bl

A common way to avoid name clashing is to prefix your class with a prefix. The prefix is up to you. Your initials, an abbreviation of the framework, etc. For example you have a class Class you could name it LAJClass.

I did it this way


def GetMyType():
    return bpy.types.Scene

def register():
    GetMyType().reg = bpy.props.StringProperty(default='WeightTransfer')
    GetMyType().sourceMesh = bpy.props.StringProperty( description="Source mesh" )
    GetMyType().sourceArmature = bpy.props.StringProperty( description="Source armature" )
    GetMyType().destMesh = bpy.props.StringProperty( description="Destination mesh" )
    GetMyType().createEmptyGroup = bpy.props.BoolProperty( description="Create empty groups option", default=True )
    bpy.utils.register_class(WeightTransferOperator)
    bpy.utils.register_class(WeightTransfer)
    bpy.utils.register_module(__name__)

OK @Terry to add a prefix but I was wondering about the possibility to add a new type/data both at the bpy.types level and at the context level.

To prefix a struct within a class use the class name as the prefix of the struct name.
For example you have class name LAJClass (which is unique) and a struct Scene then LAJClassScene is unique also.