===Python API===
Initial commit for new Modifier API. Probably does about 70-75% of what it should, but it's a start.
This commit is contained in:
@@ -75,6 +75,10 @@ extern void autocomplete_vgroup(char *str, void *arg_v);
|
|||||||
extern void effects_panels(void);
|
extern void effects_panels(void);
|
||||||
extern void do_effects_panels(unsigned short event);
|
extern void do_effects_panels(unsigned short event);
|
||||||
|
|
||||||
|
/* modifiers */
|
||||||
|
extern int mod_moveUp(void *ob_v, void *md_v);
|
||||||
|
extern int mod_moveDown(void *ob_v, void *md_v);
|
||||||
|
|
||||||
/* editing */
|
/* editing */
|
||||||
extern void editing_panels(void);
|
extern void editing_panels(void);
|
||||||
extern void do_common_editbuts(unsigned short event);
|
extern void do_common_editbuts(unsigned short event);
|
||||||
|
|||||||
1171
source/blender/python/api2_2x/Modifier.c
Normal file
1171
source/blender/python/api2_2x/Modifier.c
Normal file
File diff suppressed because it is too large
Load Diff
70
source/blender/python/api2_2x/Modifier.h
Normal file
70
source/blender/python/api2_2x/Modifier.h
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* ***** 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): Ken Hughes
|
||||||
|
*
|
||||||
|
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EXPP_MODIFIER_H
|
||||||
|
#define EXPP_MODIFIER_H
|
||||||
|
|
||||||
|
#include <Python.h>
|
||||||
|
#include "DNA_object_types.h"
|
||||||
|
#include "DNA_modifier_types.h"
|
||||||
|
#include "DNA_listBase.h"
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Python BPy_Modifier structure definition: */
|
||||||
|
/*****************************************************************************/
|
||||||
|
typedef struct {
|
||||||
|
PyObject_HEAD /* required macro */
|
||||||
|
Object *obj;
|
||||||
|
ModifierData *md;
|
||||||
|
} BPy_Modifier;
|
||||||
|
|
||||||
|
extern PyTypeObject Modifier_Type;
|
||||||
|
|
||||||
|
#define BPy_Modifier_Check(v) ((v)->ob_type == &Modifier_Type) /* for type checking */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* prototypes
|
||||||
|
*/
|
||||||
|
|
||||||
|
PyObject *Modifier_CreatePyObject( Object *obj, ModifierData *md );
|
||||||
|
ModifierData *Modifier_FromPyObject( PyObject * py_obj );
|
||||||
|
int Modifier_CheckPyObject( PyObject * py_obj );
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
PyObject_HEAD /* required macro */
|
||||||
|
Object *obj;
|
||||||
|
ModifierData *iter;
|
||||||
|
} BPy_ModSeq;
|
||||||
|
|
||||||
|
PyObject *ModSeq_CreatePyObject( Object *obj );
|
||||||
|
|
||||||
|
#endif /* EXPP_MODIFIER_H */
|
||||||
@@ -108,6 +108,7 @@ struct rctf;
|
|||||||
#include "Effect.h"
|
#include "Effect.h"
|
||||||
#include "Pose.h"
|
#include "Pose.h"
|
||||||
#include "Group.h"
|
#include "Group.h"
|
||||||
|
#include "Modifier.h"
|
||||||
#include "gen_utils.h"
|
#include "gen_utils.h"
|
||||||
#include "BIF_editkey.h"
|
#include "BIF_editkey.h"
|
||||||
|
|
||||||
@@ -3513,6 +3514,8 @@ static PyObject *Object_getAttr( BPy_Object * obj, char *name )
|
|||||||
return Object_getDupliNoSpeed( obj );
|
return Object_getDupliNoSpeed( obj );
|
||||||
if( StringEqual( name, "drawSize" ) )
|
if( StringEqual( name, "drawSize" ) )
|
||||||
return ( PyFloat_FromDouble( object->empty_drawsize ) );
|
return ( PyFloat_FromDouble( object->empty_drawsize ) );
|
||||||
|
if( StringEqual( name, "modifiers" ) )
|
||||||
|
return ModSeq_CreatePyObject( obj->object );
|
||||||
|
|
||||||
/* not an attribute, search the methods table */
|
/* not an attribute, search the methods table */
|
||||||
return Py_FindMethod( BPy_Object_methods, ( PyObject * ) obj, name );
|
return Py_FindMethod( BPy_Object_methods, ( PyObject * ) obj, name );
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ extern PyTypeObject property_Type;
|
|||||||
extern PyTypeObject buffer_Type, constant_Type, euler_Type;
|
extern PyTypeObject buffer_Type, constant_Type, euler_Type;
|
||||||
extern PyTypeObject matrix_Type, quaternion_Type, rgbTuple_Type, vector_Type;
|
extern PyTypeObject matrix_Type, quaternion_Type, rgbTuple_Type, vector_Type;
|
||||||
extern PyTypeObject point_Type;
|
extern PyTypeObject point_Type;
|
||||||
|
extern PyTypeObject Modifier_Type, ModSeq_Type;
|
||||||
|
|
||||||
char M_Types_doc[] = "The Blender Types module\n\n\
|
char M_Types_doc[] = "The Blender Types module\n\n\
|
||||||
This module is a dictionary of all Blender Python types";
|
This module is a dictionary of all Blender Python types";
|
||||||
@@ -121,6 +122,9 @@ void types_InitAll( void )
|
|||||||
vector_Type.ob_type = &PyType_Type;
|
vector_Type.ob_type = &PyType_Type;
|
||||||
property_Type.ob_type = &PyType_Type;
|
property_Type.ob_type = &PyType_Type;
|
||||||
point_Type.ob_type = &PyType_Type;
|
point_Type.ob_type = &PyType_Type;
|
||||||
|
PyType_Ready( &Modifier_Type );
|
||||||
|
PyType_Ready( &ModSeq_Type );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -223,6 +227,10 @@ PyObject *Types_Init( void )
|
|||||||
( PyObject * ) &property_Type );
|
( PyObject * ) &property_Type );
|
||||||
PyDict_SetItemString( dict, "pointType",
|
PyDict_SetItemString( dict, "pointType",
|
||||||
( PyObject * ) &point_Type );
|
( PyObject * ) &point_Type );
|
||||||
|
PyDict_SetItemString( dict, "ModifierType",
|
||||||
|
( PyObject * ) &Modifier_Type );
|
||||||
|
PyDict_SetItemString( dict, "ModSeqType",
|
||||||
|
( PyObject * ) &ModSeq_Type );
|
||||||
|
|
||||||
return submodule;
|
return submodule;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ The Blender Python API Reference
|
|||||||
-----------
|
-----------
|
||||||
- L{Armature}
|
- L{Armature}
|
||||||
- L{NLA}
|
- L{NLA}
|
||||||
- L{BezTriple}
|
- L{BezTriple} (*)
|
||||||
- L{BGL}
|
- L{BGL}
|
||||||
- L{Camera}
|
- L{Camera}
|
||||||
- L{Curve}
|
- L{Curve}
|
||||||
@@ -23,8 +23,8 @@ The Blender Python API Reference
|
|||||||
- L{Effect}
|
- L{Effect}
|
||||||
- L{Group} (*)
|
- L{Group} (*)
|
||||||
- L{Image}
|
- L{Image}
|
||||||
- L{Ipo}
|
- L{Ipo} (*)
|
||||||
- L{IpoCurve}
|
- L{IpoCurve} (*)
|
||||||
- L{Key} (*)
|
- L{Key} (*)
|
||||||
- L{Lamp}
|
- L{Lamp}
|
||||||
- L{Lattice}
|
- L{Lattice}
|
||||||
@@ -33,6 +33,7 @@ The Blender Python API Reference
|
|||||||
- L{Mathutils} (*)
|
- L{Mathutils} (*)
|
||||||
- L{Mesh} (*)
|
- L{Mesh} (*)
|
||||||
- L{Metaball}
|
- L{Metaball}
|
||||||
|
- L{Modifier} (*)
|
||||||
- L{NMesh} (*)
|
- L{NMesh} (*)
|
||||||
- L{Noise}
|
- L{Noise}
|
||||||
- L{Object} (*)
|
- L{Object} (*)
|
||||||
|
|||||||
122
source/blender/python/api2_2x/doc/Modifier.py
Normal file
122
source/blender/python/api2_2x/doc/Modifier.py
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
# Blender.Modifier module and the Modifier PyType object
|
||||||
|
|
||||||
|
"""
|
||||||
|
The Blender.Modifier submodule
|
||||||
|
|
||||||
|
B{New}:
|
||||||
|
- provides access to Blender's modifier stack
|
||||||
|
|
||||||
|
This module provides access to the Modifier Data in Blender.
|
||||||
|
|
||||||
|
Example::
|
||||||
|
from Blender import *
|
||||||
|
|
||||||
|
ob = Object.Get('Cube') # retrieve an object
|
||||||
|
mods = ob.modifiers # get the object's modifiers
|
||||||
|
for mod in mods:
|
||||||
|
print mod,mod.name # print each modifier and its name
|
||||||
|
mod = mods.append(mod.SUBSURF) # add a new subsurf modifier
|
||||||
|
mod[mod.keys().LEVELS] = 3 # set subsurf subdivision levels to 3
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class ModSeq:
|
||||||
|
"""
|
||||||
|
The ModSeq object
|
||||||
|
=================
|
||||||
|
This object provides access to list of modifiers for a particular object.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __getitem__(index):
|
||||||
|
"""
|
||||||
|
This operator returns one of the object's modifiers.
|
||||||
|
@type index: int
|
||||||
|
@return: an Modifier object
|
||||||
|
@rtype: Modifier
|
||||||
|
@raise KeyError: index was out of range
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __len__():
|
||||||
|
"""
|
||||||
|
Returns the number of modifiers in the object's modifier stack.
|
||||||
|
@return: number of Modifiers
|
||||||
|
@rtype: int
|
||||||
|
"""
|
||||||
|
|
||||||
|
def append(type):
|
||||||
|
"""
|
||||||
|
Appends a new modifier to the end of the object's modifier stack.
|
||||||
|
@type type: a constant specifying the type of modifier to create
|
||||||
|
@rtype: Modifier
|
||||||
|
@return: the new Modifier
|
||||||
|
"""
|
||||||
|
|
||||||
|
class Modifier:
|
||||||
|
"""
|
||||||
|
The Modifier object
|
||||||
|
===================
|
||||||
|
This object provides access to a modifier for a particular object.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __getitem__(key):
|
||||||
|
"""
|
||||||
|
This operator returns one of the modifier's data attributes.
|
||||||
|
@type key: value from modifier's L{key()} constant
|
||||||
|
@return: the requested data
|
||||||
|
@rtype: varies
|
||||||
|
@raise KeyError: the key does not exist for the modifier
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __setitem__(key):
|
||||||
|
"""
|
||||||
|
This operator modifiers one of the modifier's data attributes.
|
||||||
|
@type key: value from modifier's L{key()} constant
|
||||||
|
@raise KeyError: the key does not exist for the modifier
|
||||||
|
"""
|
||||||
|
|
||||||
|
def up():
|
||||||
|
"""
|
||||||
|
Moves the modifier up in the object's modifier stack.
|
||||||
|
@rtype: PyNone
|
||||||
|
@raise RuntimeError: request to move above another modifier requiring
|
||||||
|
original data
|
||||||
|
"""
|
||||||
|
|
||||||
|
def down():
|
||||||
|
"""
|
||||||
|
Moves the modifier down in the object's modifier stack.
|
||||||
|
@rtype: PyNone
|
||||||
|
@raise RuntimeError: request to move modifier beyond a non-deforming
|
||||||
|
modifier
|
||||||
|
"""
|
||||||
|
|
||||||
|
def keys():
|
||||||
|
"""
|
||||||
|
Get the sequence of keys for the modifier.
|
||||||
|
For example, a subsurf modifier can be accessed by::
|
||||||
|
from Blender import *
|
||||||
|
|
||||||
|
ob = Object.Get('Cube') # retrieve an object
|
||||||
|
mod = ob.modifiers[0] # get the object's modifiers
|
||||||
|
mod[mod.keys().LEVELS] = 3 # set subsurf subdivision levels to 3
|
||||||
|
|
||||||
|
The valid keys are:
|
||||||
|
- Common keys (all modifiers contain these keys): RENDER, REALTIME,
|
||||||
|
EDITMODE, ONCAGE
|
||||||
|
- Armature keys: ENVELOPES, OBJECT, VERTGROUPS
|
||||||
|
- Boolean keys: OBJECT, OPERATION
|
||||||
|
- Build keys: START, LENGTH, SEED, RANDOMIZE
|
||||||
|
- Curve keys: OBJECT, VERTGROUP
|
||||||
|
- Decimate keys: RATIO, FACE_COUNT
|
||||||
|
- Lattice keys: OBJECT, VERTGROUP
|
||||||
|
- Mirror keys: LIMIT, FLAG, AXIS
|
||||||
|
- Subsurf keys: TYPE, LEVELS, RENDER_LEVELS, OPTIMAL, UV
|
||||||
|
- Wave keys: START_X, START_Y, HEIGHT, WIDTH, NARROW, SPEED, DAMP,
|
||||||
|
LIFETIME, TIME_OFFS, FLAG
|
||||||
|
|
||||||
|
@rtype: PyConstant
|
||||||
|
@return: the keys for the modifier
|
||||||
|
@raise RuntimeError: request to move modifier beyond a non-deforming
|
||||||
|
modifier
|
||||||
|
"""
|
||||||
|
|
||||||
@@ -812,7 +812,7 @@ static void modifiers_del(void *ob_v, void *md_v)
|
|||||||
BIF_undo_push("Del modifier");
|
BIF_undo_push("Del modifier");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void modifiers_moveUp(void *ob_v, void *md_v)
|
int mod_moveUp(void *ob_v, void *md_v)
|
||||||
{
|
{
|
||||||
Object *ob = ob_v;
|
Object *ob = ob_v;
|
||||||
ModifierData *md = md_v;
|
ModifierData *md = md_v;
|
||||||
@@ -823,20 +823,26 @@ static void modifiers_moveUp(void *ob_v, void *md_v)
|
|||||||
if (mti->type!=eModifierTypeType_OnlyDeform) {
|
if (mti->type!=eModifierTypeType_OnlyDeform) {
|
||||||
ModifierTypeInfo *nmti = modifierType_getInfo(md->prev->type);
|
ModifierTypeInfo *nmti = modifierType_getInfo(md->prev->type);
|
||||||
|
|
||||||
if (nmti->flags&eModifierTypeFlag_RequiresOriginalData) {
|
if (nmti->flags&eModifierTypeFlag_RequiresOriginalData)
|
||||||
error("Cannot move above a modifier requiring original data.");
|
return -1;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BLI_remlink(&ob->modifiers, md);
|
BLI_remlink(&ob->modifiers, md);
|
||||||
BLI_insertlink(&ob->modifiers, md->prev->prev, md);
|
BLI_insertlink(&ob->modifiers, md->prev->prev, md);
|
||||||
}
|
}
|
||||||
|
|
||||||
BIF_undo_push("Move modifier");
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void modifiers_moveDown(void *ob_v, void *md_v)
|
static void modifiers_moveUp(void *ob_v, void *md_v)
|
||||||
|
{
|
||||||
|
if( mod_moveUp( ob_v, md_v ) )
|
||||||
|
error("Cannot move above a modifier requiring original data.");
|
||||||
|
else
|
||||||
|
BIF_undo_push("Move modifier");
|
||||||
|
}
|
||||||
|
|
||||||
|
int mod_moveDown(void *ob_v, void *md_v)
|
||||||
{
|
{
|
||||||
Object *ob = ob_v;
|
Object *ob = ob_v;
|
||||||
ModifierData *md = md_v;
|
ModifierData *md = md_v;
|
||||||
@@ -847,17 +853,23 @@ static void modifiers_moveDown(void *ob_v, void *md_v)
|
|||||||
if (mti->flags&eModifierTypeFlag_RequiresOriginalData) {
|
if (mti->flags&eModifierTypeFlag_RequiresOriginalData) {
|
||||||
ModifierTypeInfo *nmti = modifierType_getInfo(md->next->type);
|
ModifierTypeInfo *nmti = modifierType_getInfo(md->next->type);
|
||||||
|
|
||||||
if (nmti->type!=eModifierTypeType_OnlyDeform) {
|
if (nmti->type!=eModifierTypeType_OnlyDeform)
|
||||||
error("Cannot move beyond a non-deforming modifier.");
|
return -1;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BLI_remlink(&ob->modifiers, md);
|
BLI_remlink(&ob->modifiers, md);
|
||||||
BLI_insertlink(&ob->modifiers, md->next, md);
|
BLI_insertlink(&ob->modifiers, md->next, md);
|
||||||
}
|
}
|
||||||
|
|
||||||
BIF_undo_push("Move modifier");
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void modifiers_moveDown(void *ob_v, void *md_v)
|
||||||
|
{
|
||||||
|
if( mod_moveDown( ob_v, md_v ) )
|
||||||
|
error("Cannot move beyond a non-deforming modifier.");
|
||||||
|
else
|
||||||
|
BIF_undo_push("Move modifier");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void modifier_testLatticeObj(char *name, ID **idpp)
|
static void modifier_testLatticeObj(char *name, ID **idpp)
|
||||||
|
|||||||
Reference in New Issue
Block a user