Skip to main content
Participant
November 21, 2009
Answered

checking closed path

  • November 21, 2009
  • 1 reply
  • 1042 views

Hi Guys,

I am new to scripting, I am able to check the closed paths but I am struck in some problem.

Whenever I delete some segments from closed path and rejoin leaving a particular segment outside a newly made closed path, my script fails to recognize the opened path. have attached the screen shots.

In the second image after deleting the segment i am not able to recognize the path which is out segment that closed path.

Here is my code:

var thePathed = app.activeDocument;

for (var a = 0; a < thePathed.pathItems.length; a++)
{

    app.activeDocument = thePathed;

    var aPath = thePathed.pathItems;
           
    for (var b = 0; b < aPath.subPathItems.length; b++)
        {
            if (aPath.subPathItems.closed == false)
            {
                           
                alert("Error in Path Name: "+ aPath.name)
                       
            }
        }
           
}
alert ("Path checking Finished")

Any suggestions on this is appreciable.

Thank you in advance.....

Regards,

Annesh MRD

This topic has been closed for replies.
Correct answer Michael_L_Hale

I am attaching the SampleImage for your reference.


I think I see what is wrong. You edited the path in a way that made it a complex path not seperate paths.

Try this

var thePathed = app.activeDocument;

for (var a = 0; a < thePathed.pathItems.length; a++)
{

    app.activeDocument = thePathed;

    var aPath = thePathed.pathItems;
          
    for (var b = 0; b < aPath.subPathItems.length; b++)
        {
            if ( aPath.subPathItems.operation ==  ShapeOperation.SHAPEXOR || aPath.subPathItems.closed == false )
            {
                          
                alert("Error in Path Name: "+ aPath.name)
                      
            }
        }
          
}
alert ("Path checking Finished")

Inspiring
November 21, 2009

Your code does give a 'Error in Path' alert for me if there is an open subpath.

Participant
November 23, 2009

Thank you....

Still I have some problem.

Here I am attaching the screen shot with the lable ABC.

A   --  I have created the path for full image

B   --  deleted two segments in path

C   --  After deleting I closed the path of below portion, the path of the above potion is open only

After running the script its not showing any error even through path of the above portion is open.

Inspiring
November 23, 2009

Your second image is 'QUEUED' so I can see it now. I did follow your instructions in the frist post and the script found the open path. Could you try posting a jpg with the path that causes you trouble? JPG files support paths so the path will be in the file. PNG does not.