Mobile app version of vmapp.org
Login or Join
Mendez620

: Is there a way in Adobe Illustrator to import a path from a list of points? I want to be able to take a list of point coordinates created by a script and import them as a path. The list

@Mendez620

Posted in: #AdobeIllustrator #AnchorPoint #IllustratorScripting #Path

I want to be able to take a list of point coordinates created by a script and import them as a path. The list would be just be a text document with the coordinates separated by line breaks. Is there a way to do this?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Mendez620

1 Comments

Sorted by latest first Latest Oldest Best

 

@Gail6891361

Yes, you can use a simple script (extendScript, put in file with jsx rending and drag and drop on illustrator) to do this:
#target illustrator

main();

function map(arr, func){ //extendScript has no map
ret = new Array();
for (var i = 0; i < arr.length; i++){
ret.push(func(arr[i]));
}
return ret;
}

function main() {
var doc = app.activeDocument
var file = File.openDialog('load points', 'points:*.txt', false);

file.open('r');
var points = new Array();
while(! file.eof){
var line = file.readln();
var data = map(line.split(/[, ]+/), Number)
points.push(data);
}
newPath = doc.pathItems.add();
newPath.setEntirePath( points );
}


Script prompts for a file with a 2D coordinate per line. Each coordinate value on the line is either comma, or space (or any combination thereof) separated. Feel free to edit to suit your need.

Or you can let your script write the data directly in your script using COM (Component Object Model also commonly referred to as Visual Basic) or OSA (Open Scripting Architecture also commonly referred to as AppleScript) both of which work in a number of host languages (such as python).

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme