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

Select/delete all completely obscured objects

Explorer ,
Oct 21, 2022 Oct 21, 2022

Copy link to clipboard

Copied

I'm looking for a method/script to select and/ or delete all items/objects obscured by any object above it.  

I've not had much luck searching. Can anyone help?

 

cheers

 

Rob

TOPICS
Scripting , Third party plugins , Tools

Views

368

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
Adobe
LEGEND ,
Oct 21, 2022 Oct 21, 2022

Copy link to clipboard

Copied

Unless there's already a script out there I'm not aware of a stock solution inside AI to do this. You would have to check each object against the ones underneath based on whether the bounding boxes are fully inside the other and the layer order is correct. Sometimes you may even need to analyze the actual path. Certainly there would also be some caveats with complex constructs or specific appearances to consider. It seems doable, but I'm not deep enough into Illustrator scripting to really whip up some quick code. 

 

Mylenium

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
Community Expert ,
Oct 21, 2022 Oct 21, 2022

Copy link to clipboard

Copied

It depends on the complexity, but selecting all and clicking Pathfinder Merge is worth trying.

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
Community Expert ,
Oct 21, 2022 Oct 21, 2022

Copy link to clipboard

Copied

If the file is simple enough, you can Object >> hide all the elements you want to keep. Then select all delete, Then use object >> Show All

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
Guide ,
Oct 21, 2022 Oct 21, 2022

Copy link to clipboard

Copied

Scripting with bounding boxes should be easy but may not give the OP the result he hopes for. I've come up with a function which tests whether irregular paths are contained within irregular paths, but it is costly.  If we're talking about thousands of items, the script will cause Illustrator to crash. I am aware of a mathematical formula which is purported to test for points within any polygon, but when I tested it didn't work for any irregular polygon.  I'm not aware of any other scripting methods. 

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
People's Champ ,
Oct 22, 2022 Oct 22, 2022

Copy link to clipboard

Copied

Hi Rob,

 

I would share other fellows' concerns regarding performance but if I have to write this, I would try to take advantage of algorithms like this one:

http://www.java2s.com/ref/javascript/javascript-algorithm-geometry-rectangle-find-intersection.html

It works as it with ExtendScript, only effort is to bring the additional content (loop through page items and coordinates). . But yes, that would be costy with a huge amount of efforts.

I have been trying to think outside the box but cannot see something else. However, if you want to downsize the resulting PDF files, Callas pdfToolbox has features to remove hidden (overlaid by other content) objects:

https://help.callassoftware.com/m/pdftoolbox/l/1086520-visibility-object-is-invisible

FWIW

Loic

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
Engaged ,
Oct 26, 2022 Oct 26, 2022

Copy link to clipboard

Copied

LATEST

You are not going to find a trivial solution as this is not a trivial problem. There are too many complex factors determining if one object completely occludes another or not: [irregular] path shape, opacity, appearances, live brushes/patterns/filters, translucent bitmaps, third-party plugins, hidden object/container/layer, overprint. You certainly can’t do it in ExtendScript as it doesn’t have access to all these attributes.

 

Any naive solution for detecting occluded objects will inevitably yield naive results. While failure to detect a hidden object is no biggie, incorrectly identifying a visible object as hidden is a very bad outcome if your plan is to delete those objects from the document.

 

Loic suggested professional PDF preflight software which is priced accordingly. If this is something you must do, you should trial that to determine if it meets your needs.

 

The only test for determining an object’s occlusion I would contemplate trusting is to compare how the document prints. Export two sets of separations at suitably high DPI, one with the object present and the other without. If the bitmap data is identical for both, it’s probably safe enough to toss the object. That will be painfully tedious, even with basic optimizations (e.g. skip all objects that are obviously visible, rasterize just the area containing the object being tested), and is not a novice job to code.

 

In any case, there is a much simpler question to ask: Why do you want to remove occluded objects in the first place? Unless there’s some very good technical reason for doing so—e.g. you need to produce compact efficient SVG/PDF files from messy documents containing many obscured paths—then your quickest, cheapest, most foolproof solution is just to leave well alone and do nothing at all. Occluded objects won’t affect the image’s final on-screen/in-print appearance so while they are deadweight they are not the end of the world.

 

And if you do need to do it for good technical reason then unless you have large numbers of documents to process then you’ll be quickest and cheapest to perform the job manually, either doing it yourself or outsourcing to a cheap artworking provider. Just because a task may be automated doesn’t mean automation is the most cost-effective route; there is much still to be said for old-school computing.

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