SOLVED Weird Bug on Creating FFD (1) Manually and (2) Script


I encountered a weird bug on creating FFD between Manually and through Script.
Creating Manually works as expected. But creating it through the script, somehow snaps the object to an actual box, despite the fact that both FFDs have the same parameters.

You can check the problem here:

You can check the illustration file here:

Here is the working script:

import c4d
from c4d import gui

# Select Object 
# Run Script 

def main():

    doc = c4d.documents.GetActiveDocument()
    obj = doc.GetActiveObject()

    point_list = obj.GetAllPoints()

    # Populate Initial Variables
    min_x = point_list[0][0]
    max_x = point_list[0][0]
    min_y = point_list[0][1]
    max_y = point_list[0][1]
    min_z = point_list[0][2]
    max_z = point_list[0][2]

    for points in obj.GetAllPoints():

        min_x = min(min_x, points[0])
        max_x = max(max_x, points[0])
        min_y = min(min_y, points[1])
        max_y = max(max_y, points[1])
        min_z = min(min_z, points[2])
        max_z = max(max_z, points[2])

    grid_x = abs(min_x - max_x)
    grid_y = abs(min_y - max_y)
    grid_z = abs(min_z - max_z)

    # Create Deformer
    deformer = c4d.BaseObject(5108) # FFD Deformer
    doc.AddUndo(c4d.UNDOTYPE_NEW, deformer)

    # Set Deformer Parameters
    bbox_center = obj.GetMp()     # GetBoundingBoxCenter

    deformer_mat = obj.GetMg() = bbox_center * obj.GetMg()

    deformer[c4d.FFDOBJECT_SIZE] = c4d.Vector(grid_x, grid_y, grid_z) #Set FFD Grid Size
    deformer.Message (c4d.MSG_UPDATE)

# Execute main()
if __name__=='__main__':


Hi @bentraje thanks for writing to us,

FFD is indeed a bit strange because it's a Deformer that has Point information. When you defining the c4d.FFDOBJECT_SIZE within the UI, it changes these points to match your setting. But in the End what really controls the displayed is those points.

So there is two way to fix it:

  1. Using deformer.SetParameter(c4d.FFDOBJECT_SIZE, c4d.Vector(grid_x, grid_y, grid_z), c4d.DESCFLAGS_SET_USERINTERACTION) instead of deformer[c4d.FFDOBJECT_SIZE] = c4d.Vector(grid_x, grid_y, grid_z)
    SetParameter with c4d.ESCFLAGS_SET_USERINTERACTION mimics an user interaction and SetParameter is called on the ObjectData while by default c4d.DESCFLAGS_SET_NONE is passed.
  2. Manually defining those points, I let you read Struggling with FFD - [FFDOBJECT_SIZE] which demonstrate how to do it.



Thanks for the response. #1 option works as expected.