Hi, there are indeed some loose ends with id property & UI integration as you have noticed. This is an area which can worked on but for the mostpart python defined RNA is the way to go.
reply inline. On Sat, Jan 1, 2011 at 9:41 AM, Hart's Antler <bhart...@yahoo.com> wrote: > 1. KeyError: 'the length of IDProperty names is limited to 31 > characters'object['x'*32] = 'why not make the limit 32 or 64?, 31 is an odd > number - not possible to use md5sum hashes either as a workaround' its annoying but with a fixed allocation size per item its not so simple to avoid. * Allocating the strings each would cause worse problem with small allocations then we already have. * Changing the fixed length higher then 31 could work but would mean opening files in older blender versions would be incompatible. * having a limit of 32 and ensure all string functions limit to 32 chars could work too (use strncpy rather then strcpy) could work but also would give problems with loading new files on older blenders. for a 1 char gain I don't think its worth it. This is similar to being able to having object names longer then 21 chars. known problem and not trivial to fix. > 2. inner single quotes are invalid## this failslayout.prop( object, > "['my-custom-prop']" ) # a better warning should be printed, or > single quotes should be supported## this works - double quotes must be > usedlayout.prop( object, '["my-custom-prop"]' ) The issue here is that we are using the animation path lookup for the UI as well, see: RNA_path_resolve(), since this is potentially evaluated 100's, even 1000s of times a frame update, and not compiled into bytecode (as with python), I prefer not to confuse this as being a language or being python compatible. and keep path evaluation simple where possible. We could raise an error if "['foo']" is passed to a UI function to avoid confusion. > 3. dicts are allowed, but layout.prop(...) can not show each subkey on its > own## (the dict can be viewed as a string from Custom Properties Panel, but > thats not very useful for the user) ##object['x'] = {'a':1, 'b':2}box.prop( > object, '["x"]["a"]' ) # error: rna_uiItemR: property not > found: Object.["x"]["a"]box.prop( object, '["x"]' ) # this also fails This is just not supported yet, direct ID property access isnt compleate, best define your own RNA in most cases as Tom Edwards pointed out. > 4. booleans not supported by custom propertiesobject['my-custom-prop'] = True Yes, ID properties only support ints, floats. Again, using RNA you can define booleans. its not that hard to add boolean support to ID properties so// ob["mybool"] = True ...is not the same as ob["mybool"] = 1 I don't think this is a big limitation, boolean is a subclass of an int in python, "1 == True" works as if both are 1. # converted to 1 without any warninglayout.prop( object, '["my-custom-prop"]', toggle=True ) # toggle is ignored, numeric entry is displayed instead > ## workaround ##class mypanel(bpy.types.Panel): bl_space_type = 'PROPERTIES' > bl_region_type = 'WINDOW' bl_context = "object" bl_label = "toggle > custom prop example" @classmethod def poll(cls, context): return True > def draw(self, context): layout = self.layout ob = > context.active_object tag = 'my-custom-prop' if tag not > in ob.keys(): ob[tag] = True v = ob[tag] if v: icon = > 'CHECKBOX_HLT' else: icon = 'CHECKBOX_DEHLT' op = > layout.operator( 'toggle_prop', text=tag, icon=icon ) > op.propname = tag > class toggle_prop_op(bpy.types.Operator): '''operator: > prop toggle helper''' bl_idname = "toggle_prop" bl_label = > "toggle" bl_options = {'REGISTER', 'UNDO'} propname > = StringProperty(name="property name", description="...", maxlen=32, > default="") @classmethod def poll(cls, context): return True def > invoke(self, context, event): ob = context.active_object > ob[ self.propname ] = not ob[ self.propname ] return > {'FINISHED'} > > > _______________________________________________ > Bf-committers mailing list > Bf-committers@blender.org > http://lists.blender.org/mailman/listinfo/bf-committers > -- - Campbell _______________________________________________ Bf-committers mailing list Bf-committers@blender.org http://lists.blender.org/mailman/listinfo/bf-committers