Get a certain datablock name/id of a selected object

Hello,

I want to change curve data from the active object in python, but I can’t find how to get the current name or id of the curve data which the object uses. For example:

curve_object=bpy.context.active_object
bpy.data.curves[ <name of curve datablock in use by curve_object> ].resolution_u=16

Or:
curve=bpy.context.active_object.<curve_datablock_id>
curve.resolution_u=16

Can somebody please tell me how these attributes are called?

Thank you.

Assuming active object is type ‘CURVE’

curve = bpy.context.object.data

Thank you!

I found this page:
http://www.blender.org/documentation/blender_python_api_2_70_release/info_quickstart.html#accessing-datablocks
And now know that you can access the materials like this:
obj.data.materials[0].diffuse_color=(0.5, 1, 0)

But I can’t find the name of some other attributes like the particlesettings. I’ve tried this:
obj.data.particlesystems[0].count=5
obj.data.particlesettings[0].count=5
obj.data.particles[0].count=5
But those give errors.

Where can I find an overview of these attributes?

print(dir(xxxx)) is your friend. It displays all the next dot properties that are valid for the supplied variable.


&gt;&gt;&gt; psys = ob.particle_systems[0]
&gt;&gt;&gt; print(dir(psys))
['__doc__', '__module__', '__slots__', 'active_particle_target', 'active_particle_target_index', 'billboard_normal_uv', 'billboard_split_uv', 'billboard_time_index_uv', 'bl_rna', 'child_particles', 'child_seed', 'cloth', 'co_hair', 'dt_frac', 'has_multiple_caches', 'invert_vertex_group_clump', 'invert_vertex_group_density', 'invert_vertex_group_field', 'invert_vertex_group_kink', 'invert_vertex_group_length', 'invert_vertex_group_rotation', 'invert_vertex_group_roughness_1', 'invert_vertex_group_roughness_2', 'invert_vertex_group_roughness_end', 'invert_vertex_group_size', 'invert_vertex_group_tangent', 'invert_vertex_group_velocity', 'is_editable', 'is_edited', 'is_global_hair', 'mcol_on_emitter', 'name', 'parent', 'particles', 'point_cache', 'reactor_target_object', 'reactor_target_particle_system', 'rna_type', 'seed', 'set_resolution', 'settings', 'targets', 'use_hair_dynamics', 'use_keyed_timing', 'uv_on_emitter', 'vertex_group_clump', 'vertex_group_density', 'vertex_group_field', 'vertex_group_kink', 'vertex_group_length', 'vertex_group_rotation', 'vertex_group_roughness_1', 'vertex_group_roughness_2', 'vertex_group_roughness_end', 'vertex_group_size', 'vertex_group_tangent', 'vertex_group_velocity']

So try.


ob.particle_systems[0].settings.count = 5

I think I’m going to use that function a lot. Thanks! :slight_smile: