Hi,
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:
https://www.dropbox.com/s/ffzw6g4mi04h7mq/c4d275_ffd_different_manual_vs_script.mp4?dl=0
You can check the illustration file here:
https://www.dropbox.com/s/wotl9hmjfr90koc/c4d275_ffd_different_manual_vs_script.c4d?dl=0
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)
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()
Regards,
Ben