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

Script to delete paths

New Here ,
Dec 21, 2016 Dec 21, 2016

Hello,

I tinker with scripting but I'm nowhere near a pro.

I need an illustrator script that will find all paths that have no stroke, and delete them.

I feel like this script is really close with a little tweaking:

No Stroke No Fill not recognizing

But I'm having trouble tweaking it properly.

Any help is appreciated. Thanks!!

TOPICS
Scripting
3.9K
Translate
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

Participant , Dec 22, 2016 Dec 22, 2016

I think this should do it. Good luck!

#target illustrator

// it's best practice to wrap everything in a function

//   so that you don't accidentally mess up any global

//   variables

function RemoveNoStrokePaths() {

  // if there are no documents open then return, otherwise

  //   store a reference to the active document in 'doc'

  if( !app.documents.length ) return;

  var doc = app.activeDocument;

 

  // store a reference to all the PathItems in the active document

  var paths = doc.pathItems;

 

  // Since

...
Translate
Adobe
People's Champ ,
Dec 22, 2016 Dec 22, 2016

If you are not confident with scripting, why not use an action script ?

First select some no path object.

Second, create an action

Third, menu/select/same stroke width

Delete

Stop Action recording

On next run, pick a no stroke item, run the action.

I know it's no script and you have to first select some object but you get the job done in a blink

Translate
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
Participant ,
Dec 22, 2016 Dec 22, 2016

I think this should do it. Good luck!

#target illustrator

// it's best practice to wrap everything in a function

//   so that you don't accidentally mess up any global

//   variables

function RemoveNoStrokePaths() {

  // if there are no documents open then return, otherwise

  //   store a reference to the active document in 'doc'

  if( !app.documents.length ) return;

  var doc = app.activeDocument;

 

  // store a reference to all the PathItems in the active document

  var paths = doc.pathItems;

 

  // Since we might be removing items from the list, the item indices

  //   could change, and so should loop from the last index to the first

  for( var i = paths.length-1; i >= 0; i-- ) {

    

     // get reference to the current PathItem

     var curPath = paths;

    

     // if the PathItem has a stroke assigned, the 'stroked' property

     //   will equal 'true', so if it's false we know that the path

     //   doesn't have a stroke and we can remove it

     if( !curPath.stroked )

          curPath.remove();

   }

}

RemoveNoStrokePaths();

Translate
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
New Here ,
Dec 22, 2016 Dec 22, 2016

Yes!!

Thank you so much.

Translate
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
Advisor ,
Feb 22, 2023 Feb 22, 2023
LATEST

@zertle 

Thanks, very useful piece of code. Ive add && curPath.filled so i can clean empty items using script and then action

Translate
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