4 Replies Latest reply on Jun 24, 2017 10:17 PM by karth80472045

    check line passes through circle through script

    karth80472045 Level 1

      Hello every one ,

       

      i need your help i want to check line passes through circle or touches the circle points then i have to check this line and circle lies on the same group.

       

       

      here if you see line passes through circle and line touches the circle so these two lines should be in the same group . i have to check only lying in the same group. can anybody tell me the logic to write in the script. please help me.

       

      Line stroke weight is 1.417pt

      circle stroke weight is 0.567 pt

       

      with regards

      yogi

        • 1. Re: check line passes through circle through script
          Silly-V Adobe Community Professional

          Somewhat difficult to understand question.

          • 2. Re: check line passes through circle through script
            karth80472045 Level 1

            Thanks for the Prompt reply,

            i will explain clearly

             

             

            i required to check via scripting

             

            Line1 ,circle1 ,line2 ,circle2, circle 3,line3 and line4 all should be in same group .

             

            if Line1 and circle1in group .

            like this

             

             

            Then it is wrong

             

             

             

            this also wrong how it should be

             

             

             

             

            so the main checking is line and circle intersecting or touching the circumference of a circle should lie in the same group.

             

            other wise it is wrong i have throw as an error . can anybody help me how to write in the script

             

            with regards,

            yogesh.v

            • 3. Re: check line passes through circle through script
              moluapple Level 4

              Hi, this snippt will group all the blue paths, but without the red paths. For test, you need to ungroup the exists group first.

              1.PNG

              (function() {
                  var d = activeDocument,
                      p = d.pathItems,
                      l = p.length,
                      i,
                      circle = [],
                      abs = [],
                      base = d.artboards.length;
                  for (i = 0; i < l; i++) {
                      if (p[i].strokeWidth == 0.567) { //make sure that only the circle's stroke width = 0.567
                          circle.push(p[i]);
                          abs.push(d.artboards.add(p[i].geometricBounds)); // create artboards from each circle
                      }
                  }
                  var g = d.groupItems.add();
                  for (i = abs.length - 1; i >= 0; i--) {
                      d.artboards.setActiveArtboardIndex(base + i);
                      d.selectObjectsOnActiveArtboard(); // select all path touches the circle center
                      d.artboards.remove(base + i);
                      app.redraw();
                      if (app.selection.length == 1 && app.selection[0] == circle[i]) {
                          continue; // only the circle itself selected, so it should not in group
                      }
                      if (app.selection.length > 1 && g.pageItems.length && g.selected == false) {
                          g = d.groupItems.add(); // the selection does not belong the exists group, so add a new one
                      }
                      g.selected = false;
                      for (var s = app.selection, j = s.length - 1; j >= 0; j--) {
                          s[j].moveToBeginning(g);
                      }
                  }
              })()
              
              • 4. Re: check line passes through circle through script
                karth80472045 Level 1

                thank you very much sir !!!!