[SOLVED] Export Bezier-curve into list of coordinates?


#1

Quick Question: Is there a way to export a bezier-curve (or motion path) into a list of x,y - coordinates?


Help : Trajectory of an object in motion
(Jonathan Deutsch) #2

There is not a built-in way to export this data, but you could get it with some javascript. Let’s say you gave an element a unique element ID “mybox” and had it animate with one motion path on the Main Timeline. You could make an On Scene Load handler run this javascript:

// setup capture values
var startTime = 0.0;
var endTime = hypeDocument.durationForTimelineNamed("Main Timeline");
var framesPerSecond = 30.0;

// element we're interested in
var boxElement = hypeDocument.getElementById("mybox");

// eventual array position data will be stored in
var positions = [];

// loop through, advancing by a frame
for(var time = startTime; time < endTime; time += (1.0/framesPerSecond)) {
	// set the document to be at the frame time
	hypeDocument.goToTimeInTimelineNamed(time, "Main Timeline");
	
	// capture the x/y position of the element
	var x = hypeDocument.getElementProperty(boxElement, "left");
	var y = hypeDocument.getElementProperty(boxElement, "top");
	
	// add to the positions array
	positions.push({"x" : x, "y" : y});
}	

// write out our result to the developer console
console.log(positions);

#3

Yes! Though about that last night. It came to me in a dream :smiley: Sometimes the easiest way is the best way. Thanks for your comment, once again!