[Bf-python] Modifiers syntax

Campbell Barton cbarton at metavr.com
Sun Apr 23 11:48:35 CEST 2006


Since were using getitem/setitem anyhow.

mod[mod.keys().LEVELS] = 3     # set subsurf subdivision levels to 3
   ...couldent we just use
mod["LEVELS"] = 3     # set subsurf subdivision levels to 3
   ...and return a key error if the attribute dosent exist exist for that modifier?

Also, Id also prefer strings for append.
ob.modifiers.append("SUBSURF")

- Cam
 



jmsoler at free.fr wrote:
> Selon jean-michel soler <jmsoler at free.fr>:
>
>   
>> It seems that it does not compile :
>>
>> Compiling ==> 'Modifier.c'
>> Modifier.c
>> source\blender\python\api2_2x\Modifier.c(271) : warning C4047: 'return'
>> : 'int' differs in levels of indirection from 'PyObject *'
>> source\blender\python\api2_2x\Modifier.c(1105) : warning C4047:
>> 'initializing' : 'unsigned char *' differs in levels of indirection from
>> 'getter'
>> source\blender\python\api2_2x\Modifier.c(1106) : error C2078: too many
>> initializers
>> scons: ***
>> [E:\bf-blender\build\win32-vc\source\blender\python\api2_2x\Modifier.
>> obj] Error 2
>> scons: building terminated because of errors.
>>     
>
>
> 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
>
> Should be :
>
> -----> mod = mods.append(mods.SUBSURF) # add a new subsurf modifier <-----
>
>
>
> _______________________________________________
> Bf-python mailing list
> Bf-python at projects.blender.org
> http://projects.blender.org/mailman/listinfo/bf-python
>
>   


-- 
Campbell J Barton

133 Hope Street
Geelong West, Victoria 3218 Australia

URL:    http://www.metavr.com
e-mail: cbarton at metavr.com
phone: AU (03) 5229 0241



More information about the Bf-python mailing list