A possible script for finding "holes" of a planar closed curve

 From:  mkdm
8645.1 
Hi Michael.

Working on my 2D workflow involving Moi and Affinity Designer I often need to select all the closed curve in Moi
that can be considered as "holes" of a given closed curve.
And I have to do this operation manually. Very tedious.

I don't remember if someone has already written something like that but if not,
I thought of writing this new command : "FindHoles".

But before I do, I want to post this pseudo code and ask if do you think it's a good way or not.
For what I've simulated it should be.

For a better understanding of what I want to do you can also check this brief video : http://take.ms/HJ6Zj



Anyway, this is the pseudo code :

code:

1) CURRENT LIMITATION : All the curves must be planar and must lay on the TOP plane

2) I first select the curve for which I want to find possible "HOLES"

3) I then select the set of all the other curves that I consider "candidate holes"

4) I run this "FindHoles" command that perform these tasks :

Step A) I assign the first selected curve, at index 0 of selected curves, to the variable "IN_CURVE"
Step B) If "IN_CURVE" is not CLOSED then I exit

Step C) I assign all other selected curves, starting from index 1 of selected curves, to the variable "CAND_HOLES"
Step D) If "CAND_HOLES" is EMPTY then I exit

Step E) I perform the "Planar" command on "IN_CURVE"
I call the resulting surface "PLAN_IN_CURVE"

Step F) I enter this loop that should find all "holes" of "IN_CURVE"
This is the pseudo code of the loop :

***** LOOP START *****

For each "ELEMENT" in "CAND_HOLES"

Step 1) I perform the "Project" command

Step 2) "Object to Project" = "ELEMENT"

Step 3) "Projection Target" = "PLAN_IN_CURVE" with : TOP as selected projection plane, "Closest pt" as projection options

Step 4) I get the possible resulting curve and call it "PROJ_RES"

Step 5) If I get no "PROJ_RES" then "ELEMENT" is NOT a "hole" of "IN_CURVE"

Step 6) If "PROJ_RES" is an OPEN curve then "ELEMENT" is NOT a "hole" of "IN_CURVE"

Step 7) If "PROJ_RES" is a CLOSED curve then "ELEMENT" IS a "hole" of IN_CURVE and I add it to the resulting array "FOUND_HOLES"

Step 8) Next (For each)

***** LOOP END *****


At the end I deselect everything and I select all the curves in "FOUND_HOLES"

What do you think ?

Thanks a lot.

Marco (mkdm)