FBFCurve class starting from MoBu 2011 has changed. There are no methods KeyRemove, KeyDelete and documentation indicated that it was not to replace them.

What to do in this situation.

1. I found a way not using the delete key method in the curve: just create a new curve, write only the necessary keys there, and then reassign the curve as desired. example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
def curveCutRight(node, time):
newcurve = FBFCurve()
curve = node.FCurve

count = len(curve.Keys)
newcurve.EditBegin(count)
newcurve.EditClear()

for key in curve.Keys:
if (key.Time.Get() != time.Get()): break
newcurve.KeyAdd(key.Time, key.Value)

newcurve.EditEnd()

node.FCurve = newcurve
del newcurve, count

2. Today at AREA, Oskar Holmstrand was reported about some undocumented functions to work with a key

1
2
myFCurve.KeyDeleteByIndexRange(index,index)
myFCurve.KeyDeleteByTimeRange(time, time, bool)

Accordingly, in the first case, we indicate with a key index on which to delete, and second, we specify the time period in which the keys must be removed. Very convenient, sorry there is no documentation for that.

Accordingly, in the first case, we indicate with a key index on which to delete, and second, we specify the time period in which the keys need to remove a third option – whether we should remove the key which time coincides with the boundaries of the range.
Keep in mind that you can specify time ranges from minus infinity to plus infinity. For example, to delete all the keys of time greater than some given time, including the boundary of the range:

1
curve.KeyDeleteByTimeRange(time, FBTime.Infinity, True)
MoBu Python: changes in FBFCurve
Tagged on:         

Leave a Reply

Your email address will not be published. Required fields are marked *