Skip to content

Instantly share code, notes, and snippets.

@MikeUdin
Last active August 7, 2023 02:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MikeUdin/59a83c9f1de28ebfcf0d250790f53016 to your computer and use it in GitHub Desktop.
Save MikeUdin/59a83c9f1de28ebfcf0d250790f53016 to your computer and use it in GitHub Desktop.
import c4d
def main():
ps = op.GetAllPoints() #Points in Local coordinates List
m = op.GetMg() #Object Global Matrix
center = op.GetMp() #Local coordinates center: https://tinyurl.com/wed88cn
rad = op.GetRad() # Geometry radius: https://tinyurl.com/tb6vn64
center -= c4d.Vector(0,rad.y,0) #Move down axis to lowest point. Comment this line to keep axis in a center
center *= m #Convert to Global coordinates center
new_m = c4d.Matrix(m) #Copy matrix
new_m.off = center #Change its center
loc_m = ~new_m * m #Get local matrix
op.SetAllPoints([loc_m.Mul(p) for p in ps])
op.SetMg(new_m)
op.Message(c4d.MSG_UPDATE)
c4d.EventAdd()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment