5 Replies Latest reply: Jul 22, 2014 11:41 AM by bcrimmins RSS

    How to delete a path item from within a group item?

    bcrimmins Community Member

      I am generating and downloading QR codes in vector format (.eps).  I use VB scripting to place each QR code into an Illustrator document for later laser etching as a batch.  Each QR code is comprised of a bunch of small, individual filled squares all enclosed in a single large transparent square.  Here's a sample of one of the QR codes: http://laserfolly.com/2753.eps  When etching, the laser control software interprets the outside bounding square in such a way that it confuses its "inside out" algorithm used to determine whether a given path item should be etched, i.e., is it "filled".  This causes the some of the individual squares to be interpreted as not filled... even though they are.  If I delete the outer bounding square path item then all is well.  But there are hundreds of these codes in every batch... so it is time prohibitive to delete those outer squares by hand.  Here's my ask: does anyone know how to use Illustrator scripting (I'm using VB) to identify that outer square and delete it at the time that it's placed in the batch document?

       

      Thanks in advance for any help you can give.

       

      Bob

        • 1. Re: How to delete a path item from within a group item?
          Muppet Mark Community Member

          I can't help you using VB ( I'm on a mac ) but in answer to your question… Yes its pretty straight forward…

          Have script look for the path that has the clipping property as true…

          In the case of your codes its most probably the first and only one in the group…

          Do you mind using JS or do you need to do other processing in the VB…?

          • 2. Re: How to delete a path item from within a group item?
            bcrimmins Community Member

            Thanks, Mark.  That makes sense.  However, when I search all the paths in the document there are none that have a true clipping property.  My suspicion is that the bounding square is just that, a square drawn by the qr code api as a frame around the code.  You got me thinking though.  I figured out that I can identify the relevant path simply by it's dimensions and then delete it.  So here's the new sticking point: I don't think the Illustrator object model allows for interrogating path items within a group, i.e., you have to iterate through all the pathitems in the document.  Ideailly, I'd like to be able to look at only the paths within the QR code, which I add to the document as a placed item... which Illustrator treats as a group.  This document has tens of thousands of paths and so looping through all of the them to find the 50 QR codes would be super inefficient.  What do you think?  Is there a way to iterate through just the paths in a placeditem/group?

             

            RE VB vs. JS, I can write in both but there are a lot of reasons I'm using VB on this project.  The main reasons are that the customer is using Excel for data internally and Excel VBA is a really strong VBA object model.  I've also written more than 500,000 lines of the stuff in my career so I'm pretty comfortable solving complex problems with it.  Also, the IDE and the run-time debugging engine is oh so great for rooting out the nasties.  :-)

            • 3. Re: How to delete a path item from within a group item?
              Larry G. Schneider CommunityMVP

              Since a GroupItem is a subclass of PathItem, it should be as simple as docRef.pathItems.groupItems(1)pathItems(1).

              • 4. Re: How to delete a path item from within a group item?
                Muppet Mark Community Member

                #target illustrator

                 

                var doc = app.activeDocument;

                 

                alert( doc.pathItems.length ); // All document paths

                 

                alert( doc.groupItems[0].pathItems.length ); // Just the target group paths

                 

                alert( doc.pathItems.length - doc.groupItems[0].pathItems.length ); // The rest…

                 

                var count = doc.groupItems[0].pathItems.length;

                 

                for ( var i = 0; i < count; i++ ) {

                 

                  doc.selection = doc.groupItems[0].pathItems[i];

                 

                  $.sleep( 500 );

                 

                  app.redraw();

                 

                };

                 

                Just target the required groupItem…? As you can see from this you can isolate any objects within the doc… Should be exactly the same in VB…?

                • 5. Re: How to delete a path item from within a group item?
                  bcrimmins Community Member

                  Gentlemen, thanks for the ideas.  You stimulated the following solution:

                   

                  myPlacedItem.Layer.GroupItems(1).PathItems(1).Delete

                   

                  I couldn't get to the GroupItems or PathItems directly through the PlacedItem object, but once I dove into the layer property... voila!

                   

                  Thanks for your help!

                   

                  Bob