Weird Bug on Creating FFD (1) Manually and (2) Script
bentraje last edited by
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 max_x = point_list min_y = point_list max_y = point_list min_z = point_list max_z = point_list for points in obj.GetAllPoints(): min_x = min(min_x, points) max_x = max(max_x, points) min_y = min(min_y, points) max_y = max(max_y, points) min_z = min(min_z, points) max_z = max(max_z, points) 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) deformer.InsertUnder(obj) # Set Deformer Parameters bbox_center = obj.GetMp() # GetBoundingBoxCenter deformer_mat = obj.GetMg() deformer_mat.off = bbox_center * obj.GetMg() deformer.SetMg(deformer_mat) deformer[c4d.FFDOBJECT_SIZE] = c4d.Vector(grid_x, grid_y, grid_z) #Set FFD Grid Size deformer.Message (c4d.MSG_UPDATE) c4d.EventAdd() # Execute main() if __name__=='__main__': main()
m_adam last edited by
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_SIZEwithin 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:
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)
c4d.ESCFLAGS_SET_USERINTERACTIONmimics an user interaction and SetParameter is called on the ObjectData while by default
- Manually defining those points, I let you read Struggling with FFD - [FFDOBJECT_SIZE] which demonstrate how to do it.
bentraje last edited by
Thanks for the response. #1 option works as expected.