- property decorators for setting attributes didnt work, hack to prevent every instan...
authorCampbell Barton <ideasman42@gmail.com>
Thu, 3 Dec 2009 21:53:01 +0000 (21:53 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 3 Dec 2009 21:53:01 +0000 (21:53 +0000)
- made bone.length writable

release/scripts/modules/bpy_types.py
source/blender/makesdna/DNA_action_types.h
source/blender/python/intern/bpy_rna.c

index 4351ee7579b300ca0aaa896243c36c2663be628f..565f0e4da1b9e50b91117108dea01ec1749c8a0b 100644 (file)
@@ -88,6 +88,11 @@ class _GenericBone:
     @property
     def length(self):
         return (self.head - self.tail).length
+    
+    @length.setter
+    def length(self, value):
+        """The distance from head to tail"""
+        self.tail = self.head + ((self.tail - self.head).normalize() * value)
 
     @property
     def children(self):
index 5f6d8ef375ad431ebf68833aaa2a362e4a488a24..0dc24f31a7b4c76aba91aa452fa83d0889af7569 100644 (file)
@@ -244,7 +244,7 @@ typedef enum eRotationModes {
  * though there is a define for it (hack for the outliner).
  */
 typedef struct bPose {
-       ListBase chanbase;                      /* list of pose channels */
+       ListBase chanbase;                      /* list of pose channels, PoseBones in RNA */
        
        short flag, proxy_layer;        /* proxy layer: copy from armature, gets synced */
        
index fd5e1ddf75c31500ee048acf366bf80971137660..e657cfc79e29332b6e2afe1bf77f677869e0d218 100644 (file)
@@ -1738,19 +1738,22 @@ static int pyrna_struct_setattro( BPy_StructRNA *self, PyObject *pyname, PyObjec
        PropertyRNA *prop = RNA_struct_find_property(&self->ptr, name);
        
        if (prop==NULL) {
+               return PyObject_GenericSetAttr((PyObject *)self, pyname, value);
+#if 0
                // XXX - This currently allows anything to be assigned to an rna prop, need to see how this should be used
                // but for now it makes porting scripts confusing since it fails silently.
                // edit: allowing this for setting classes internal attributes.
                // edit: allow this for any attribute that alredy exists as a python attr
                if (    (name[0]=='_' /* || pyrna_struct_pydict_contains(self, pyname) */ ) &&
                                !BPy_StructRNA_CheckExact(self) &&
-                               PyObject_GenericSetAttr((PyObject *)self, pyname, value) >= 0) {
+
                        return 0;
                } else
                {
                        PyErr_Format( PyExc_AttributeError, "StructRNA - Attribute \"%.200s\" not found", name);
                        return -1;
                }
+#endif
        }               
        
        if (!RNA_property_editable(&self->ptr, prop)) {
@@ -2984,6 +2987,9 @@ static PyObject* pyrna_srna_ExternalType(StructRNA *srna)
                PyObject *base_compare= pyrna_srna_PyBase(srna);
                PyObject *bases= PyObject_GetAttrString(newclass, "__bases__");
 
+               // XXX - highly dodgy!, this stops blender from creating __dict__ in instances
+               ((PyTypeObject *)newclass)->tp_dictoffset = 0;
+
                if(PyTuple_GET_SIZE(bases)) {
                        PyObject *base= PyTuple_GET_ITEM(bases, 0);
 
@@ -3039,6 +3045,9 @@ static PyObject* pyrna_srna_Subtype(StructRNA *srna)
 
                if (newclass) {
 
+                       // XXX - highly dodgy!, this stops blender from creating __dict__ in instances
+                       ((PyTypeObject *)newclass)->tp_dictoffset = 0;
+
                        /* srna owns one, and the other is owned by the caller */
                        pyrna_subtype_set_rna(newclass, srna);