I am getting the Error: couldnt turn result into numeric value

New Here ,
Jun 14, 2022 Jun 14, 2022

Copy link to clipboard

Copied

This is my code:

var nullLayerNames = ["Shape Layer 13: Path 1 [1.1.0]","Shape Layer 13: Path 1 [1.1.1]","Shape Layer 13: Path 1 [1.1.2]","Shape Layer 13: Path 1 [1.1.3]","Shape Layer 13: Path 1 [1.1.4]","Shape Layer 13: Path 1 [1.1.5]","Shape Layer 13: Path 1 [1.1.6]","Shape Layer 13: Path 1 [1.1.7]","Shape Layer 13: Path 1 [1.1.8]","Shape Layer 13: Path 1 [1.1.9]"]; 
var nullLayerNamesIn = ["Shape Layer 13: Path 1 [1.1.0][In]","Shape Layer 13: Path 1 [1.1.1][In]","Shape Layer 13: Path 1 [1.1.2][In]","Shape Layer 13: Path 1 [1.1.3][In]","Shape Layer 13: Path 1 [1.1.4][In]","Shape Layer 13: Path 1 [1.1.5][In]","Shape Layer 13: Path 1 [1.1.6][In]","Shape Layer 13: Path 1 [1.1.7][In]","Shape Layer 13: Path 1 [1.1.8][In]","Shape Layer 13: Path 1 [1.1.9][In]"]; 
var nullLayerNamesOut = ["Shape Layer 13: Path 1 [1.1.0][Out]","Shape Layer 13: Path 1 [1.1.1][Out]","Shape Layer 13: Path 1 [1.1.2][Out]","Shape Layer 13: Path 1 [1.1.3][Out]","Shape Layer 13: Path 1 [1.1.4][Out]","Shape Layer 13: Path 1 [1.1.5][Out]","Shape Layer 13: Path 1 [1.1.6][Out]","Shape Layer 13: Path 1 [1.1.7][Out]","Shape Layer 13: Path 1 [1.1.8][Out]","Shape Layer 13: Path 1 [1.1.9][Out]"]; 
var origPath = thisProperty; 
var origPoints = origPath.points(); 
var origInTang = origPath.inTangents(); 
var origOutTang = origPath.outTangents(); 
var getNullLayers = []; 
var getNullLayersIn = []; 
var getNullLayersOut = []; 
for (var i = 0; i < nullLayerNames.length; i++){ 
    try{  
        getNullLayers.push(effect(nullLayerNames[i])("ADBE Layer Control-0001")); 
        getNullLayersIn.push(effect(nullLayerNamesIn[i])("ADBE Layer Control-0001")); 
        getNullLayersOut.push(effect(nullLayerNamesOut[i])("ADBE Layer Control-0001")); 
    } catch(err) { 
        getNullLayers.push(null); 
    }} 
for (var i = 0; i < getNullLayers.length; i++){ 
    if (getNullLayers[i] != null && getNullLayers[i].index != thisLayer.index){ 
        origPoints[i] = fromCompToSurface(getNullLayers[i].toComp(getNullLayers[i].anchorPoint));  
		
        origInTang[i] = fromCompToSurface(getNullLayersIn[i].toComp(getNullLayersIn[i].anchorPoint)) - origPoints[i];  
        origOutTang[i] = fromCompToSurface(getNullLayersOut[i].toComp(getNullLayersOut[i].anchorPoint)) - origPoints[i];  
    }} 
var pointsChecked = [];
for(var i = 0; i< origPoints.length; i++) {
	

	const pathTanForward1 = origOutTang[i];// out tangent of first point (from left)
	const angleForward1=radiansToDegrees(Math.atan2(pathTanForward1[i+1],pathTanForward1[i])); // angle of tangent of first point

	const pathTanForward2 = origInTang[i+1];  // in tangent of second point 
	const angleForward2=radiansToDegrees(Math.atan2(pathTanForward2[i+1],pathTanForward2[i])); // angle of tangent of second point

	const angleDifferenceForward = Math.abs(angleForward2 - angleForward1) - 180; 
	var backPos = -1;
	if (i == 0) {
		backPos = origPoints.length -1;
	} 
	const pathTanBackward1 = origOutTang[i];// out tangent of first point (from left)
	const angleBackward1=radiansToDegrees(Math.atan2(pathTanBackward1[i+backPos],pathTanBackward1[i])); // angle of tangent of first point

	const pathTanBackward2 = origInTang[i+backPos];  // in tangent of second point 
	const angleBackward2=radiansToDegrees(Math.atan2(pathTanBackward2[i+backPos],pathTanBackward2[i])); // angle of tangent of second point

	const angleDifferenceBackward = Math.abs(angleBackward2 - angleBackward1) - 180; 

	if (angleDifferenceForward<1 && angleDifferenceForward>0 && angleDifferenceBackward<1 && angleDifferenceBackward>0){  
		var substactPoint = [origPoints[i][0] * 0.8, origPoints[i][1] * 0.8];
		pointsChecked.push(substactPoint);
		pointsChecked.push(origPoints[i]);
	} 

	

	
}
createPath(pointsChecked,[],[], false);

After taking away some of the code I found the error code doesn't seem to respond to a particular line but I have isolated to have something to do with this code:

const pathTanForward1 = origOutTang[i];// out tangent of first point (from left)
    const angleForward1=radiansToDegrees(Math.atan2(pathTanForward1[i+1],pathTanForward1[i])); // angle of tangent of first point

    const pathTanForward2 = origInTang[i+1];  // in tangent of second point 
    const angleForward2=radiansToDegrees(Math.atan2(pathTanForward2[i+1],pathTanForward2[i])); // angle of tangent of second point

 

I looked up the error message and found this thread::https://community.adobe.com/t5/after-effects-discussions/error-couldn-t-turn-result-into-numeric-val....

Here they get the same issue and it was the misspelling of the PI function, I dont think I've misspelt anything else I am mistaken.

 

If anyone can help will be much appreciated, thanks.

I attached the project file in case anyone is interested.

TOPICS
Error or problem , Expressions , Scripting

Views

22

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 14, 2022 Jun 14, 2022

Copy link to clipboard

Copied

LATEST

On a quick glance I would assume you're missing some value when building your final array. Your "pointsChecked" function would build anchor points in the wrong order or with multiple tangent values because you're not keeping your iterator straight. Anyway, hard to check without being in front of AE and your code is rather unelegant and hard to read to begin with. I'd probably completely rewrite it, beginning with getting rid of those long, redundant definitions for the input points and creating consistent variables for the values. You're kind of re-declaring them on every line, which is unnecessary and may cause inadvertent errors.

 

Mylenium

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines