* Split Object.c (created Object.h)
* Split Blender.c (created Blender.h) * Followed a naming convention suggested by Willian for Modules and Classes. * Implemented New, Get and GetSelected functions for the Object module. * Implemented most of the attributes in the Get and Set functions for the Object module. * Hopefully fixed a link error on OS X. Declared g_blenderdict externally in modules.h and moved the real declaration to Blender.c
This commit is contained in:
@@ -29,61 +29,12 @@
|
|||||||
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Python.h>
|
#include "Blender.h"
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include <BKE_global.h>
|
|
||||||
#include <BSE_headerbuttons.h>
|
|
||||||
#include <DNA_ID.h>
|
|
||||||
#include <DNA_object_types.h>
|
|
||||||
#include <DNA_scene_types.h>
|
|
||||||
/* #include <DNA_screen_types.h> */
|
|
||||||
#include <DNA_userdef_types.h>
|
|
||||||
#include <BKE_ipo.h>
|
|
||||||
|
|
||||||
#include "gen_utils.h"
|
|
||||||
#include "modules.h"
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Python API function prototypes for the Blender module. */
|
/* Global variables */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
PyObject *Blender_Set (PyObject *self, PyObject *args);
|
PyObject *g_blenderdict;
|
||||||
PyObject *Blender_Get (PyObject *self, PyObject *args);
|
|
||||||
PyObject *Blender_Redraw(PyObject *self, PyObject *args);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/* The following string definitions are used for documentation strings. */
|
|
||||||
/* In Python these will be written to the console when doing a */
|
|
||||||
/* Blender.__doc__ */
|
|
||||||
/*****************************************************************************/
|
|
||||||
char Blender_Set_doc[] =
|
|
||||||
"(request, data) - Update settings in Blender\n\
|
|
||||||
\n\
|
|
||||||
(request) A string indentifying the setting to change\n\
|
|
||||||
'curframe' - Sets the current frame using the number in data";
|
|
||||||
|
|
||||||
char Blender_Get_doc[] =
|
|
||||||
"(request) - Retrieve settings from Blender\n\
|
|
||||||
\n\
|
|
||||||
(request) A string indentifying the data to be returned\n\
|
|
||||||
'curframe' - Returns the current animation frame\n\
|
|
||||||
'curtime' - Returns the current animation time\n\
|
|
||||||
'staframe' - Returns the start frame of the animation\n\
|
|
||||||
'endframe' - Returns the end frame of the animation\n\
|
|
||||||
'filename' - Returns the name of the last file read or written\n\
|
|
||||||
'version' - Returns the Blender version number";
|
|
||||||
|
|
||||||
char Blender_Redraw_doc[] = "() - Redraw all 3D windows";
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/* Python method structure definition. */
|
|
||||||
/*****************************************************************************/
|
|
||||||
struct PyMethodDef Blender_methods[] = {
|
|
||||||
{"Set", &Blender_Set, METH_VARARGS, Blender_Set_doc},
|
|
||||||
{"Get", &Blender_Get, METH_VARARGS, Blender_Get_doc},
|
|
||||||
{"Redraw", &Blender_Redraw, METH_VARARGS, Blender_Redraw_doc},
|
|
||||||
{NULL, NULL}
|
|
||||||
};
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: Blender_Set */
|
/* Function: Blender_Set */
|
||||||
|
90
source/blender/python/api2_2x/Blender.h
Normal file
90
source/blender/python/api2_2x/Blender.h
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version. The Blender
|
||||||
|
* Foundation also sells licenses for use in proprietary software under
|
||||||
|
* the Blender License. See http://www.blender.org/BL/ for information
|
||||||
|
* about this.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This is a new part of Blender.
|
||||||
|
*
|
||||||
|
* Contributor(s): Michel Selten
|
||||||
|
*
|
||||||
|
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EXPP_BLENDER_H
|
||||||
|
#define EXPP_BLENDER_H
|
||||||
|
|
||||||
|
#include <Python.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <BKE_global.h>
|
||||||
|
#include <BSE_headerbuttons.h>
|
||||||
|
#include <DNA_ID.h>
|
||||||
|
#include <DNA_object_types.h>
|
||||||
|
#include <DNA_scene_types.h>
|
||||||
|
#include <DNA_userdef_types.h>
|
||||||
|
#include <BKE_ipo.h>
|
||||||
|
|
||||||
|
#include "gen_utils.h"
|
||||||
|
#include "modules.h"
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Python API function prototypes for the Blender module. */
|
||||||
|
/*****************************************************************************/
|
||||||
|
PyObject *Blender_Set (PyObject *self, PyObject *args);
|
||||||
|
PyObject *Blender_Get (PyObject *self, PyObject *args);
|
||||||
|
PyObject *Blender_Redraw(PyObject *self, PyObject *args);
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* The following string definitions are used for documentation strings. */
|
||||||
|
/* In Python these will be written to the console when doing a */
|
||||||
|
/* Blender.__doc__ */
|
||||||
|
/*****************************************************************************/
|
||||||
|
char Blender_Set_doc[] =
|
||||||
|
"(request, data) - Update settings in Blender\n\
|
||||||
|
\n\
|
||||||
|
(request) A string indentifying the setting to change\n\
|
||||||
|
'curframe' - Sets the current frame using the number in data";
|
||||||
|
|
||||||
|
char Blender_Get_doc[] =
|
||||||
|
"(request) - Retrieve settings from Blender\n\
|
||||||
|
\n\
|
||||||
|
(request) A string indentifying the data to be returned\n\
|
||||||
|
'curframe' - Returns the current animation frame\n\
|
||||||
|
'curtime' - Returns the current animation time\n\
|
||||||
|
'staframe' - Returns the start frame of the animation\n\
|
||||||
|
'endframe' - Returns the end frame of the animation\n\
|
||||||
|
'filename' - Returns the name of the last file read or written\n\
|
||||||
|
'version' - Returns the Blender version number";
|
||||||
|
|
||||||
|
char Blender_Redraw_doc[] = "() - Redraw all 3D windows";
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Python method structure definition. */
|
||||||
|
/*****************************************************************************/
|
||||||
|
struct PyMethodDef Blender_methods[] = {
|
||||||
|
{"Set", &Blender_Set, METH_VARARGS, Blender_Set_doc},
|
||||||
|
{"Get", &Blender_Get, METH_VARARGS, Blender_Get_doc},
|
||||||
|
{"Redraw", &Blender_Redraw, METH_VARARGS, Blender_Redraw_doc},
|
||||||
|
{NULL, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* EXPP_BLENDER_H */
|
@@ -29,150 +29,268 @@
|
|||||||
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Python.h>
|
#include "Object.h"
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include <BKE_global.h>
|
|
||||||
#include <BKE_main.h>
|
|
||||||
#include <DNA_ika_types.h>
|
|
||||||
#include <DNA_object_types.h>
|
|
||||||
|
|
||||||
#include "gen_utils.h"
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Python API function prototypes for the Blender module. */
|
/* Function: M_Object_New */
|
||||||
/*****************************************************************************/
|
|
||||||
PyObject *Object_New(PyObject *self, PyObject *args);
|
|
||||||
PyObject *Object_Get(PyObject *self, PyObject *args);
|
|
||||||
PyObject *Object_GetSelected (PyObject *self, PyObject *args);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/* The following string definitions are used for documentation strings. */
|
|
||||||
/* In Python these will be written to the console when doing a */
|
|
||||||
/* Blender.__doc__ */
|
|
||||||
/*****************************************************************************/
|
|
||||||
char Object_New_doc[] =
|
|
||||||
"(type) - Add a new object of type 'type' in the current scene";
|
|
||||||
|
|
||||||
char Object_Get_doc[] =
|
|
||||||
"(name) - return the object with the name 'name', returns None if not\
|
|
||||||
found.\n\
|
|
||||||
If 'name' is not specified, it returns a list of all objects in the\n\
|
|
||||||
current scene.";
|
|
||||||
|
|
||||||
char Object_GetSelected_doc[] =
|
|
||||||
"() - Returns a list of selected Objects in the active layer(s)\n\
|
|
||||||
The active object is the first in the list, if visible";
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/* Python BlenderObject structure definition. */
|
|
||||||
/*****************************************************************************/
|
|
||||||
typedef struct {
|
|
||||||
PyObject_HEAD
|
|
||||||
struct Object *object;
|
|
||||||
} BlenObject;
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/* PythonTypeObject callback function prototypes */
|
|
||||||
/*****************************************************************************/
|
|
||||||
void ObjectDeAlloc (BlenObject *obj);
|
|
||||||
PyObject* ObjectGetAttr (BlenObject *obj, char *name);
|
|
||||||
int ObjectSetAttr (BlenObject *obj, char *name, PyObject *v);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/* Python TypeObject structure definition. */
|
|
||||||
/*****************************************************************************/
|
|
||||||
static PyTypeObject object_type =
|
|
||||||
{
|
|
||||||
PyObject_HEAD_INIT(&PyType_Type)
|
|
||||||
0, /* ob_size */
|
|
||||||
"Object", /* tp_name */
|
|
||||||
sizeof (BlenObject), /* tp_basicsize */
|
|
||||||
0, /* tp_itemsize */
|
|
||||||
/* methods */
|
|
||||||
(destructor)ObjectDeAlloc, /* tp_dealloc */
|
|
||||||
0, /* tp_print */
|
|
||||||
(getattrfunc)ObjectGetAttr, /* tp_getattr */
|
|
||||||
(setattrfunc)ObjectSetAttr, /* tp_setattr */
|
|
||||||
0, /* tp_compare */
|
|
||||||
0, /* tp_repr */
|
|
||||||
0, /* tp_as_number */
|
|
||||||
0, /* tp_as_sequence */
|
|
||||||
0, /* tp_as_mapping */
|
|
||||||
0, /* tp_as_hash */
|
|
||||||
};
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/* Python method structure definition. */
|
|
||||||
/*****************************************************************************/
|
|
||||||
struct PyMethodDef Object_methods[] = {
|
|
||||||
{"New", Object_New, METH_VARARGS, Object_New_doc},
|
|
||||||
{"Get", Object_Get, METH_VARARGS, Object_Get_doc},
|
|
||||||
{"get", Object_Get, METH_VARARGS, Object_Get_doc},
|
|
||||||
{"getSelected", Object_GetSelected, METH_VARARGS, Object_GetSelected_doc},
|
|
||||||
{NULL, NULL}
|
|
||||||
};
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/* Function: Object_New */
|
|
||||||
/* Python equivalent: Blender.Object.New */
|
/* Python equivalent: Blender.Object.New */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
PyObject *Object_New(PyObject *self, PyObject *args)
|
PyObject *M_Object_New(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
printf ("In Object_New()\n");
|
struct Object * object;
|
||||||
return (Py_None);
|
C_BlenObject * blen_object;
|
||||||
|
int type;
|
||||||
|
char name[32];
|
||||||
|
|
||||||
|
printf ("In Object_New()\n");
|
||||||
|
|
||||||
|
if (!PyArg_ParseTuple(args, "i", &type))
|
||||||
|
{
|
||||||
|
PythonReturnErrorObject (PyExc_TypeError,
|
||||||
|
"type expected");
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create a new object. */
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case OB_MESH: strcpy (name, "Mesh"); break;
|
||||||
|
case OB_CURVE: strcpy (name, "Curve"); break;
|
||||||
|
case OB_SURF: strcpy (name, "Surf"); break;
|
||||||
|
case OB_FONT: strcpy (name, "Text"); break;
|
||||||
|
case OB_MBALL: strcpy (name, "Mball"); break;
|
||||||
|
case OB_CAMERA: strcpy (name, "Camera"); break;
|
||||||
|
case OB_LAMP: strcpy (name, "Lamp"); break;
|
||||||
|
case OB_IKA: strcpy (name, "Ika"); break;
|
||||||
|
case OB_LATTICE: strcpy (name, "Lattice"); break;
|
||||||
|
case OB_WAVE: strcpy (name, "Wave"); break;
|
||||||
|
case OB_ARMATURE: strcpy (name, "Armature"); break;
|
||||||
|
default: strcpy (name, "Empty");
|
||||||
|
}
|
||||||
|
|
||||||
|
object = alloc_libblock (&(G.main->object), ID_OB, name);
|
||||||
|
|
||||||
|
object->flag = 0;
|
||||||
|
object->type = type;
|
||||||
|
|
||||||
|
/* transforms */
|
||||||
|
QuatOne(object->quat);
|
||||||
|
QuatOne(object->dquat);
|
||||||
|
|
||||||
|
object->col[3]= 1.0; // alpha
|
||||||
|
|
||||||
|
object->size[0] = object->size[1] = object->size[2] = 1.0;
|
||||||
|
object->loc[0] = object->loc[1] = object->loc[2] = 0.0;
|
||||||
|
Mat4One(object->parentinv);
|
||||||
|
Mat4One(object->obmat);
|
||||||
|
object->dt = OB_SHADED; // drawtype
|
||||||
|
|
||||||
|
if (U.flag & MAT_ON_OB)
|
||||||
|
{
|
||||||
|
object->colbits = -1;
|
||||||
|
}
|
||||||
|
switch (object->type)
|
||||||
|
{
|
||||||
|
case OB_CAMERA: /* fall through. */
|
||||||
|
case OB_LAMP:
|
||||||
|
object->trackflag = OB_NEGZ;
|
||||||
|
object->upflag = OB_POSY;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
object->trackflag = OB_POSY;
|
||||||
|
object->upflag = OB_POSZ;
|
||||||
|
}
|
||||||
|
object->ipoflag = OB_OFFS_OB + OB_OFFS_PARENT;
|
||||||
|
|
||||||
|
/* duplivert settings */
|
||||||
|
object->dupon = 1;
|
||||||
|
object->dupoff = 0;
|
||||||
|
object->dupsta = 1;
|
||||||
|
object->dupend = 100;
|
||||||
|
|
||||||
|
/* Gameengine defaults*/
|
||||||
|
object->mass = 1.0;
|
||||||
|
object->inertia = 1.0;
|
||||||
|
object->formfactor = 0.4;
|
||||||
|
object->damping = 0.04;
|
||||||
|
object->rdamping = 0.1;
|
||||||
|
object->anisotropicFriction[0] = 1.0;
|
||||||
|
object->anisotropicFriction[1] = 1.0;
|
||||||
|
object->anisotropicFriction[2] = 1.0;
|
||||||
|
object->gameflag = OB_PROP;
|
||||||
|
|
||||||
|
object->lay = 1; // Layer, by default visible
|
||||||
|
|
||||||
|
switch(type)
|
||||||
|
{
|
||||||
|
case OB_MESH:
|
||||||
|
object->data = add_mesh();
|
||||||
|
G.totmesh++;
|
||||||
|
break;
|
||||||
|
case OB_CAMERA:
|
||||||
|
object->data = add_camera();
|
||||||
|
break;
|
||||||
|
case OB_LAMP:
|
||||||
|
object->data = add_lamp();
|
||||||
|
G.totlamp++;
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* TODO the following types will be supported later
|
||||||
|
case OB_CURVE:
|
||||||
|
object->data = add_curve(OB_CURVE);
|
||||||
|
G.totcurve++;
|
||||||
|
break;
|
||||||
|
case OB_SURF:
|
||||||
|
object->data = add_curve(OB_SURF);
|
||||||
|
G.totcurve++;
|
||||||
|
break;
|
||||||
|
case OB_FONT:
|
||||||
|
object->data = add_curve(OB_FONT);
|
||||||
|
break;
|
||||||
|
case OB_MBALL:
|
||||||
|
object->data = add_mball();
|
||||||
|
break;
|
||||||
|
case OB_IKA:
|
||||||
|
object->data = add_ika();
|
||||||
|
object->dt = OB_WIRE;
|
||||||
|
break;
|
||||||
|
case OB_LATTICE:
|
||||||
|
object->data = (void *)add_lattice();
|
||||||
|
object->dt = OB_WIRE;
|
||||||
|
break;
|
||||||
|
case OB_WAVE:
|
||||||
|
object->data = add_wave();
|
||||||
|
break;
|
||||||
|
case OB_ARMATURE:
|
||||||
|
object->data = add_armature();
|
||||||
|
break;
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
G.totobj++;
|
||||||
|
|
||||||
|
/* Create a Python object from it. */
|
||||||
|
blen_object = (C_BlenObject*)PyObject_NEW (C_BlenObject, &object_type);
|
||||||
|
blen_object->object = object;
|
||||||
|
|
||||||
|
return ((PyObject*)blen_object);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: Object_Get */
|
/* Function: M_Object_Get */
|
||||||
/* Python equivalent: Blender.Object.Get */
|
/* Python equivalent: Blender.Object.Get */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
PyObject *Object_Get(PyObject *self, PyObject *args)
|
PyObject *M_Object_Get(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
char * name;
|
struct Object * object;
|
||||||
PyObject * arg;
|
char * name;
|
||||||
struct Object * object;
|
|
||||||
BlenObject * blen_object;
|
|
||||||
|
|
||||||
printf ("In Object_Get()\n");
|
printf ("In Object_Get()\n");
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "O", &arg))
|
PyArg_ParseTuple(args, "|s", &name);
|
||||||
{
|
|
||||||
/* We expected a string as an argument, but we didn't get one. */
|
|
||||||
return (PythonReturnErrorObject (PyExc_AttributeError,
|
|
||||||
"expected string argument"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!PyString_Check (arg))
|
if (name != NULL)
|
||||||
{
|
{
|
||||||
return (PythonReturnErrorObject (PyExc_AttributeError,
|
C_BlenObject * blen_object;
|
||||||
"expected string argument"));
|
|
||||||
}
|
|
||||||
|
|
||||||
name = PyString_AsString (arg);
|
object = GetObjectByName (name);
|
||||||
object = GetObjectByName (name);
|
|
||||||
|
|
||||||
if (object == NULL)
|
if (object == NULL)
|
||||||
{
|
{
|
||||||
/* No object exists with the name specified in the argument name. */
|
/* No object exists with the name specified in the argument name. */
|
||||||
return (PythonReturnErrorObject (PyExc_AttributeError,
|
return (PythonReturnErrorObject (PyExc_AttributeError,
|
||||||
"Unknown object specified."));
|
"Unknown object specified."));
|
||||||
}
|
}
|
||||||
blen_object = (BlenObject*)PyObject_NEW (BlenObject, &object_type);
|
blen_object = (C_BlenObject*)PyObject_NEW (C_BlenObject, &object_type);
|
||||||
blen_object->object = object;
|
blen_object->object = object;
|
||||||
|
|
||||||
return ((PyObject*)blen_object);
|
return ((PyObject*)blen_object);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* No argument has been given. Return a list of all objects by name. */
|
||||||
|
PyObject * obj_list;
|
||||||
|
ID * id_iter;
|
||||||
|
int index = 0;
|
||||||
|
|
||||||
|
obj_list = PyList_New (BLI_countlist (&(G.main->object)));
|
||||||
|
|
||||||
|
if (obj_list == NULL)
|
||||||
|
{
|
||||||
|
return (PythonReturnErrorObject (PyExc_SystemError,
|
||||||
|
"List creation failed."));
|
||||||
|
}
|
||||||
|
|
||||||
|
object = G.main->object.first;
|
||||||
|
id_iter = &(object->id);
|
||||||
|
while (id_iter)
|
||||||
|
{
|
||||||
|
PyObject * object;
|
||||||
|
|
||||||
|
object = PyString_FromString (GetIdName (id_iter));
|
||||||
|
if (object == NULL)
|
||||||
|
{
|
||||||
|
return (PythonReturnErrorObject (PyExc_SystemError,
|
||||||
|
"Python string creation failed."));
|
||||||
|
}
|
||||||
|
PyList_SetItem (obj_list, index, object);
|
||||||
|
id_iter = id_iter->next;
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
return (obj_list);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: Object_GetSelected */
|
/* Function: M_Object_GetSelected */
|
||||||
/* Python equivalent: Blender.Object.getSelected */
|
/* Python equivalent: Blender.Object.getSelected */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
PyObject *Object_GetSelected (PyObject *self, PyObject *args)
|
PyObject *M_Object_GetSelected (PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
printf ("In Object_GetSelected()\n");
|
C_BlenObject * blen_object;
|
||||||
|
PyObject * list;
|
||||||
|
Base * base_iter;
|
||||||
|
|
||||||
return (Py_None);
|
printf ("In Object_GetSelected()\n");
|
||||||
|
|
||||||
|
list = PyList_New (0);
|
||||||
|
if ((G.scene->basact) &&
|
||||||
|
((G.scene->basact->flag & SELECT) &&
|
||||||
|
(G.scene->basact->lay & G.vd->lay)))
|
||||||
|
{
|
||||||
|
/* Active object is first in the list. */
|
||||||
|
blen_object = (C_BlenObject*)PyObject_NEW (C_BlenObject, &object_type);
|
||||||
|
if (blen_object == NULL)
|
||||||
|
{
|
||||||
|
Py_DECREF (list);
|
||||||
|
Py_INCREF (Py_None);
|
||||||
|
return (Py_None);
|
||||||
|
}
|
||||||
|
blen_object->object = G.scene->basact->object;
|
||||||
|
PyList_Append (list, (PyObject*)blen_object);
|
||||||
|
}
|
||||||
|
|
||||||
|
base_iter = G.scene->base.first;
|
||||||
|
while (base_iter)
|
||||||
|
{
|
||||||
|
if (((G.scene->basact->flag & SELECT) &&
|
||||||
|
(G.scene->basact->lay & G.vd->lay)) &&
|
||||||
|
(base_iter != G.scene->basact))
|
||||||
|
{
|
||||||
|
blen_object = (C_BlenObject*)PyObject_NEW (C_BlenObject,
|
||||||
|
&object_type);
|
||||||
|
if (blen_object == NULL)
|
||||||
|
{
|
||||||
|
Py_DECREF (list);
|
||||||
|
Py_INCREF (Py_None);
|
||||||
|
return (Py_None);
|
||||||
|
}
|
||||||
|
blen_object->object = base_iter->object;
|
||||||
|
PyList_Append (list, (PyObject*)blen_object);
|
||||||
|
}
|
||||||
|
base_iter = base_iter->next;
|
||||||
|
}
|
||||||
|
return (list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -180,13 +298,13 @@ PyObject *Object_GetSelected (PyObject *self, PyObject *args)
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
PyObject *initObject (void)
|
PyObject *initObject (void)
|
||||||
{
|
{
|
||||||
PyObject * module;
|
PyObject * module;
|
||||||
|
|
||||||
printf ("In initObject()\n");
|
printf ("In initObject()\n");
|
||||||
|
|
||||||
module = Py_InitModule("Object", Object_methods);
|
module = Py_InitModule3("Object", M_Object_methods, M_Object_doc);
|
||||||
|
|
||||||
return (module);
|
return (module);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -196,16 +314,18 @@ PyObject *initObject (void)
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
PyObject* ObjectCreatePyObject (struct Object *obj)
|
PyObject* ObjectCreatePyObject (struct Object *obj)
|
||||||
{
|
{
|
||||||
BlenObject * blen_object;
|
C_BlenObject * blen_object;
|
||||||
|
|
||||||
printf ("In ObjectCreatePyObject\n");
|
printf ("In ObjectCreatePyObject\n");
|
||||||
|
|
||||||
blen_object = (BlenObject*)PyObject_NEW
|
blen_object = (C_BlenObject*)PyObject_NEW (C_BlenObject, &object_type);
|
||||||
(BlenObject,
|
|
||||||
&object_type);
|
|
||||||
|
|
||||||
blen_object->object = obj;
|
if (blen_object == NULL)
|
||||||
return ((PyObject*)blen_object);
|
{
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
blen_object->object = obj;
|
||||||
|
return ((PyObject*)blen_object);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -213,9 +333,9 @@ PyObject* ObjectCreatePyObject (struct Object *obj)
|
|||||||
/* Description: This is a callback function for the BlenObject type. It is */
|
/* Description: This is a callback function for the BlenObject type. It is */
|
||||||
/* the destructor function. */
|
/* the destructor function. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void ObjectDeAlloc (BlenObject *obj)
|
void ObjectDeAlloc (C_BlenObject *obj)
|
||||||
{
|
{
|
||||||
PyObject_DEL (obj);
|
PyObject_DEL (obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -224,147 +344,121 @@ void ObjectDeAlloc (BlenObject *obj)
|
|||||||
/* the function that retrieves any value from Blender and */
|
/* the function that retrieves any value from Blender and */
|
||||||
/* passes it to Python. */
|
/* passes it to Python. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
PyObject* ObjectGetAttr (BlenObject *obj, char *name)
|
PyObject* ObjectGetAttr (C_BlenObject *obj, char *name)
|
||||||
{
|
{
|
||||||
struct Object * object;
|
struct Object * object;
|
||||||
struct Ika * ika;
|
struct Ika * ika;
|
||||||
|
|
||||||
object = obj->object;
|
object = obj->object;
|
||||||
if (StringEqual (name, "LocX"))
|
if (StringEqual (name, "LocX"))
|
||||||
return (PyFloat_FromDouble(object->loc[0]));
|
return (PyFloat_FromDouble(object->loc[0]));
|
||||||
if (StringEqual (name, "LocY"))
|
if (StringEqual (name, "LocY"))
|
||||||
return (PyFloat_FromDouble(object->loc[1]));
|
return (PyFloat_FromDouble(object->loc[1]));
|
||||||
if (StringEqual (name, "LocZ"))
|
if (StringEqual (name, "LocZ"))
|
||||||
return (PyFloat_FromDouble(object->loc[2]));
|
return (PyFloat_FromDouble(object->loc[2]));
|
||||||
if (StringEqual (name, "loc"))
|
if (StringEqual (name, "loc"))
|
||||||
{
|
return (Py_BuildValue ("fff", object->loc[0], object->loc[1],
|
||||||
printf ("This is not implemented yet. (vector)\n");
|
object->loc[2]));
|
||||||
return (Py_None);
|
if (StringEqual (name, "dLocX"))
|
||||||
}
|
return (PyFloat_FromDouble(object->dloc[0]));
|
||||||
if (StringEqual (name, "dLocX"))
|
if (StringEqual (name, "dLocY"))
|
||||||
return (PyFloat_FromDouble(object->dloc[0]));
|
return (PyFloat_FromDouble(object->dloc[1]));
|
||||||
if (StringEqual (name, "dLocY"))
|
if (StringEqual (name, "dLocZ"))
|
||||||
return (PyFloat_FromDouble(object->dloc[1]));
|
return (PyFloat_FromDouble(object->dloc[2]));
|
||||||
if (StringEqual (name, "dLocZ"))
|
if (StringEqual (name, "dloc"))
|
||||||
return (PyFloat_FromDouble(object->dloc[2]));
|
return (Py_BuildValue ("fff", object->dloc[0], object->dloc[1],
|
||||||
if (StringEqual (name, "dloc"))
|
object->dloc[2]));
|
||||||
{
|
if (StringEqual (name, "RotX"))
|
||||||
printf ("This is not implemented yet. (vector)\n");
|
return (PyFloat_FromDouble(object->rot[0]));
|
||||||
return (Py_None);
|
if (StringEqual (name, "RotY"))
|
||||||
}
|
return (PyFloat_FromDouble(object->rot[1]));
|
||||||
if (StringEqual (name, "RotX"))
|
if (StringEqual (name, "RotZ"))
|
||||||
return (PyFloat_FromDouble(object->rot[0]));
|
return (PyFloat_FromDouble(object->rot[2]));
|
||||||
if (StringEqual (name, "RotY"))
|
if (StringEqual (name, "rot"))
|
||||||
return (PyFloat_FromDouble(object->rot[1]));
|
return (Py_BuildValue ("fff", object->rot[0], object->rot[1],
|
||||||
if (StringEqual (name, "RotZ"))
|
object->rot[2]));
|
||||||
return (PyFloat_FromDouble(object->rot[2]));
|
if (StringEqual (name, "dRotX"))
|
||||||
if (StringEqual (name, "rot"))
|
return (PyFloat_FromDouble(object->drot[0]));
|
||||||
{
|
if (StringEqual (name, "dRotY"))
|
||||||
printf ("This is not implemented yet. (vector)\n");
|
return (PyFloat_FromDouble(object->drot[1]));
|
||||||
return (Py_None);
|
if (StringEqual (name, "dRotZ"))
|
||||||
}
|
return (PyFloat_FromDouble(object->drot[2]));
|
||||||
if (StringEqual (name, "dRotX"))
|
if (StringEqual (name, "drot"))
|
||||||
return (PyFloat_FromDouble(object->drot[0]));
|
return (Py_BuildValue ("fff", object->drot[0], object->drot[1],
|
||||||
if (StringEqual (name, "dRotY"))
|
object->drot[2]));
|
||||||
return (PyFloat_FromDouble(object->drot[1]));
|
if (StringEqual (name, "SizeX"))
|
||||||
if (StringEqual (name, "dRotZ"))
|
return (PyFloat_FromDouble(object->size[0]));
|
||||||
return (PyFloat_FromDouble(object->drot[2]));
|
if (StringEqual (name, "SizeY"))
|
||||||
if (StringEqual (name, "drot"))
|
return (PyFloat_FromDouble(object->size[1]));
|
||||||
{
|
if (StringEqual (name, "SizeZ"))
|
||||||
printf ("This is not implemented yet. (vector)\n");
|
return (PyFloat_FromDouble(object->size[2]));
|
||||||
return (Py_None);
|
if (StringEqual (name, "size"))
|
||||||
}
|
return (Py_BuildValue ("fff", object->size[0], object->size[1],
|
||||||
if (StringEqual (name, "SizeX"))
|
object->size[2]));
|
||||||
return (PyFloat_FromDouble(object->size[0]));
|
if (StringEqual (name, "dSizeX"))
|
||||||
if (StringEqual (name, "SizeY"))
|
return (PyFloat_FromDouble(object->dsize[0]));
|
||||||
return (PyFloat_FromDouble(object->size[1]));
|
if (StringEqual (name, "dSizeY"))
|
||||||
if (StringEqual (name, "SizeZ"))
|
return (PyFloat_FromDouble(object->dsize[1]));
|
||||||
return (PyFloat_FromDouble(object->size[2]));
|
if (StringEqual (name, "dSizeZ"))
|
||||||
if (StringEqual (name, "size"))
|
return (PyFloat_FromDouble(object->dsize[2]));
|
||||||
{
|
if (StringEqual (name, "dsize"))
|
||||||
printf ("This is not implemented yet. (vector)\n");
|
return (Py_BuildValue ("fff", object->dsize[0], object->dsize[1],
|
||||||
return (Py_None);
|
object->dsize[2]));
|
||||||
}
|
if (strncmp (name,"Eff", 3) == 0)
|
||||||
if (StringEqual (name, "dSizeX"))
|
{
|
||||||
return (PyFloat_FromDouble(object->dsize[0]));
|
if ( (object->type == OB_IKA) && (object->data != NULL) )
|
||||||
if (StringEqual (name, "dSizeY"))
|
{
|
||||||
return (PyFloat_FromDouble(object->dsize[1]));
|
ika = object->data;
|
||||||
if (StringEqual (name, "dSizeZ"))
|
switch (name[3])
|
||||||
return (PyFloat_FromDouble(object->dsize[2]));
|
{
|
||||||
if (StringEqual (name, "dsize"))
|
case 'X':
|
||||||
{
|
return (PyFloat_FromDouble (ika->effg[0]));
|
||||||
printf ("This is not implemented yet. (vector)\n");
|
case 'Y':
|
||||||
return (Py_None);
|
return (PyFloat_FromDouble (ika->effg[1]));
|
||||||
}
|
case 'Z':
|
||||||
if (strncmp (name,"Eff", 3) == 0)
|
return (PyFloat_FromDouble (ika->effg[2]));
|
||||||
{
|
default:
|
||||||
if ( (object->type == OB_IKA) && (object->data != NULL) )
|
/* Do we need to display a sensible error message here? */
|
||||||
{
|
return (NULL);
|
||||||
ika = object->data;
|
}
|
||||||
switch (name[3])
|
}
|
||||||
{
|
return (NULL);
|
||||||
case 'X':
|
}
|
||||||
return (PyFloat_FromDouble (ika->effg[0]));
|
if (StringEqual (name, "Layer"))
|
||||||
case 'Y':
|
return (PyInt_FromLong(object->lay));
|
||||||
return (PyFloat_FromDouble (ika->effg[1]));
|
if (StringEqual (name, "parent"))
|
||||||
case 'Z':
|
return (ObjectCreatePyObject (object->parent));
|
||||||
return (PyFloat_FromDouble (ika->effg[2]));
|
if (StringEqual (name, "track"))
|
||||||
default:
|
return (ObjectCreatePyObject (object->track));
|
||||||
/* Do we need to display a sensible error message here? */
|
if (StringEqual (name, "data"))
|
||||||
return (NULL);
|
{
|
||||||
}
|
printf ("This is not implemented yet.\n");
|
||||||
}
|
return (Py_None);
|
||||||
return (NULL);
|
}
|
||||||
}
|
if (StringEqual (name, "ipo"))
|
||||||
if (StringEqual (name, "Layer"))
|
{
|
||||||
return (PyInt_FromLong(object->lay));
|
printf ("This is not implemented yet.\n");
|
||||||
if (StringEqual (name, "parent"))
|
return (Py_None);
|
||||||
{
|
}
|
||||||
printf ("This is not implemented yet.\n");
|
if (StringEqual (name, "mat"))
|
||||||
return (Py_None);
|
{
|
||||||
}
|
printf ("This is not implemented yet. (matrix)\n");
|
||||||
if (StringEqual (name, "track"))
|
return (Py_None);
|
||||||
{
|
}
|
||||||
printf ("This is not implemented yet.\n");
|
if (StringEqual (name, "matrix"))
|
||||||
return (Py_None);
|
{
|
||||||
}
|
printf ("This is not implemented yet. (matrix)\n");
|
||||||
if (StringEqual (name, "data"))
|
return (Py_None);
|
||||||
{
|
}
|
||||||
printf ("This is not implemented yet.\n");
|
if (StringEqual (name, "colbits"))
|
||||||
return (Py_None);
|
return (Py_BuildValue ("h", object->colbits));
|
||||||
}
|
if (StringEqual (name, "drawType"))
|
||||||
if (StringEqual (name, "ipo"))
|
return (Py_BuildValue ("b", object->dt));
|
||||||
{
|
if (StringEqual (name, "drawMode"))
|
||||||
printf ("This is not implemented yet.\n");
|
return (Py_BuildValue ("b", object->dtx));
|
||||||
return (Py_None);
|
|
||||||
}
|
printf ("Unknown variable.\n");
|
||||||
if (StringEqual (name, "mat"))
|
return (Py_None);
|
||||||
{
|
|
||||||
printf ("This is not implemented yet. (matrix)\n");
|
|
||||||
return (Py_None);
|
|
||||||
}
|
|
||||||
if (StringEqual (name, "matrix"))
|
|
||||||
{
|
|
||||||
printf ("This is not implemented yet. (matrix)\n");
|
|
||||||
return (Py_None);
|
|
||||||
}
|
|
||||||
if (StringEqual (name, "colbits"))
|
|
||||||
{
|
|
||||||
printf ("This is not implemented yet.\n");
|
|
||||||
return (Py_None);
|
|
||||||
}
|
|
||||||
if (StringEqual (name, "drawType"))
|
|
||||||
{
|
|
||||||
printf ("This is not implemented yet.\n");
|
|
||||||
return (Py_None);
|
|
||||||
}
|
|
||||||
if (StringEqual (name, "drawMode"))
|
|
||||||
{
|
|
||||||
printf ("This is not implemented yet.\n");
|
|
||||||
return (Py_None);
|
|
||||||
}
|
|
||||||
printf ("Unknown variable.\n");
|
|
||||||
return (Py_None);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -373,147 +467,134 @@ PyObject* ObjectGetAttr (BlenObject *obj, char *name)
|
|||||||
/* the function that retrieves any value from Python and sets */
|
/* the function that retrieves any value from Python and sets */
|
||||||
/* it accordingly in Blender. */
|
/* it accordingly in Blender. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
int ObjectSetAttr (BlenObject *obj, char *name, PyObject *value)
|
int ObjectSetAttr (C_BlenObject *obj, char *name, PyObject *value)
|
||||||
{
|
{
|
||||||
struct Object * object;
|
struct Object * object;
|
||||||
struct Ika * ika;
|
struct Ika * ika;
|
||||||
|
|
||||||
object = obj->object;
|
object = obj->object;
|
||||||
if (StringEqual (name, "LocX"))
|
if (StringEqual (name, "LocX"))
|
||||||
return (!PyArg_Parse (value, "f", &(object->loc[0])));
|
return (!PyArg_Parse (value, "f", &(object->loc[0])));
|
||||||
if (StringEqual (name, "LocY"))
|
if (StringEqual (name, "LocY"))
|
||||||
return (!PyArg_Parse (value, "f", &(object->loc[1])));
|
return (!PyArg_Parse (value, "f", &(object->loc[1])));
|
||||||
if (StringEqual (name, "LocZ"))
|
if (StringEqual (name, "LocZ"))
|
||||||
return (!PyArg_Parse (value, "f", &(object->loc[2])));
|
return (!PyArg_Parse (value, "f", &(object->loc[2])));
|
||||||
if (StringEqual (name, "loc"))
|
if (StringEqual (name, "loc"))
|
||||||
{
|
return (!PyArg_Parse (value, "fff", &(object->loc[0]),
|
||||||
printf ("This is not implemented yet. (vector)\n");
|
&(object->loc[1]), &(object->loc[2])));
|
||||||
return (0);
|
if (StringEqual (name, "dLocX"))
|
||||||
}
|
return (!PyArg_Parse (value, "f", &(object->dloc[0])));
|
||||||
if (StringEqual (name, "dLocX"))
|
if (StringEqual (name, "dLocY"))
|
||||||
return (!PyArg_Parse (value, "f", &(object->dloc[0])));
|
return (!PyArg_Parse (value, "f", &(object->dloc[1])));
|
||||||
if (StringEqual (name, "dLocY"))
|
if (StringEqual (name, "dLocZ"))
|
||||||
return (!PyArg_Parse (value, "f", &(object->dloc[1])));
|
return (!PyArg_Parse (value, "f", &(object->dloc[2])));
|
||||||
if (StringEqual (name, "dLocZ"))
|
if (StringEqual (name, "dloc"))
|
||||||
return (!PyArg_Parse (value, "f", &(object->dloc[2])));
|
return (!PyArg_Parse (value, "fff", &(object->dloc[0]),
|
||||||
if (StringEqual (name, "dloc"))
|
&(object->dloc[1]), &(object->dloc[2])));
|
||||||
{
|
if (StringEqual (name, "RotX"))
|
||||||
printf ("This is not implemented yet. (vector)\n");
|
return (!PyArg_Parse (value, "f", &(object->rot[0])));
|
||||||
return (0);
|
if (StringEqual (name, "RotY"))
|
||||||
}
|
return (!PyArg_Parse (value, "f", &(object->rot[1])));
|
||||||
if (StringEqual (name, "RotX"))
|
if (StringEqual (name, "RotZ"))
|
||||||
return (!PyArg_Parse (value, "f", &(object->rot[0])));
|
return (!PyArg_Parse (value, "f", &(object->rot[2])));
|
||||||
if (StringEqual (name, "RotY"))
|
if (StringEqual (name, "rot"))
|
||||||
return (!PyArg_Parse (value, "f", &(object->rot[1])));
|
return (!PyArg_Parse (value, "fff", &(object->rot[0]),
|
||||||
if (StringEqual (name, "RotZ"))
|
&(object->rot[1]), &(object->rot[2])));
|
||||||
return (!PyArg_Parse (value, "f", &(object->rot[2])));
|
if (StringEqual (name, "dRotX"))
|
||||||
if (StringEqual (name, "rot"))
|
return (!PyArg_Parse (value, "f", &(object->drot[0])));
|
||||||
{
|
if (StringEqual (name, "dRotY"))
|
||||||
printf ("This is not implemented yet. (vector)\n");
|
return (!PyArg_Parse (value, "f", &(object->drot[1])));
|
||||||
return (0);
|
if (StringEqual (name, "dRotZ"))
|
||||||
}
|
return (!PyArg_Parse (value, "f", &(object->drot[2])));
|
||||||
if (StringEqual (name, "dRotX"))
|
if (StringEqual (name, "drot"))
|
||||||
return (!PyArg_Parse (value, "f", &(object->drot[0])));
|
return (!PyArg_Parse (value, "fff", &(object->drot[0]),
|
||||||
if (StringEqual (name, "dRotY"))
|
&(object->drot[1]), &(object->drot[2])));
|
||||||
return (!PyArg_Parse (value, "f", &(object->drot[1])));
|
if (StringEqual (name, "SizeX"))
|
||||||
if (StringEqual (name, "dRotZ"))
|
return (!PyArg_Parse (value, "f", &(object->size[0])));
|
||||||
return (!PyArg_Parse (value, "f", &(object->drot[2])));
|
if (StringEqual (name, "SizeY"))
|
||||||
if (StringEqual (name, "drot"))
|
return (!PyArg_Parse (value, "f", &(object->size[1])));
|
||||||
{
|
if (StringEqual (name, "SizeZ"))
|
||||||
printf ("This is not implemented yet. (vector)\n");
|
return (!PyArg_Parse (value, "f", &(object->size[2])));
|
||||||
return (0);
|
if (StringEqual (name, "size"))
|
||||||
}
|
return (!PyArg_Parse (value, "fff", &(object->size[0]),
|
||||||
if (StringEqual (name, "SizeX"))
|
&(object->size[1]), &(object->size[2])));
|
||||||
return (!PyArg_Parse (value, "f", &(object->size[0])));
|
if (StringEqual (name, "dSizeX"))
|
||||||
if (StringEqual (name, "SizeY"))
|
return (!PyArg_Parse (value, "f", &(object->dsize[0])));
|
||||||
return (!PyArg_Parse (value, "f", &(object->size[1])));
|
if (StringEqual (name, "dSizeY"))
|
||||||
if (StringEqual (name, "SizeZ"))
|
return (!PyArg_Parse (value, "f", &(object->dsize[1])));
|
||||||
return (!PyArg_Parse (value, "f", &(object->size[2])));
|
if (StringEqual (name, "dSizeZ"))
|
||||||
if (StringEqual (name, "size"))
|
return (!PyArg_Parse (value, "f", &(object->dsize[2])));
|
||||||
{
|
if (StringEqual (name, "dsize"))
|
||||||
printf ("This is not implemented yet. (vector)\n");
|
return (!PyArg_Parse (value, "fff", &(object->dsize[0]),
|
||||||
return (0);
|
&(object->dsize[1]), &(object->dsize[2])));
|
||||||
}
|
if (strncmp (name,"Eff", 3) == 0)
|
||||||
if (StringEqual (name, "dSizeX"))
|
{
|
||||||
return (!PyArg_Parse (value, "f", &(object->dsize[0])));
|
if ( (object->type == OB_IKA) && (object->data != NULL) )
|
||||||
if (StringEqual (name, "dSizeY"))
|
{
|
||||||
return (!PyArg_Parse (value, "f", &(object->dsize[1])));
|
ika = object->data;
|
||||||
if (StringEqual (name, "dSizeZ"))
|
switch (name[3])
|
||||||
return (!PyArg_Parse (value, "f", &(object->dsize[2])));
|
{
|
||||||
if (StringEqual (name, "dsize"))
|
case 'X':
|
||||||
{
|
return (!PyArg_Parse (value, "f", &(ika->effg[0])));
|
||||||
printf ("This is not implemented yet. (vector)\n");
|
case 'Y':
|
||||||
return (0);
|
return (!PyArg_Parse (value, "f", &(ika->effg[1])));
|
||||||
}
|
case 'Z':
|
||||||
if (strncmp (name,"Eff", 3) == 0)
|
return (!PyArg_Parse (value, "f", &(ika->effg[2])));
|
||||||
{
|
default:
|
||||||
if ( (object->type == OB_IKA) && (object->data != NULL) )
|
/* Do we need to display a sensible error message here? */
|
||||||
{
|
return (0);
|
||||||
ika = object->data;
|
}
|
||||||
switch (name[3])
|
}
|
||||||
{
|
return (0);
|
||||||
case 'X':
|
}
|
||||||
return (!PyArg_Parse (value, "f", &(ika->effg[0])));
|
if (StringEqual (name, "Layer"))
|
||||||
case 'Y':
|
return (!PyArg_Parse (value, "i", &(object->lay)));
|
||||||
return (!PyArg_Parse (value, "f", &(ika->effg[1])));
|
if (StringEqual (name, "parent"))
|
||||||
case 'Z':
|
{
|
||||||
return (!PyArg_Parse (value, "f", &(ika->effg[2])));
|
/* This is not allowed. */
|
||||||
default:
|
PythonReturnErrorObject (PyExc_AttributeError,
|
||||||
/* Do we need to display a sensible error message here? */
|
"Setting the parent is not allowed.");
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
}
|
if (StringEqual (name, "track"))
|
||||||
return (0);
|
{
|
||||||
}
|
/* This is not allowed. */
|
||||||
if (StringEqual (name, "Layer"))
|
PythonReturnErrorObject (PyExc_AttributeError,
|
||||||
return (!PyArg_Parse (value, "i", &(object->lay)));
|
"Setting the track is not allowed.");
|
||||||
if (StringEqual (name, "parent"))
|
return (0);
|
||||||
{
|
}
|
||||||
printf ("This is not implemented yet.\n");
|
if (StringEqual (name, "data"))
|
||||||
return (1);
|
{
|
||||||
}
|
/* This is not allowed. */
|
||||||
if (StringEqual (name, "track"))
|
PythonReturnErrorObject (PyExc_AttributeError,
|
||||||
{
|
"Setting the data is not allowed.");
|
||||||
printf ("This is not implemented yet.\n");
|
return (0);
|
||||||
return (1);
|
}
|
||||||
}
|
if (StringEqual (name, "ipo"))
|
||||||
if (StringEqual (name, "data"))
|
{
|
||||||
{
|
/* This is not allowed. */
|
||||||
printf ("This is not implemented yet.\n");
|
PythonReturnErrorObject (PyExc_AttributeError,
|
||||||
return (1);
|
"Setting the ipo is not allowed.");
|
||||||
}
|
return (0);
|
||||||
if (StringEqual (name, "ipo"))
|
}
|
||||||
{
|
if (StringEqual (name, "mat"))
|
||||||
printf ("This is not implemented yet.\n");
|
{
|
||||||
return (1);
|
printf ("This is not implemented yet. (matrix)\n");
|
||||||
}
|
return (1);
|
||||||
if (StringEqual (name, "mat"))
|
}
|
||||||
{
|
if (StringEqual (name, "matrix"))
|
||||||
printf ("This is not implemented yet. (matrix)\n");
|
{
|
||||||
return (1);
|
printf ("This is not implemented yet. (matrix)\n");
|
||||||
}
|
return (1);
|
||||||
if (StringEqual (name, "matrix"))
|
}
|
||||||
{
|
if (StringEqual (name, "colbits"))
|
||||||
printf ("This is not implemented yet. (matrix)\n");
|
return (!PyArg_Parse (value, "h", &(object->colbits)));
|
||||||
return (1);
|
if (StringEqual (name, "drawType"))
|
||||||
}
|
return (!PyArg_Parse (value, "b", &(object->dt)));
|
||||||
if (StringEqual (name, "colbits"))
|
if (StringEqual (name, "drawMode"))
|
||||||
{
|
return (!PyArg_Parse (value, "b", &(object->dtx)));
|
||||||
printf ("This is not implemented yet.\n");
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
if (StringEqual (name, "drawType"))
|
|
||||||
{
|
|
||||||
printf ("This is not implemented yet.\n");
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
if (StringEqual (name, "drawMode"))
|
|
||||||
{
|
|
||||||
printf ("This is not implemented yet.\n");
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
printf ("Unknown variable.\n");
|
printf ("Unknown variable.\n");
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
138
source/blender/python/api2_2x/Object.h
Normal file
138
source/blender/python/api2_2x/Object.h
Normal file
@@ -0,0 +1,138 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version. The Blender
|
||||||
|
* Foundation also sells licenses for use in proprietary software under
|
||||||
|
* the Blender License. See http://www.blender.org/BL/ for information
|
||||||
|
* about this.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This is a new part of Blender.
|
||||||
|
*
|
||||||
|
* Contributor(s): Michel Selten
|
||||||
|
*
|
||||||
|
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EXPP_OBJECT_H
|
||||||
|
#define EXPP_OBJECT_H
|
||||||
|
|
||||||
|
#include <Python.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <BKE_global.h>
|
||||||
|
#include <BKE_library.h>
|
||||||
|
#include <BKE_main.h>
|
||||||
|
#include <BKE_mesh.h>
|
||||||
|
#include <BKE_object.h>
|
||||||
|
#include <BLI_arithb.h>
|
||||||
|
#include <BLI_blenlib.h>
|
||||||
|
#include <DNA_ID.h>
|
||||||
|
#include <DNA_ika_types.h>
|
||||||
|
#include <DNA_listBase.h>
|
||||||
|
#include <DNA_object_types.h>
|
||||||
|
#include <DNA_scene_types.h>
|
||||||
|
#include <DNA_userdef_types.h>
|
||||||
|
#include <DNA_view3d_types.h>
|
||||||
|
|
||||||
|
#include "gen_utils.h"
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Python API function prototypes for the Blender module. */
|
||||||
|
/*****************************************************************************/
|
||||||
|
PyObject *M_Object_New(PyObject *self, PyObject *args);
|
||||||
|
PyObject *M_Object_Get(PyObject *self, PyObject *args);
|
||||||
|
PyObject *M_Object_GetSelected (PyObject *self, PyObject *args);
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* The following string definitions are used for documentation strings. */
|
||||||
|
/* In Python these will be written to the console when doing a */
|
||||||
|
/* Blender.Object.__doc__ */
|
||||||
|
/*****************************************************************************/
|
||||||
|
char M_Object_doc[] =
|
||||||
|
"The Blender Object module\n\n\
|
||||||
|
This module provides access to **Object Data** in Blender.\n";
|
||||||
|
|
||||||
|
char M_Object_New_doc[] =
|
||||||
|
"(type) - Add a new object of type 'type' in the current scene";
|
||||||
|
|
||||||
|
char M_Object_Get_doc[] =
|
||||||
|
"(name) - return the object with the name 'name', returns None if not\
|
||||||
|
found.\n\
|
||||||
|
If 'name' is not specified, it returns a list of all objects in the\n\
|
||||||
|
current scene.";
|
||||||
|
|
||||||
|
char M_Object_GetSelected_doc[] =
|
||||||
|
"() - Returns a list of selected Objects in the active layer(s)\n\
|
||||||
|
The active object is the first in the list, if visible";
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Python BlenderObject structure definition. */
|
||||||
|
/*****************************************************************************/
|
||||||
|
typedef struct {
|
||||||
|
PyObject_HEAD
|
||||||
|
PyObject *dict;
|
||||||
|
struct Object *object;
|
||||||
|
} C_BlenObject;
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* PythonTypeObject callback function prototypes */
|
||||||
|
/*****************************************************************************/
|
||||||
|
void ObjectDeAlloc (C_BlenObject *obj);
|
||||||
|
PyObject* ObjectGetAttr (C_BlenObject *obj, char *name);
|
||||||
|
int ObjectSetAttr (C_BlenObject *obj, char *name, PyObject *v);
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Python method structure definition. */
|
||||||
|
/*****************************************************************************/
|
||||||
|
struct PyMethodDef M_Object_methods[] = {
|
||||||
|
{"New", (PyCFunction)M_Object_New, METH_VARARGS,
|
||||||
|
M_Object_New_doc},
|
||||||
|
{"Get", (PyCFunction)M_Object_Get, METH_VARARGS,
|
||||||
|
M_Object_Get_doc},
|
||||||
|
{"get", (PyCFunction)M_Object_Get, METH_VARARGS,
|
||||||
|
M_Object_Get_doc},
|
||||||
|
{"getSelected", (PyCFunction)M_Object_GetSelected, METH_VARARGS,
|
||||||
|
M_Object_GetSelected_doc},
|
||||||
|
{NULL, NULL, 0, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Python TypeObject structure definition. */
|
||||||
|
/*****************************************************************************/
|
||||||
|
static PyTypeObject object_type =
|
||||||
|
{
|
||||||
|
PyObject_HEAD_INIT(&PyType_Type)
|
||||||
|
0, /* ob_size */
|
||||||
|
"Object", /* tp_name */
|
||||||
|
sizeof (C_BlenObject), /* tp_basicsize */
|
||||||
|
0, /* tp_itemsize */
|
||||||
|
/* methods */
|
||||||
|
(destructor)ObjectDeAlloc, /* tp_dealloc */
|
||||||
|
0, /* tp_print */
|
||||||
|
(getattrfunc)ObjectGetAttr, /* tp_getattr */
|
||||||
|
(setattrfunc)ObjectSetAttr, /* tp_setattr */
|
||||||
|
0, /* tp_compare */
|
||||||
|
0, /* tp_repr */
|
||||||
|
0, /* tp_as_number */
|
||||||
|
0, /* tp_as_sequence */
|
||||||
|
0, /* tp_as_mapping */
|
||||||
|
0, /* tp_as_hash */
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* EXPP_OBJECT_H */
|
@@ -38,7 +38,7 @@
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Global variables */
|
/* Global variables */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
PyObject *g_blenderdict;
|
extern PyObject *g_blenderdict;
|
||||||
|
|
||||||
void initBlender (void);
|
void initBlender (void);
|
||||||
PyObject* initObject (void);
|
PyObject* initObject (void);
|
||||||
|
Reference in New Issue
Block a user