• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to select all Gradient filled paths but FAST?

Explorer ,
Jul 29, 2019 Jul 29, 2019

Copy link to clipboard

Copied

Hello, I've been trying to find a faster way to select all gradient filled objects (not meshes) in complicated documents and change them to a basic color.

This would effectively remove the gradients which cause all sorts of problems when creating an underbase for screenprinting, but leave the objects themselves there since we don't want to remove them or expand them to raster or meshes.

I've found this method. It takes WAY too long on any document I've tried it on (all complex documents because that's all we need it for).

From here: Selecting pathItems with a Gradient

  1. #target illustrator 
  2. var doc = app.activeDocument 
  3. var pL = doc.pathItems.length; 
  4. var pID; 
  5. for (var i = 0, l = pL; i < l; i++) { 
  6.     pID = doc.pathItems
  7.     if (pID.fillColor.typename == 'GradientColor') { 
  8.         pID.selected = true
  9.     } 

The only other thing I've found for this takes just as long as well (it was ExtendedSelect from this link> Arid Ocean - ExtendedSelect Script ). I haven't checked the code but I'm guessing it probably uses the same method. I don't want people to have to just sit there and wait for their PC to maybe or maybe not respond after half an hour. Is their an instant way to select all gradient filled paths?

TOPICS
Scripting

Views

2.3K

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

correct answers 1 Correct answer

Advocate , Aug 03, 2019 Aug 03, 2019

Salut!

" and change them to a basic color."

1mn pour 24300 paths

c'est mieux que manuellement ?

#target illustrator

  var newColor = macmjnColor(100,75,0,0);

//----

  var pID, doc;

      doc = app.activeDocument

      paths = doc.pathItems;      alert(paths.length)

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

          pID = paths;

            if (pID.fillColor.typename == 'GradientColor') {

              paths.fillColor = newColor;

            }

        }

//------

function macmjnColor( c, m, j, n )

{ //crée

...

Votes

Translate

Translate
Adobe
Community Expert ,
Aug 02, 2019 Aug 02, 2019

Copy link to clipboard

Copied

When Unlock All is executed, the locked pageItem is selected quickly.

https://sttk3.com/blog/tips/illustrator/select-faster-by-script.html

var doc = app.activeDocument ;

// initsialize locked of pageItems

var keyStr = 'unlockAll' ;

app.executeMenuCommand(keyStr) ;

var pID ;

for(var i = 0, l = doc.pathItems.length ; i < l ; i++) {

  pID = doc.pathItems ;

  if(pID.fillColor.typename == 'GradientColor') {

   

    // mark it

    pID.locked = true ;

  }

}

// select marked items

app.executeMenuCommand(keyStr) ;

Votes

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
Contributor ,
Aug 03, 2019 Aug 03, 2019

Copy link to clipboard

Copied

Basically this is the fastest way of doing it - you select all the pathItems, and then check if they have gradient, if so, then select them.

On this level i don't think there is anything to speed up.

It strictly depends on the complexity of the document - more paths - more time to check all of them.
I'd even say it should be checked with the pageItems instead of pathItems, as compoundPathItems also might have gradient color, so for now they won't be checked. The thing is - it will slow down the script even more.

Above idea with first locking the item, then unlocking them to select might be faster, as it doesn't unnecesarly render all the image after each new selection - it's reduced to one render at the end, but if there are any other locked items in the document it will select them also.

If there is possibility to send here some file to see what we are dealing with, it could help.

Maybe just the PC's are slow.

@Edit

Just an idea i had few moments before - instead of selecting each item with item.selected = true; create new array and fill it with objects with gradient fill
then just go with document.selection = arrayOfObjectsWithGradinetFill

Votes

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
Advocate ,
Aug 03, 2019 Aug 03, 2019

Copy link to clipboard

Copied

Salut!

" and change them to a basic color."

1mn pour 24300 paths

c'est mieux que manuellement ?

#target illustrator

  var newColor = macmjnColor(100,75,0,0);

//----

  var pID, doc;

      doc = app.activeDocument

      paths = doc.pathItems;      alert(paths.length)

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

          pID = paths;

            if (pID.fillColor.typename == 'GradientColor') {

              paths.fillColor = newColor;

            }

        }

//------

function macmjnColor( c, m, j, n )

{ //crée une nouvelle couleur CMJN

  var cmykColor = new CMYKColor();

  cmykColor.cyan = c;

  cmykColor.magenta = m;

  cmykColor.yellow = j;

  cmykColor.black = n;

  return cmykColor;

}

//------

Votes

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
Explorer ,
Aug 05, 2019 Aug 05, 2019

Copy link to clipboard

Copied

This works great! Thank you! I actually found another way to do this as I was waiting for replies. I don't have the time to explain it right now but the way I came up with uses an action to create an underbase for almost any art for shirt screenprinting.

 

Basically to convert the gradients to normal colors, it expands everything including the gradients, selects the new clipping paths created by the expanded gradients, offsets them with no change just to duplicate the paths,  releases the clipping paths to turn them to normal paths, then fills them. The method created by renél80416020 made a much cleaner way of doing this that's also pretty fast.

 

Here's a link to my entire action for all to benefit from: UB Creation Action - pCloud

It's only tested on 2019 Illustrator.

 

The action that does this inside the action group is the last one. To run it you'll need to change the destination path of the AI file included in the link, it's one of the lines in the action.

 

Also no, this PC isn't slow at all, in reply to that question. This is a $1000+ custom PC I built using the very best benchmarked parts for the price very recently.

Votes

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
Explorer ,
Aug 28, 2024 Aug 28, 2024

Copy link to clipboard

Copied

LATEST

Hi! Does it works with freeform gradients ? 

 

___
Lottie and Rive animation for your web or mobile project.

Votes

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