EKL Finding Hole Centers From a Non-Connex Curve

EKL Finding Hole Centers From a Non-Connex Curve

This something I have done several times over the years and its demonstrates some useful techniques.

Disassembley

I typically will work from in an Action first then move the code to the required Knowledgeware object, Rule, reaction, Knowledge Pattern etc. This way I can control when the code runs and what the inputs and outputs are in the specification tree.

First step is to disassemble the non-connex curve that represents all of the boundaries. However we want to maintain each connex boundary as a whole. This is done by using the Boolean value “True”, in the disassemble method, to maintain closed boundaries.

Finding Holes

Now that we have the curves, we need to find curves that are specifically round or close to round depending on where the geometry came from. To do this we will compare the surface area of each hole to the mathematical definition of the hole area based on the minimum curvature radius of the curve.

Outputting the Hole Centers

Now that we know what is round (in air quotes, based on tolerance) we can get the center of gravity point and output this as a comma, semi-colon separated list as a string. So we will need a string parameter in the specification tree to receive the value, this can then be manipulated in excel to get the center points.

First we need to add a New output String which we can equate to the string in the specification tree. Then we will add a counter to keep track of the number of found circles and initialize the value to 1.

Finally we can then extract the hole position and add it to the output string.