Skip navigation
Currently Being Moderated

finding duplicate path(object) without selecting

Nov 23, 2009 9:14 PM

Hi all,

 

Is it possible to find the duplicate pathitem in the document without selecting those pathitems.It is possible to find the duplicate path items by selecting all the objects in the ducument,but i m not getting any clue to find the same without selecting.

 

If it is possible then please give some suggestion on how to achive this ?

 

 

Thanks,

Sanat

 
Replies
  • Currently Being Moderated
    Nov 28, 2009 7:15 AM   in reply to sanatkumar1

    i`m not quite sure what you`re asking, but i hope this somehow helps your goal:

     

     

    //let's create the duplicate first

    var b = app.activeDocument.selection[0];
    b.name = "##SOURCE##";

    b.duplicate();

     

    app.activeDocument.selection[0].name = "##DUPLICATEDSOURCE##";

     

    //let's test if we can find and remove our previously duplicated object
    var mydupObj = app.activeDocument.pageItems.getByName("##DUPLICATEDSOURCE##");
    mydupObj.remove();

     

     

    hope it helps;

    cheers;

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 29, 2009 1:35 AM   in reply to sonicDream

    i might've misunderstood your question first time ... probably you`re looking to check if 2 objects are duplicates without creating the duplicate programatically. if so this might give you an inside look. test it by creating a shape, selecting it, copying it and pasting it in place ... you can play with the ignoreProperties string to make the comparison more general:

     

    var doc = app.activeDocument;
    var sel = app.activeDocument.selection;
    var ignoreProperties = "|name||width||height|";

     

    function AreDuplicates(o1, o2) {
        for(prop in sel[0]) {
            try {
                if(sel[0][prop] != sel[1][prop] && ignoreProperties.indexOf("|" + prop + "|") > -1) return false;
             } catch(er) {}
             finally { continue; }
        }
        return true;
    }
    if(AreDuplicates(sel[0], sel[1])) alert("Wheeee, they are sooooooooo duplicated!");
    else alert("Damn and i really hoped that ... never mind!");

     

     

    hope it helps;

     

    cheers;

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 1, 2009 8:39 AM   in reply to sanatkumar1

    * removed by author *


     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points