MAXON CINEMA 4D: Cinema 4D Forum Adobe After Effects Forum

Is it possible to center axis points via C.O.F.F.E.E. Script ?

COW Forums : Maxon Cinema 4D

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Mehmet SensoyIs it possible to center axis points via C.O.F.F.E.E. Script ?
by on Feb 7, 2014 at 10:11:32 am

Hello,
I'm looking for a solution about a week. Could not find it yet. Hope you guys help me...

I have found one code tried to modified it;
main () {

var doc = GetActiveDocument();
var op = Object;

if(op->GetType() != Opolygon) return;//error handling

var newmatrix = new(Matrix); // create a new matrix(axis)


var newpos = newmatrix->SetV0(vector(a1,a2,a3));// The position of this new Matrix(axis)


doc->AddUndo(UNDO_OBJECT, op);
var invertednewmatrix = newmatrix->GetClone();// Create a clone of the Matrix(axis) and assign it to this variable
invertednewmatrix->Invert();// Invert the matrix so the variable name makes sense
var invpos = invertednewmatrix->GetV0(); // Get the position of the inverted Matrix(axis)

var gp = op->GetPoints();// Get all the vertices of the object
var pcnt = op->GetPointCount();//Used to tell how many times the loop should run
var i = 0;
for (i = 0; i < pcnt; i++)
{
gp[i] = newmatrix->GetMulP(gp[i]); //offsets each vertice by the newpos amount
op->SetPosition(invpos); //offset the axis by the newpos amuont
}
op->SetPoints(gp);
op->Message(MSG_UPDATE);
doc->EndUndo();

}


But it's not working. Here is my scene file, I'm working on Xpresso so trying to make it on C.O.F.F.E.E. node.

7107_example.c4d.zip

Thank you all and best regards...


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]