forked from bartvdbraak/blender
- dir() now works for collection functions
- group.objects.link/unlink use exceptions rather then return values - scene.add_object/remove_object --> scene.objects.link/unlink
This commit is contained in:
parent
e7413bf791
commit
3119eaf284
@ -485,10 +485,10 @@ def write(filename, objects, scene,
|
|||||||
newob = bpy.data.add_object('MESH', 'temp_object')
|
newob = bpy.data.add_object('MESH', 'temp_object')
|
||||||
newob.data = me
|
newob.data = me
|
||||||
# if we forget to set Object.data - crash
|
# if we forget to set Object.data - crash
|
||||||
scene.add_object(newob)
|
scene.objects.link(newob)
|
||||||
newob.convert_to_triface(scene)
|
newob.convert_to_triface(scene)
|
||||||
# mesh will still be there
|
# mesh will still be there
|
||||||
scene.remove_object(newob)
|
scene.objects.unlink(newob)
|
||||||
'''
|
'''
|
||||||
|
|
||||||
# Make our own list so it can be sorted to reduce context switching
|
# Make our own list so it can be sorted to reduce context switching
|
||||||
|
@ -465,7 +465,7 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH):
|
|||||||
# bmesh.transform(contextMatrix)
|
# bmesh.transform(contextMatrix)
|
||||||
ob = bpy.data.add_object("MESH", tempName)
|
ob = bpy.data.add_object("MESH", tempName)
|
||||||
ob.data = bmesh
|
ob.data = bmesh
|
||||||
SCN.add_object(ob)
|
SCN.objects.link(ob)
|
||||||
# ob = SCN_OBJECTS.new(bmesh, tempName)
|
# ob = SCN_OBJECTS.new(bmesh, tempName)
|
||||||
'''
|
'''
|
||||||
if contextMatrix_tx:
|
if contextMatrix_tx:
|
||||||
@ -766,7 +766,7 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH):
|
|||||||
|
|
||||||
ob = bpy.data.add_object("LAMP", "Lamp")
|
ob = bpy.data.add_object("LAMP", "Lamp")
|
||||||
ob.data = bpy.data.add_lamp("Lamp")
|
ob.data = bpy.data.add_lamp("Lamp")
|
||||||
SCN.add_object(ob)
|
SCN.objects.link(ob)
|
||||||
|
|
||||||
contextLamp[1]= ob.data
|
contextLamp[1]= ob.data
|
||||||
# contextLamp[1]= bpy.data.lamps.new()
|
# contextLamp[1]= bpy.data.lamps.new()
|
||||||
|
@ -864,7 +864,7 @@ def create_mesh(scn, new_objects, has_ngons, CREATE_FGONS, CREATE_EDGES, verts_l
|
|||||||
|
|
||||||
ob= bpy.data.add_object("MESH", "Mesh")
|
ob= bpy.data.add_object("MESH", "Mesh")
|
||||||
ob.data= me
|
ob.data= me
|
||||||
scn.add_object(ob)
|
scn.objects.link(ob)
|
||||||
# ob= scn.objects.new(me)
|
# ob= scn.objects.new(me)
|
||||||
new_objects.append(ob)
|
new_objects.append(ob)
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ class AddTorus(bpy.types.Operator):
|
|||||||
mesh.update()
|
mesh.update()
|
||||||
ob_new = bpy.data.add_object('MESH', "Torus")
|
ob_new = bpy.data.add_object('MESH', "Torus")
|
||||||
ob_new.data = mesh
|
ob_new.data = mesh
|
||||||
scene.add_object(ob_new)
|
scene.objects.link(ob_new)
|
||||||
scene.objects.active = ob_new
|
scene.objects.active = ob_new
|
||||||
ob_new.selected = True
|
ob_new.selected = True
|
||||||
|
|
||||||
|
@ -49,16 +49,24 @@ static PointerRNA rna_Group_objects_get(CollectionPropertyIterator *iter)
|
|||||||
return rna_pointer_inherit_refine(&iter->parent, &RNA_Object, ((GroupObject*)internal->link)->ob);
|
return rna_pointer_inherit_refine(&iter->parent, &RNA_Object, ((GroupObject*)internal->link)->ob);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rna_Group_objects_link(Group *group, bContext *C, Object *object)
|
static void rna_Group_objects_link(Group *group, bContext *C, ReportList *reports, Object *object)
|
||||||
{
|
{
|
||||||
|
if(!add_to_group(group, object, CTX_data_scene(C), NULL)) {
|
||||||
|
BKE_reportf(reports, RPT_ERROR, "Object \"%s\" already in group \"%s\".", object->id.name+2, group->id.name+2);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, &object->id);
|
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, &object->id);
|
||||||
return add_to_group(group, object, CTX_data_scene(C), NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rna_Group_objects_unlink(Group *group, bContext *C, Object *object)
|
static void rna_Group_objects_unlink(Group *group, bContext *C, ReportList *reports, Object *object)
|
||||||
{
|
{
|
||||||
|
if(!rem_from_group(group, object, CTX_data_scene(C), NULL)) {
|
||||||
|
BKE_reportf(reports, RPT_ERROR, "Object \"%s\" not in group \"%s\".", object->id.name+2, group->id.name+2);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, &object->id);
|
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, &object->id);
|
||||||
return rem_from_group(group, object, CTX_data_scene(C), NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@ -79,11 +87,8 @@ static void rna_def_group_objects(BlenderRNA *brna, PropertyRNA *cprop)
|
|||||||
|
|
||||||
/* add object */
|
/* add object */
|
||||||
func= RNA_def_function(srna, "link", "rna_Group_objects_link");
|
func= RNA_def_function(srna, "link", "rna_Group_objects_link");
|
||||||
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
|
RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS);
|
||||||
RNA_def_function_ui_description(func, "Add this object to a group");
|
RNA_def_function_ui_description(func, "Add this object to a group");
|
||||||
/* return type */
|
|
||||||
parm= RNA_def_boolean(func, "success", 0, "Success", "");
|
|
||||||
RNA_def_function_return(func, parm);
|
|
||||||
/* object to add */
|
/* object to add */
|
||||||
parm= RNA_def_pointer(func, "object", "Object", "", "Object to add.");
|
parm= RNA_def_pointer(func, "object", "Object", "", "Object to add.");
|
||||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||||
@ -91,10 +96,7 @@ static void rna_def_group_objects(BlenderRNA *brna, PropertyRNA *cprop)
|
|||||||
/* remove object */
|
/* remove object */
|
||||||
func= RNA_def_function(srna, "unlink", "rna_Group_objects_unlink");
|
func= RNA_def_function(srna, "unlink", "rna_Group_objects_unlink");
|
||||||
RNA_def_function_ui_description(func, "Remove this object to a group");
|
RNA_def_function_ui_description(func, "Remove this object to a group");
|
||||||
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
|
RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS);
|
||||||
/* return type */
|
|
||||||
parm= RNA_def_boolean(func, "success", 0, "Success", "");
|
|
||||||
RNA_def_function_return(func, parm);
|
|
||||||
/* object to remove */
|
/* object to remove */
|
||||||
parm= RNA_def_pointer(func, "object", "Object", "", "Object to remove.");
|
parm= RNA_def_pointer(func, "object", "Object", "", "Object to remove.");
|
||||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||||
|
@ -80,6 +80,7 @@ EnumPropertyItem proportional_editing_items[] = {
|
|||||||
#include "BKE_node.h"
|
#include "BKE_node.h"
|
||||||
#include "BKE_pointcache.h"
|
#include "BKE_pointcache.h"
|
||||||
#include "BKE_scene.h"
|
#include "BKE_scene.h"
|
||||||
|
#include "BKE_depsgraph.h"
|
||||||
|
|
||||||
#include "BLI_threads.h"
|
#include "BLI_threads.h"
|
||||||
|
|
||||||
@ -97,6 +98,34 @@ static PointerRNA rna_Scene_objects_get(CollectionPropertyIterator *iter)
|
|||||||
return rna_pointer_inherit_refine(&iter->parent, &RNA_Object, ((Base*)internal->link)->object);
|
return rna_pointer_inherit_refine(&iter->parent, &RNA_Object, ((Base*)internal->link)->object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void rna_Scene_link_object(Scene *sce, ReportList *reports, Object *ob)
|
||||||
|
{
|
||||||
|
Base *base= object_in_scene(ob, sce);
|
||||||
|
if (base) {
|
||||||
|
BKE_report(reports, RPT_ERROR, "Object is already in this scene.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
base= scene_add_base(sce, ob);
|
||||||
|
ob->id.us++;
|
||||||
|
|
||||||
|
/* this is similar to what object_add_type and add_object do */
|
||||||
|
ob->lay= base->lay= sce->lay;
|
||||||
|
ob->recalc |= OB_RECALC;
|
||||||
|
|
||||||
|
DAG_scene_sort(sce);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void rna_Scene_unlink_object(Scene *sce, ReportList *reports, Object *ob)
|
||||||
|
{
|
||||||
|
Base *base= object_in_scene(ob, sce);
|
||||||
|
if (!base) {
|
||||||
|
BKE_report(reports, RPT_ERROR, "Object is not in this scene.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/* as long as ED_base_object_free_and_unlink calls free_libblock_us, we don't have to decrement ob->id.us */
|
||||||
|
ED_base_object_free_and_unlink(sce, base);
|
||||||
|
}
|
||||||
|
|
||||||
static void rna_Scene_skgen_etch_template_set(PointerRNA *ptr, PointerRNA value)
|
static void rna_Scene_skgen_etch_template_set(PointerRNA *ptr, PointerRNA value)
|
||||||
{
|
{
|
||||||
ToolSettings *ts = (ToolSettings*)ptr->data;
|
ToolSettings *ts = (ToolSettings*)ptr->data;
|
||||||
@ -2176,37 +2205,25 @@ static void rna_def_scene_objects(BlenderRNA *brna, PropertyRNA *cprop)
|
|||||||
StructRNA *srna;
|
StructRNA *srna;
|
||||||
PropertyRNA *prop;
|
PropertyRNA *prop;
|
||||||
|
|
||||||
// FunctionRNA *func;
|
FunctionRNA *func;
|
||||||
// PropertyRNA *parm;
|
PropertyRNA *parm;
|
||||||
|
|
||||||
RNA_def_property_srna(cprop, "SceneObjects");
|
RNA_def_property_srna(cprop, "SceneObjects");
|
||||||
srna= RNA_def_struct(brna, "SceneObjects", NULL);
|
srna= RNA_def_struct(brna, "SceneObjects", NULL);
|
||||||
RNA_def_struct_sdna(srna, "Object");
|
RNA_def_struct_sdna(srna, "Scene");
|
||||||
RNA_def_struct_ui_text(srna, "Scene Objects", "Collection of scene objects.");
|
RNA_def_struct_ui_text(srna, "Scene Objects", "Collection of scene objects.");
|
||||||
|
|
||||||
#if 0
|
func= RNA_def_function(srna, "link", "rna_Scene_link_object");
|
||||||
/* add object */
|
RNA_def_function_ui_description(func, "Link object to scene.");
|
||||||
func= RNA_def_function(srna, "link", "rna_Scene_objects_link");
|
RNA_def_function_flag(func, FUNC_USE_REPORTS);
|
||||||
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
|
parm= RNA_def_pointer(func, "object", "Object", "", "Object to add to scene.");
|
||||||
RNA_def_function_ui_description(func, "Add this object to this scene");
|
|
||||||
/* return type */
|
|
||||||
parm= RNA_def_boolean(func, "success", 0, "Success", "");
|
|
||||||
RNA_def_function_return(func, parm);
|
|
||||||
/* object to add */
|
|
||||||
parm= RNA_def_pointer(func, "object", "Object", "", "Object to add.");
|
|
||||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||||
|
|
||||||
/* remove object */
|
func= RNA_def_function(srna, "unlink", "rna_Scene_unlink_object");
|
||||||
func= RNA_def_function(srna, "unlink", "rna_Scene_objects_unlink");
|
RNA_def_function_ui_description(func, "Unlink object from scene.");
|
||||||
RNA_def_function_ui_description(func, "Remove this object to a scene");
|
RNA_def_function_flag(func, FUNC_USE_REPORTS);
|
||||||
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
|
parm= RNA_def_pointer(func, "object", "Object", "", "Object to remove from scene.");
|
||||||
/* return type */
|
|
||||||
parm= RNA_def_boolean(func, "success", 0, "Success", "");
|
|
||||||
RNA_def_function_return(func, parm);
|
|
||||||
/* object to remove */
|
|
||||||
parm= RNA_def_pointer(func, "object", "Object", "", "Object to remove.");
|
|
||||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||||
#endif
|
|
||||||
|
|
||||||
prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
|
prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
|
||||||
RNA_def_property_struct_type(prop, "Object");
|
RNA_def_property_struct_type(prop, "Object");
|
||||||
|
@ -47,34 +47,6 @@
|
|||||||
|
|
||||||
#include "WM_api.h"
|
#include "WM_api.h"
|
||||||
|
|
||||||
static void rna_Scene_add_object(Scene *sce, ReportList *reports, Object *ob)
|
|
||||||
{
|
|
||||||
Base *base= object_in_scene(ob, sce);
|
|
||||||
if (base) {
|
|
||||||
BKE_report(reports, RPT_ERROR, "Object is already in this scene.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
base= scene_add_base(sce, ob);
|
|
||||||
ob->id.us++;
|
|
||||||
|
|
||||||
/* this is similar to what object_add_type and add_object do */
|
|
||||||
ob->lay= base->lay= sce->lay;
|
|
||||||
ob->recalc |= OB_RECALC;
|
|
||||||
|
|
||||||
DAG_scene_sort(sce);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void rna_Scene_remove_object(Scene *sce, ReportList *reports, Object *ob)
|
|
||||||
{
|
|
||||||
Base *base= object_in_scene(ob, sce);
|
|
||||||
if (!base) {
|
|
||||||
BKE_report(reports, RPT_ERROR, "Object is not in this scene.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
/* as long as ED_base_object_free_and_unlink calls free_libblock_us, we don't have to decrement ob->id.us */
|
|
||||||
ED_base_object_free_and_unlink(sce, base);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void rna_Scene_set_frame(Scene *sce, bContext *C, int frame)
|
static void rna_Scene_set_frame(Scene *sce, bContext *C, int frame)
|
||||||
{
|
{
|
||||||
sce->r.cfra= frame;
|
sce->r.cfra= frame;
|
||||||
@ -118,18 +90,6 @@ void RNA_api_scene(StructRNA *srna)
|
|||||||
FunctionRNA *func;
|
FunctionRNA *func;
|
||||||
PropertyRNA *parm;
|
PropertyRNA *parm;
|
||||||
|
|
||||||
func= RNA_def_function(srna, "add_object", "rna_Scene_add_object");
|
|
||||||
RNA_def_function_ui_description(func, "Add object to scene.");
|
|
||||||
RNA_def_function_flag(func, FUNC_USE_REPORTS);
|
|
||||||
parm= RNA_def_pointer(func, "object", "Object", "", "Object to add to scene.");
|
|
||||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
|
||||||
|
|
||||||
func= RNA_def_function(srna, "remove_object", "rna_Scene_remove_object");
|
|
||||||
RNA_def_function_ui_description(func, "Remove object from scene.");
|
|
||||||
RNA_def_function_flag(func, FUNC_USE_REPORTS);
|
|
||||||
parm= RNA_def_pointer(func, "object", "Object", "", "Object to remove from scene.");
|
|
||||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
|
||||||
|
|
||||||
func= RNA_def_function(srna, "set_frame", "rna_Scene_set_frame");
|
func= RNA_def_function(srna, "set_frame", "rna_Scene_set_frame");
|
||||||
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
|
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
|
||||||
RNA_def_function_ui_description(func, "Set scene frame updating all objects immediately.");
|
RNA_def_function_ui_description(func, "Set scene frame updating all objects immediately.");
|
||||||
|
@ -1428,54 +1428,66 @@ static PyObject *pyrna_struct_path_resolve(BPy_StructRNA *self, PyObject *value)
|
|||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *pyrna_struct_dir(BPy_StructRNA *self)
|
|
||||||
|
static void pyrna_dir_members_py(PyObject *list, PyObject *self)
|
||||||
{
|
{
|
||||||
PyObject *ret, *dict;
|
PyObject *dict;
|
||||||
PyObject *pystring;
|
PyObject **dict_ptr;
|
||||||
|
PyObject *list_tmp;
|
||||||
/* for looping over attrs and funcs */
|
|
||||||
PropertyRNA *iterprop;
|
|
||||||
|
|
||||||
/* Include this incase this instance is a subtype of a python class
|
|
||||||
* In these instances we may want to return a function or variable provided by the subtype
|
|
||||||
* */
|
|
||||||
|
|
||||||
if (BPy_StructRNA_CheckExact(self)) {
|
dict_ptr= _PyObject_GetDictPtr((PyObject *)self);
|
||||||
ret = PyList_New(0);
|
|
||||||
} else {
|
|
||||||
PyObject *list;
|
|
||||||
/* class instances */
|
|
||||||
dict = *_PyObject_GetDictPtr((PyObject *)self);
|
|
||||||
|
|
||||||
if (dict==NULL) {
|
if(dict_ptr && (dict=*dict_ptr)) {
|
||||||
ret = PyList_New(0);
|
list_tmp = PyDict_Keys(dict);
|
||||||
}
|
PyList_SetSlice(list, INT_MAX, INT_MAX, list_tmp);
|
||||||
else {
|
Py_DECREF(list_tmp);
|
||||||
ret = PyDict_Keys(dict);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* classes dict */
|
|
||||||
dict= ((PyTypeObject *)Py_TYPE(self))->tp_dict;
|
|
||||||
list = PyDict_Keys(dict);
|
|
||||||
PyList_SetSlice(ret, INT_MAX, INT_MAX, list);
|
|
||||||
Py_DECREF(list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Collect RNA items*/
|
dict= ((PyTypeObject *)Py_TYPE(self))->tp_dict;
|
||||||
|
if(dict) {
|
||||||
|
list_tmp = PyDict_Keys(dict);
|
||||||
|
PyList_SetSlice(list, INT_MAX, INT_MAX, list_tmp);
|
||||||
|
Py_DECREF(list_tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void pyrna_dir_members_rna(PyObject *list, PointerRNA *ptr)
|
||||||
|
{
|
||||||
|
PyObject *pystring;
|
||||||
|
const char *idname;
|
||||||
|
|
||||||
|
/* for looping over attrs and funcs */
|
||||||
|
PointerRNA tptr;
|
||||||
|
PropertyRNA *iterprop;
|
||||||
|
|
||||||
|
{
|
||||||
|
RNA_pointer_create(NULL, &RNA_Struct, ptr->type, &tptr);
|
||||||
|
iterprop= RNA_struct_find_property(&tptr, "functions");
|
||||||
|
|
||||||
|
RNA_PROP_BEGIN(&tptr, itemptr, iterprop) {
|
||||||
|
idname= RNA_function_identifier(itemptr.data);
|
||||||
|
|
||||||
|
pystring = PyUnicode_FromString(idname);
|
||||||
|
PyList_Append(list, pystring);
|
||||||
|
Py_DECREF(pystring);
|
||||||
|
}
|
||||||
|
RNA_PROP_END;
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Collect RNA attributes
|
* Collect RNA attributes
|
||||||
*/
|
*/
|
||||||
char name[256], *nameptr;
|
char name[256], *nameptr;
|
||||||
|
|
||||||
iterprop= RNA_struct_iterator_property(self->ptr.type);
|
iterprop= RNA_struct_iterator_property(ptr->type);
|
||||||
|
|
||||||
RNA_PROP_BEGIN(&self->ptr, itemptr, iterprop) {
|
RNA_PROP_BEGIN(ptr, itemptr, iterprop) {
|
||||||
nameptr= RNA_struct_name_get_alloc(&itemptr, name, sizeof(name));
|
nameptr= RNA_struct_name_get_alloc(&itemptr, name, sizeof(name));
|
||||||
|
|
||||||
if(nameptr) {
|
if(nameptr) {
|
||||||
pystring = PyUnicode_FromString(nameptr);
|
pystring = PyUnicode_FromString(nameptr);
|
||||||
PyList_Append(ret, pystring);
|
PyList_Append(list, pystring);
|
||||||
Py_DECREF(pystring);
|
Py_DECREF(pystring);
|
||||||
|
|
||||||
if(name != nameptr)
|
if(name != nameptr)
|
||||||
@ -1484,27 +1496,23 @@ static PyObject *pyrna_struct_dir(BPy_StructRNA *self)
|
|||||||
}
|
}
|
||||||
RNA_PROP_END;
|
RNA_PROP_END;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Collect RNA function items
|
|
||||||
*/
|
|
||||||
PointerRNA tptr;
|
|
||||||
const char *idname;
|
|
||||||
|
|
||||||
RNA_pointer_create(NULL, &RNA_Struct, self->ptr.type, &tptr);
|
|
||||||
iterprop= RNA_struct_find_property(&tptr, "functions");
|
|
||||||
|
|
||||||
RNA_PROP_BEGIN(&tptr, itemptr, iterprop) {
|
static PyObject *pyrna_struct_dir(BPy_StructRNA *self)
|
||||||
idname= RNA_function_identifier(itemptr.data);
|
{
|
||||||
|
PyObject *ret;
|
||||||
|
PyObject *pystring;
|
||||||
|
|
||||||
pystring = PyUnicode_FromString(idname);
|
/* Include this incase this instance is a subtype of a python class
|
||||||
PyList_Append(ret, pystring);
|
* In these instances we may want to return a function or variable provided by the subtype
|
||||||
Py_DECREF(pystring);
|
* */
|
||||||
}
|
ret = PyList_New(0);
|
||||||
RNA_PROP_END;
|
|
||||||
}
|
if (!BPy_StructRNA_CheckExact(self))
|
||||||
|
pyrna_dir_members_py(ret, (PyObject *)self);
|
||||||
|
|
||||||
|
pyrna_dir_members_rna(ret, &self->ptr);
|
||||||
|
|
||||||
if(self->ptr.type == &RNA_Context) {
|
if(self->ptr.type == &RNA_Context) {
|
||||||
ListBase lb = CTX_data_dir_get(self->ptr.data);
|
ListBase lb = CTX_data_dir_get(self->ptr.data);
|
||||||
@ -1663,6 +1671,26 @@ static int pyrna_struct_setattro( BPy_StructRNA *self, PyObject *pyname, PyObjec
|
|||||||
return pyrna_py_to_prop(&self->ptr, prop, NULL, value, "StructRNA - item.attr = val:");
|
return pyrna_py_to_prop(&self->ptr, prop, NULL, value, "StructRNA - item.attr = val:");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PyObject *pyrna_prop_dir(BPy_PropertyRNA *self)
|
||||||
|
{
|
||||||
|
PyObject *ret;
|
||||||
|
PointerRNA r_ptr;
|
||||||
|
|
||||||
|
/* Include this incase this instance is a subtype of a python class
|
||||||
|
* In these instances we may want to return a function or variable provided by the subtype
|
||||||
|
* */
|
||||||
|
ret = PyList_New(0);
|
||||||
|
|
||||||
|
if (!BPy_PropertyRNA_CheckExact(self))
|
||||||
|
pyrna_dir_members_py(ret, (PyObject *)self);
|
||||||
|
|
||||||
|
if(RNA_property_collection_type_get(&self->ptr, self->prop, &r_ptr))
|
||||||
|
pyrna_dir_members_rna(ret, &r_ptr);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static PyObject *pyrna_prop_getattro( BPy_PropertyRNA *self, PyObject *pyname )
|
static PyObject *pyrna_prop_getattro( BPy_PropertyRNA *self, PyObject *pyname )
|
||||||
{
|
{
|
||||||
char *name = _PyUnicode_AsString(pyname);
|
char *name = _PyUnicode_AsString(pyname);
|
||||||
@ -2172,6 +2200,7 @@ static struct PyMethodDef pyrna_prop_methods[] = {
|
|||||||
/* array accessor function */
|
/* array accessor function */
|
||||||
{"foreach_get", (PyCFunction)pyrna_prop_foreach_get, METH_VARARGS, NULL},
|
{"foreach_get", (PyCFunction)pyrna_prop_foreach_get, METH_VARARGS, NULL},
|
||||||
{"foreach_set", (PyCFunction)pyrna_prop_foreach_set, METH_VARARGS, NULL},
|
{"foreach_set", (PyCFunction)pyrna_prop_foreach_set, METH_VARARGS, NULL},
|
||||||
|
{"__dir__", (PyCFunction)pyrna_prop_dir, METH_NOARGS, NULL},
|
||||||
{NULL, NULL, 0, NULL}
|
{NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -3753,7 +3782,7 @@ static int bpy_class_call(PointerRNA *ptr, FunctionRNA *func, ParameterList *par
|
|||||||
pret= RNA_function_return(func);
|
pret= RNA_function_return(func);
|
||||||
RNA_pointer_create(NULL, &RNA_Function, func, &funcptr);
|
RNA_pointer_create(NULL, &RNA_Function, func, &funcptr);
|
||||||
|
|
||||||
args = PyTuple_New(rna_function_arg_count(func));
|
args = PyTuple_New(rna_function_arg_count(func)); /* first arg is included in 'item' */
|
||||||
PyTuple_SET_ITEM(args, 0, py_class_instance);
|
PyTuple_SET_ITEM(args, 0, py_class_instance);
|
||||||
|
|
||||||
RNA_parameter_list_begin(parms, &iter);
|
RNA_parameter_list_begin(parms, &iter);
|
||||||
@ -3778,7 +3807,8 @@ static int bpy_class_call(PointerRNA *ptr, FunctionRNA *func, ParameterList *par
|
|||||||
Py_DECREF(args);
|
Py_DECREF(args);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Py_DECREF(py_class_instance);
|
PyErr_Print();
|
||||||
|
PyErr_Clear();
|
||||||
PyErr_Format(PyExc_TypeError, "could not find function %.200s in %.200s to execute callback.", RNA_function_identifier(func), RNA_struct_identifier(ptr->type));
|
PyErr_Format(PyExc_TypeError, "could not find function %.200s in %.200s to execute callback.", RNA_function_identifier(func), RNA_struct_identifier(ptr->type));
|
||||||
err= -1;
|
err= -1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user