Ok, @Tchunoo_Kahng, I’m gonna go forward and view your challenge as a nail, though it probably isn’t… And then I’m gonne use the biggest hammer of them all. It’s not efficient, it’s very slow, it’s quite complicated, but it’s very cool anyways. Consider this response as digression and an attempt to lure you into the realm of multiobjective genetic algorithms.
The hammer I’m talking about is the Optimo package.
You can read a little bit about it here, but in effect Optimo is a multiobjective genetic algorithm which can be used to solve a multitude of problems, and as it turns out, it can be used in your case as well.
Here is a view from a Revit model with some model lines that I used for this example:
This is the main graph:
Now it seems pretty harmless up until this point, but the magic happens within the OptimizeOffsetDistance node, which is simply a custom node I built myself. Opened up, it looks like this:
Now the build up of this graph is based on the Optimo package almost entirely, you can read a little bit more about it here: http://jbdynamo.blogspot.no/2016/04/dynamo-and-optimo-optimizing-your-carl.html
There is some things in this node you will have to consider:
The size of your “population”. Doesn’t matter much in this example since it is just one objective that we are going to “optimize”
The lower and upper limits for the parameter you want to explore, this will be the offset distance in your example. Mind you that I haven’t worked in any error handling in this script, like for instance if the polycurve is offsetted beynd itself and return nulls etc etc. Also I’ve made this script independent of direction, that’s why I go from -20000 to 20000 and let the algorithm sort it out itself.
This is the fitness function. This is a custom node that I made that measures the area of the polycurve I’ve made and compare it to the desirable area we want, that would be 70% of the original area, right.
Number of iterations, or generations, that we want to run. This greatly effects the accuracy of the results, but also the total runtime a lot. Start out small and increase if it’s not working as expected.
As I said, this graph is not very efficient, but it works. With just 10 generations the result is pretty accurate, Increase the number of iterations and it would be even better.
Now hopefully, someone can come along and provide an easier solution for you!
Example files here: https://www.dropbox.com/sh/oo78y6c5hesbitg/AAB-xy6Ia_PGY3ejArCdc71Qa?dl=0