Hallo Mazlov,
lot of thanks for your explanation. I think I don't will get deeper in the math of generic Bezier and Cubic Hermite spline.
But this is good to know how Ae and C4D interpret these tangent values.
Meanwhile I finished my script that push every selected Ae-Shape direct to C4D. Works fine so far.
Thanks for your help!
Tudor
Posts made by Tudor
-
RE: Correct Tangent Values
-
RE: Correct Tangent Values
Hallo Mazlov,
i have an example for this:
This is the bezier data of a circle with 500px radius what I get from Ae:
I get this values in Ae through:
myPath = myLayer.content(i).content(j).path.value;
vertices = myPath.vertices
inTangents = myPath.inTangents
outTangents = myPath.outTangentsvertices: [[0,-500],[500,0],[0,500],[-500,0]]
inTangents: [[-276.142364501953,0],[0,-276.142364501953],[276.142364501953,0],[0,276.142364501953]]
outTangents: [[276.142364501953,0],[0,276.142364501953],[-276.142364501953,0],[0,-276.142364501953]]If I construct in cinema4D a spline with this values it looks like this
spline = c4d.SplineObject(6, c4d.SPLINETYPE_BEZIER)
points = [...]
leftTangents = [...]
rightTangents = [...]
spline.SetAllPoints(points)
spline.SetTangent(i, leftTangents, rightTangents).....
doc.InsertObject(spline)I have correct all y values by -1 but in general all tangents appear to long.
Somewhere in a forum I found that I just need to multiply them with 0.75 and yes indeed it works, but I'm still confused -
Correct Tangent Values
Hello friends,
I'm trying to draw some splines though a python script.
I get the shape data from after effects where I extract the vertices and in/out tangents of a bezier shape.
Then I use this bezier data to recreate the object in cinema 4d.
So far so good, after some try and error and flipping the y-axis the object appear on the right place but the rounding not match really.
Something is wrong with the tangent values.
Does cinema interpret these tangent values from after effects different?Thanks for your help
Tudor -
RE: pass Variable from After Effects to C4D
@ferdinand I use the Script above myPythonScript
It runs fine, I start it over:
Extensions > user Script or
File > open Project or
Terminal on mac > open -a cinemaAppPath myPythonScriptPath
and it works also on window over command line. -
RE: pass Variable from After Effects to C4D
@ferdinand Hey, lot thanks for your help and suggestions but i'm still confused.
My first try to run my python script through the terminal still work for me.
Cinema app starts, run the PythonScript and print the value.open -a cinemaAppPath myPythonScriptPath
myPythonScript
import c4d def main(): print("Hello World") if __name__ == "__main__": main()
But otherwise I don't get any output in the cinema console if I run that over c4dpy.
I'm not sure but its also not very user-friendly to enter the license method and than it take some time for the process. -
pass Variable from After Effects to C4D
Hello friends,
i have developed a script that should send some arguments from after effects to cinema4D. I tried over the terminal to open cinema and run my python script file.
So far so good, but how I can pass to my c4d python script some arguments?open -a cinemaAppPath myPythonScriptPath
Do have a idea or a reference this?
Thanks for your help
Cinema2024 / MacOS Ventura M1 -
RE: Object Target Expression in Python
Does anyone have a suggestion how to work with Quaternions in my case to avoid the gimbal lock? I realy dont find any examples or approaches to this. Other APIs have different methods for this like SetFromToRotation, SetLookRotation, lookAt ....
Maybe its possible to extend the Python Library with other classes? Don‘t have any idea and not very advanced in this.
Thanks! -
RE: Quaternion rotation
I thought I can use this direction vector as Quaternion-Axis. The cam should point than to the target.
But but it seems i need a different approach.import c4d, math cam = op.GetObject() target = op[c4d.ID_USERDATA,1] def main(): tarPos = target.GetAbsPos() camPos = cam.GetAbsPos() direction = (tarPos - camPos).GetNormalized() angle = math.pi/2 #? q = c4d.Quaternion() q.SetAxis(direction, angle) b = q.GetMatrix() b.off = cam.GetAbsPos() cam.SetMg(b)
-
Quaternion rotation
Hello friends,
I'm trying to work with the Quaternion-Object.
My cam-Object should align to the direction vector and pointed in this case in X-Direction.
But if print the q.v value I get a zero vector and the rotation is not applied
Does I misunderstood the Quaternion-Syntax? I can't find nothing about that.
–
Thanksimport c4d cam = op.GetObject() def main(): direction = c4d.Vector(10,0,0).GetNormalized() angle = 0 q = c4d.Quaternion() q.SetAxis(direction, angle) b = q.GetMatrix() b.off = cam.GetAbsPos() cam.SetMg(b) print q.v
-
RE: Object Target Expression in Python
Hi,
thanks again.
I really do not understand it yet but it works.
There are some strange camera behaviors in the viewport but the system still stable.
I have tried also the Quaternions-solution, but I don't know really now the syntax work.
Do you have an idea? -
RE: Object Target Expression in Python
Hi Riccardo,
thank you for your help.
After I put GetNormalized() in your line rVec and uVec it works.
But now I get a flipping problem if the cam-Obj is direct over (or under) the target-Obj.
The same happened by the Target-Tag. The Target-Tag has a option to stabilize the system with an up-Vector.
Could I calculate this up-Vector to my matrix to stabilize it too? Or maybe there is a other approach?
Thanks
Tudor -
Object Target Expression in Python
Hi Friends,
I try to build the Object Target Expression in Python.
So far I have this and it works but with a little issue.
I have a flipping problem and I don't know how to build the up-vector in, so that it works perfectly.
–import c4d cam = op.GetObject() target = op[c4d.ID_USERDATA,1] def main(): cObj = cam.GetMg().off tObj = target.GetMg().off upV = c4d.Vector(0, 1, 0) m = c4d.Matrix() m.off = cObj m.v1 = (tObj-cObj).Cross(cObj-upV).GetNormalized() m.v3 = (tObj-cObj).GetNormalized() m.v2 = (tObj-cObj).Cross(m.v1).GetNormalized() cam.SetMg(m)