2
$\begingroup$

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?

$\endgroup$
4
  • 1
    $\begingroup$ Related That is a tricky one, it's context.object.modifiers['Cloth'].point_cache.frame_end (where the cloth modifiers name is "Cloth" and the object has context) $\endgroup$
    – batFINGER
    May 15, 2018 at 13:09
  • $\begingroup$ Hmm @batFINGER that has no effect for me, I was not able to change the frame_end. Was this changed in a recent version of Blender? (I'm using 2.82a.) I can post a MWE if needed. $\endgroup$ May 6, 2020 at 20:27
  • $\begingroup$ Works for me.. added as answer. $\endgroup$
    – batFINGER
    May 6, 2020 at 20:48
  • $\begingroup$ Thanks! I had a really dumb mistake when testing the code. I'll up vote you. $\endgroup$ May 6, 2020 at 22:42

1 Answer 1

2
$\begingroup$

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.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .