Beenden
  • Globale Community
    • Sprache:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티

Optimize objects stacking order for vinyl cutting

Engagiert ,
Nov 16, 2014 Nov 16, 2014

Hello,

i am looking for a script for optimizing vinyl cutting speed.

The script should be similar to following , but needs to sort the selected objects by the relative position to page origin and not the height from page origin as it does now

script from Arranging stacking order from top to bottm

//David Entwistle

 

var thisDoc = activeDocument;

 

// get selected objects

var selObj = thisDoc.selection;

 

// count the selected objects

var selObjCount = selObj.length;

 

// sort selected objects by their height from the page origin

var byProperty = function(prop) {

    return function(a,b) {

        if (typeof a[prop] == "number") {

            return (a[prop] - b[prop]);

        } else {

            return ((a[prop] < b[prop]) ? -1 : ((a[prop] > b[prop]) ? 1 : 0));

        }

    };

};

 

var symbolsSorted = selObj.sort(byProperty("top"));

 

// for each object in turn in the ordered selection, BringToFront

for(i = selObjCount; i >0; i--){

          var currObj = symbolsSorted[i-1];

          currObj.zOrder(ZOrderMethod.BRINGTOFRONT);

}

 

redraw();

alert("Selected Objects Sorted = " + selObjCount);

 

 

Any help is welcome

Panagiotis

THEMEN
Skripterstellung
5.0K
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines

correct answers 1 richtige Antwort

Ratgeber , Nov 17, 2014 Nov 17, 2014

Ok its late and its not exactly what you want.

There are also probably better ways to achieve this.

It measures the distance from top right of page to top right of pathitems

then sorts them accordingly.

 

var doc = app.activeDocument;

var item = doc.pathItems;

var newLayer = doc.layers.add();

newLayer.name = "New Layer";

 

var newL = doc.layers['New Layer'];

var oldL = doc.layers['Layer 1'];

 

var list = new Array();

for(var i = 0; i < item.length; i++)

{

    list.push(dist(item[i].geometricBoun

...
Übersetzen
Adobe
Ratgeber ,
Nov 16, 2014 Nov 16, 2014

When cutting you want to make sure you cut holes (ie. Center of "O") before cutting the outside.

I cut more with a CNC router so this is probably not as important when cutting vinyl.

But I run all my designs through cam software for cut paths and optimizing of.

not sure how you could decide on start and end position of each cut with illustrator.

Can you clarify what you mean by "relative position to page origin".

Do you mean:

Top left object, followed by next closest object, and so on?

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Engagiert ,
Nov 17, 2014 Nov 17, 2014

Hello , thanks for the reply

I am printing and cutting directly from the same illustrator file, with versaworks rip( using a roland printer-cutter), so the cutting order is very important.

Clarifying about relative position.

The goal is to have the shorter possible cutting head movement

So, with relative position , i mean,

Cut first  the top left object, then the 2nd closest to top left , then the 3d closest to top left , and so on.

Hope that the following image is helpfull

optimized-path.jpg

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Ratgeber ,
Nov 17, 2014 Nov 17, 2014

Ok its late and its not exactly what you want.

There are also probably better ways to achieve this.

It measures the distance from top right of page to top right of pathitems

then sorts them accordingly.

 

var doc = app.activeDocument;

var item = doc.pathItems;

var newLayer = doc.layers.add();

newLayer.name = "New Layer";

 

var newL = doc.layers['New Layer'];

var oldL = doc.layers['Layer 1'];

 

var list = new Array();

for(var i = 0; i < item.length; i++)

{

    list.push(dist(item[i].geometricBounds[0]/2.834645,item[i].geometricBounds[1]/2.834645).toFixed(3));

    item[i].name = list[i];

}

list.sort(sort);

list.reverse();

for(var j = 0 ; j <  list.length; j++)

{

    for(var k = 0; k < oldL.pathItems.length; k++)

    {

        if(oldL.pathItems[k].name == list[j])

        {

            oldL.pathItems[k].move(newL, ElementPlacement.INSIDE);

        }

    }

}

function sort(A,B){return (A - B);}

function dist(A,B){return (Math.sqrt(A*A+B*B));}

 

 

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Engagiert ,
Nov 17, 2014 Nov 17, 2014

Thanks for the script ,

i will try it and post the results!

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Engagiert ,
Nov 18, 2014 Nov 18, 2014

The script works perfectly

One question

How i can modify it to measure the distance from top LEFT of page to top LEFT of pathitems?

( instead of top right of page to top right of pathitems that measures now)

Thanks a lot!

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Ratgeber ,
Nov 18, 2014 Nov 18, 2014

Sorry,

item.geometricBounds[0] = left

item.geometricBounds[1] = top

item.geometricBounds[2] = right

item.geometricBounds[3] = bottom

So it uses top left, I made a mistake in my description.

to measure to Right would take more code as you need to measure page width etc...

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Engagiert ,
Nov 19, 2014 Nov 19, 2014

Great , thanks a lot!!

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Ratgeber ,
Nov 19, 2014 Nov 19, 2014

No problem. Glad I could help

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Neu hier ,
Jan 06, 2018 Jan 06, 2018

What is this part?
I took the script you copied above and it only makes a new layer. nothing else happens. I just copied the whole text. Opened another script in txt document. pasted your script and saved the file. renamed it but as i said it doesn't work. it just created a new layer.

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community-Einsteiger ,
May 19, 2018 May 19, 2018

The original script only processes pathItems. It depends on what you are trying to re-order. Im my case everything is grouped so here is an example.

This worked for me.

var doc = app.activeDocument; 

var item = doc.groupItems; 

var newLayer = doc.layers.add(); 

newLayer.name = "New Layer"; 

 

var newL = doc.layers['New Layer']; 

var oldL = doc.layers['DISPLAY']; 

 

var list = new Array(); 

for(var i = 0; i < item.length; i++) 

    list.push(dist(item.geometricBounds[0]/2.834645,item.geometricBounds[1]/2.834645).toFixed(3)); 

    item.name = list

list.sort(sort); 

list.reverse(); 

for(var j = 0 ; j <  list.length; j++) 

    for(var k = 0; k < oldL.groupItems.length; k++) 

    { 

        if(oldL.groupItems.name == list

        { 

            oldL.groupItems.move(newL, ElementPlacement.INSIDE); 

        } 

    } 

function sort(A,B){return (A - B);} 

function dist(A,B){return (Math.sqrt(A*A+B*B));} 

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community-Einsteiger ,
Sep 11, 2020 Sep 11, 2020

Hi siomosp, nice script man. I manage to make your script work, however the script above created by  Qwertyfly gives me the following error: 

 

Error:1302: No such element

Line:30

→    list.push(dist(item.geometricBounds[0]/

2.834645,item.geometricBounds[1]/2.834645).toFixed(3));

 

What could I be doing wrong?

 

I will be cutting 7 meters of single letters with versaworks but I need the stack order to be as optimal as possible. 

 

The file looks like this:

 

2020-09-11_15h00_18.png

Thanks in advance

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Engagiert ,
Oct 05, 2020 Oct 05, 2020

Hello!

Latest Versaworks ( Dual and V6 ) have its own algorithm for optimizing cutting sequence.

It is not the best, but it is better than nothing.

At your case i think it will do a good job

I hope they will make the cutting sequence smarter shortly!

 

 

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community Expert ,
Oct 05, 2020 Oct 05, 2020

@janaleks oh wow. in my experience with versaworks and roland printers... you'd really be better off breaking that up in to several files. using one file to cut all of that is asking for disaster. the longer your sheet gets, the harder it is for the printer to move the material back and forth, and it doesn't slow down towards the end, so it's going to be trying to pull a ton of material back and forth really quickly which can cause the material to slip, slide, get crooked, etc. and if you wait 2 hours for things to cut, and then things get messed up, you probably have to start from scratch rather than just re-doing the small part that got messed up.

 

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community-Einsteiger ,
Nov 09, 2022 Nov 09, 2022

I also see 

Error:1302: No such element

Line:30

→    list.push(dist(item.geometricBounds[0]/

2.834645,item.geometricBounds[1]/2.834645).toFixed(3));

 

in Illustrator 2022, what is wrong?

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community Expert ,
Nov 09, 2022 Nov 09, 2022
AKTUELL

the forum migration to a new platform messed array indexes in all scripts. Copy the script again, I just fixed it.

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines