Here is a basic code snippet to get connected input object’s size via cinema 4d xpresso python node.

Python
import c4d
def main():
"""
This function is called by Cinema 4D to compute the node.
It retrieves the dimensions of the input object and outputs them as a c4d.Vector.
"""
global Output1 # All output ports must be defined as global variables.
# Assume Input_Object is the BaseObject passed into this node from XPresso.
obj = Input_Object
if not obj:
# If no object is connected, output a zero vector.
Output1 = c4d.Vector(0, 0, 0)
return
# Retrieve the object's bounding radius, which for many objects represents
# half of its dimensions along each axis.
half_dimensions = obj.GetRad()
# Multiply by 2 to get the full dimensions.
dimensions = half_dimensions * 2
# Set the output port to our dimensions vector.
Output1 = dimensions
You can download sample C4D file below:
Get Position and Size
Download “Get_Object_Size_and_Position_Cinema_4D_Xpresso_Python_Node” Get_Object_Size_and_Position_Cinema_4D_Xpresso_Python_Node.zip – Downloaded 0 times – 203.45 KB
import c4d
def main():
"""
Retrieves the object's full dimensions and computes the corrected global position
using the object's local bounding center (via GetMp()).
This approach compensates for an arbitrary pivot by converting the local
bounding center into global space and adding it to the object's global position.
"""
global Output_Scale, Output_Position # Two output ports: one for scale, one for the corrected center.
# Retrieve the input object from the Xpresso node.
obj = Input_Object
if not obj:
Output_Scale = c4d.Vector(0, 0, 0)
Output_Position = c4d.Vector(0, 0, 0)
return
# Retrieve the object's half-dimensions (bounding radii) relative to the pivot.
half_dimensions = obj.GetRad()
# Compute full dimensions.
full_dimensions = half_dimensions * 2
Output_Scale = full_dimensions
# Compute the local bounding center.
# If your object provides GetMp(), it returns the local center offset from the pivot.
local_bounding_center = obj.GetMp() # For example, for a bottom-pivoted object this is typically (0, half_dimensions.y, 0).
# Convert the local bounding center to a global offset.
# First, get the object's global transformation matrix.
mg = obj.GetMg()
# Multiply the local center by the matrix. Subtract mg.off to get the offset vector.
global_center_offset = mg.Mul(local_bounding_center) - mg.off
# The corrected global center is the object's global position plus the offset.
Output_Position = obj.GetAbsPos() + global_center_offset