Created
August 9, 2021 13:01
-
-
Save MikeUdin/d8d0fcf3e5df2d083350e45817492ccc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
How to connect bezier spline points to objects | |
and control tangents with Python Tag in Cinema 4D. | |
View tutorial and get project files here | |
https://mikeudin.net/?p=7503 | |
Author : Mike Udin | |
Web-site : mikeudin.net | |
Tag : Python | |
""" | |
import c4d | |
def main(): | |
spline = op.GetObject() | |
start = spline[c4d.ID_USERDATA,2] | |
end = spline[c4d.ID_USERDATA,3] | |
if (not start) or (not end): | |
return | |
use_global_tang = spline[c4d.ID_USERDATA,5] | |
global_tang = spline[c4d.ID_USERDATA,6] | |
start_tang = start[c4d.ID_USERDATA,1] | |
end_tang = end[c4d.ID_USERDATA,1] | |
start_mx = start.GetMg() | |
end_mx = end.GetMg() | |
smx = spline.GetMg() | |
if use_global_tang: | |
start_tang = end_tang = global_tang | |
start_tang = (start_tang * start_mx) - start_mx.off | |
end_tang = (end_tang * end_mx) - end_mx.off | |
spline.SetPoint(0,start_mx.off * ~smx) | |
spline.SetTangent(0,start_tang * -1,start_tang) | |
spline.SetPoint(1,end_mx.off * ~smx) | |
spline.SetTangent(1,end_tang,end_tang * -1) | |
spline.Message(c4d.MSG_UPDATE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment