Link in Zwischenablage kopieren
Kopiert
There are some compoundPathItems in myfile.ai
How can i run "Object > Compound Path > Make" or send "ctrl+8" from jsx? At line with comment ERROR HERE i get error message "A new object cannot be created at the specified location".
#target illustrator
if (app.documents.length > 0) {
var idoc = app.activeDocument;
var cp = idoc.compoundPathItems.add();
var allPaths = activeDocument.pathItems;
//Select objects
for(var i = 0;i < allPaths.length;i++){
allPaths.selected = true;
}
var selection = app.activeDocument.selection;
for (var i=0; i<selection.length; i++) {
selection.move (cp, ElementPlacement.PLACEATEND); // move selected path inside the compound path ERROR HERE
selection.evenodd = true; // necessary to determine "insideness" or to make holes.
}
alert(selection);
"Object > Compound Path > Make" as
app.executeMenuCommand("compoundPath");
Link in Zwischenablage kopieren
Kopiert
K0r5hun,
does this work for you and can you see the changes?
if (app.documents.length > 0) {
var idoc = app.activeDocument;
var cp = idoc.compoundPathItems.add();
var allPaths = activeDocument.pathItems;
//Select objects
for(var i = 0;i < allPaths.length;i++) {
allPaths.selected = true;
}
var selection = app.activeDocument.selection;
//for (var i=0; i<selection.length; i++) {
for (var i=selection.length-1; i>0; i--) {
//selection.move (cp, ElementPlacement.PLACEATEND); // move selected path inside the compound path ERROR HERE
selection.move (cp, ElementPlacement.PLACEATBEGINNING);
//selection.evenodd = true; // necessary to determine "insideness" or to make holes.
cp.pathItems[0].evenodd = true;
}
}
alert(selection);
Have fun
Link in Zwischenablage kopieren
Kopiert
selection.move (cp, ElementPlacement.PLACEATBEGINNING);
The same error in the move line 😃
Link in Zwischenablage kopieren
Kopiert
"Object > Compound Path > Make" as
app.executeMenuCommand("compoundPath");
Link in Zwischenablage kopieren
Kopiert
Thank you! It's working!
Link in Zwischenablage kopieren
Kopiert
K0r5hun schrieb:
selection.move (cp, ElementPlacement.PLACEATBEGINNING);
The same error in the move line 😃
Only for my interest:
What kind of elements in your document exists?
Please can you show me your layers palette and the error message.
Link in Zwischenablage kopieren
Kopiert
What kind of elements in your document exists?
There are 4 Compound Paths. I create contur for my image in PSD and export it in *.ai.
Weitere Inspirationen, Events und Ressourcen finden Sie in der neuen Adobe Community
Jetzt ansehen