Skip to main content
Known Participant
June 12, 2022
Answered

Differentiating PathText shape

  • June 12, 2022
  • 2 replies
  • 272 views

How can we differentiate the PathText as an ellipse or a rectangle by using a script?

This topic has been closed for replies.
Correct answer femkeblanco
// select areaText or pathText textFrame
var Ps = app.selection[0].textPath.pathPoints;
var polygon = true;
for (var i = 0; i < Ps.length; i++) {
    var test = Ps[i].anchor[0] == Ps[i].rightDirection[0] && 
               Ps[i].rightDirection[0] == Ps[i].leftDirection[0] && 
               Ps[i].anchor[1] == Ps[i].rightDirection[1] && 
               Ps[i].rightDirection[1] == Ps[i].leftDirection[1];
    if (!test) {
        polygon = test;
        break;
    }
}
if (polygon) alert("polygon");
if (!polygon) alert("non-polygon");

2 replies

m1b
Community Expert
Community Expert
June 13, 2022

Please show screenshot or post example document of the two situations you need to differrentiate.

- Mark

femkeblanco
femkeblancoCorrect answer
Legend
June 12, 2022
// select areaText or pathText textFrame
var Ps = app.selection[0].textPath.pathPoints;
var polygon = true;
for (var i = 0; i < Ps.length; i++) {
    var test = Ps[i].anchor[0] == Ps[i].rightDirection[0] && 
               Ps[i].rightDirection[0] == Ps[i].leftDirection[0] && 
               Ps[i].anchor[1] == Ps[i].rightDirection[1] && 
               Ps[i].rightDirection[1] == Ps[i].leftDirection[1];
    if (!test) {
        polygon = test;
        break;
    }
}
if (polygon) alert("polygon");
if (!polygon) alert("non-polygon");