Setting the view and render levels of a subsurface modifier

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

CallMeMisterX
Posts: 4
Joined: Sat Apr 07, 2012 10:25 pm
Location: Saint Anthony, ID

Setting the view and render levels of a subsurface modifier

Postby CallMeMisterX » Mon Aug 06, 2012 5:09 pm

Hello, I'm just getting into the Python API. Currently, I have been successful adding a subsurface modifier to an object, but I can't seem to wrap my head around how to set the view level and render level for the modifier, once applied. I have tried the documentation, but can't seem to figure it out.
My code so far:

>>>bpy.ops.mesh.primitive_ico_sphere_add()
{'FINISHED'}
>>>bpy.ops.object.shade_smooth()
{'FINISHED'}
>>>bpy.ops.object.modifier_add(type='SUBSURF')
{'FINISHED'}

Any help is greatly appreciated.

CoDEmanX
Posts: 894
Joined: Sun Apr 05, 2009 7:42 pm
Location: Germany

Postby CoDEmanX » Thu Aug 09, 2012 12:19 am

Code: Select all

bpy.context.active_object.modifiers['Subsurf'].levels = 2  # View
bpy.context.active_object.modifiers['Subsurf'].render_levels = 2  # Render
I'm sitting, waiting, wishing, building Blender in superstition...

CallMeMisterX
Posts: 4
Joined: Sat Apr 07, 2012 10:25 pm
Location: Saint Anthony, ID

Postby CallMeMisterX » Thu Aug 09, 2012 3:53 am

Awesome. Thanks. Exactly what I was looking for.


Return to “Python”

Who is online

Users browsing this forum: No registered users and 0 guests