If the script is not affecting the Matrix object in Cinema 4D, there might be a few reasons for this. Let’s troubleshoot and ensure that everything is set up correctly:
Ensure that you’re targeting the correct type of object. The ID 1018544 is specific to the MoGraph Matrix object. Double-check that your Matrix object is indeed a MoGraph Matrix.
In the script, we’re setting MG_MATRIXOBJECT_SIZE. Ensure that this is the correct attribute for setting the scale of the clones. If not, it should be replaced with the appropriate attribute.
Make sure the call to c4d.EventAdd() is included to update Cinema 4D about the changes.
Open the Console in Cinema 4D (Window → Console) and check for any error messages when you execute the script.
Temporarily modify the script to print out values (like count_x, new_scale, etc.) to the console. This way, you can verify if the script is calculating the values correctly and reaching all parts of the code.
Ensure that the Python tag is correctly attached to the Matrix object and that the script is being executed. You might need to make a minor change or move the time slider to trigger the script execution.
In some cases, script permissions or limitations in Cinema 4D might prevent the script from executing as expected. Check any relevant settings or preferences.
Make sure that your version of Cinema 4D supports all the features and API calls used in the script.
Lastly, here’s a slightly updated script that includes print statements for debugging:
matrix_obj = op.GetObject()
if not matrix_obj or matrix_obj.GetType() != 1018544:
print("Not a Matrix object")
count_x = matrix_obj[c4d.MG_MATRIX_GRID_COUNT_X]
count_y = matrix_obj[c4d.MG_MATRIX_GRID_COUNT_Y]
count_z = matrix_obj[c4d.MG_MATRIX_GRID_COUNT_Z]
print(f"Counts: {count_x}, {count_y}, {count_z}")
size_x = matrix_obj[c4d.MG_MATRIXOBJECT_SIZE].x
size_y = matrix_obj[c4d.MG_MATRIXOBJECT_SIZE].y
size_z = matrix_obj[c4d.MG_MATRIXOBJECT_SIZE].z
print(f"Sizes: {size_x}, {size_y}, {size_z}")
cell_size_x = size_x / max(1, count_x - 1)
cell_size_y = size_y / max(1, count_y - 1)
cell_size_z = size_z / max(1, count_z - 1)
print(f"Cell Sizes: {cell_size_x}, {cell_size_y}, {cell_size_z}")
new_scale = c4d.Vector(cell_size_x * margin_factor, cell_size_y * margin_factor, cell_size_z * margin_factor)
print(f"New Scale: {new_scale}")
matrix_obj[c4d.MG_MATRIXOBJECT_SIZE] = new_scale
Run this script with the Console open and check the output. This can give you insights into where the script might be failing or if it’s calculating the values as expected.