2

I am trying to run a cloth simulation in blender using python scripting and despite setting the frame_end of the scene to the desired number of frames (C.scene.frame_end = total_frames), the cloth stops at 250 frames.

I eventually found that that I need to set the frame_end for the cloth as well, and I tested it and it works, but I don't know how to do the same operation via scripting.

Here is a screenshot of the particular setting I am trying to change. enter image description here

When I change the setting via the user interface, the following appears in the info view mode:

bpy.context.object.frame_end = 285

However, when I try to do the exact same thing via the python console, blender will give me the following error:

>>> bpy.context.object.frame_end = 285
Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
AttributeError: 'Object' object has no attribute 'frame_end'

>>> bpy.context.object
bpy.data.objects['shirt']

When I hover over the property, the "command" that pops up is also incomplete:

bpy.data.objects['shirt'] ... frame_end

How do I change this property via scripting?

scapiskipi
  • 33
  • 4

1 Answers1

2

It is a setting of the added cloth modifier.

enter image description here

context.object.modifiers['Cloth'].point_cache.frame_end 

(where the cloth modifiers name is "Cloth" and the object has context)

The tooltip is spot on in later versions of blender.

Note may have to mouse over properties area to redraw and see new value.

batFINGER
  • 84,216
  • 10
  • 108
  • 233