Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
Hello, I am a python novice, trying to find a way to move the axis of hundreds objects to the origin. I found a great script by Arttu Rautio https://aturtur.com/ar_scripts-for-cinema-4d/, specifically this one https://github.com/aturtur/cinema4d-scripts/blob/master/AR_Scripts_1.0.15/AR_AxisToCenter.py which will move the axis on many objects to their center and am wondering if it's possible to modify this to move the axis to the origin instead.
This fuction appears to be doing the axis shifting in that script.
def CenterAxis(obj): # Center object's axis doc = c4d.documents.GetActiveDocument() # Get active Cinema 4D document points = [] # Initialize empty list pointCount = obj.GetPointCount() # Get object's point count for i in range(0, pointCount): # Loop through points points.append(obj.GetPoint(i)) # Add point to points list matrix = obj.GetMg() # Get object's global matrix center = obj.GetMp() # Get Object's bounding box center in local space axis = obj.GetAbsPos() # Get object's absolute position difference = axis - (axis + center) # Calculate difference if difference != c4d.Vector(0): # If there is a difference for i in range(pointCount): # Loop through object's points obj.SetPoint(i, points[i] + difference) # Set new point position obj.Message(c4d.MSG_UPDATE) # Send update message obj.SetMg(c4d.Matrix((matrix * center), matrix.v1, matrix.v2, matrix.v3)) # Set new matrix for the object
I'm wondering if it's as simple as setting the center matrix to a fixed point (0,0,0) but I'm not sure how to format those coordinates as a matrix. (or if it's even this small a change or would need a larger re-write)
I've also tried using the script log while performing the action manually but the cooridinate manager does not produce log entries that I can see unfortunately.
Does anyone have any insight on how this might be achieved?
Thanks