Offset or scale closed polycurve to target area

so this might be more of a question regarding mathematics, but my searches have failed to find a solution in any of the cad/gis/bim forums. I have a site plan with around 200 parcels created in civil3d, which i have turned into closed polylines, and want to visualize what the site would look like with each parcel populated with a mass with a footprint that is simply a scaled version of the parcel geometry with 70% of the parcel area.

What is the math behind scaling or offsetting a closed polycurve to a target area? I roughly remember it using a simple function with a square-root but cannot for the life of me recall the exact procedure.

@Tchunoo_Kahng Could you please include some sketches/images and files to better explain your issue.

1 Like

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. :slight_smile:
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:

  1. The size of your “population”. Doesn’t matter much in this example since it is just one objective that we are going to “optimize”

  2. 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.

  3. 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.

  4. 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! :wink:

Example files here: https://www.dropbox.com/sh/oo78y6c5hesbitg/AAB-xy6Ia_PGY3ejArCdc71Qa?dl=0

5 Likes

@jostein_olsen Holy talk about the biggest hammer of them all! That is indeed Absolutely one hell of a digression, matter of fact your post digressed from an answer to a great crash course to optimo for me!

I was in a sleepless stupor with a dash of desperation as you can tell from my incoherent questioning, so @Vikram_Subbaiah I apologize for any confusion. This is a simple test of what i was going for, with the solution from the gracious steven-g from the autocad drafting techniques forums(Check it Out!).

back to you @jostein_olsen, so this is definitely my next step, but i have some questions to you as a user of optimo. Im still in a sleepless stupor so the nodes for NSGA-II is intimidating, but to me the pros clearly are over say galapagos is that it can be embedded into a particular custom node for easier use for those unfamiliar with optimization, like your OptimizeOffsetDistance node? I have been exporting geometry to grasshopper and using galapagos for this and its quite a hassle when Im the only one who can use grasshopper at the office. Are there any shortcomings compared to galapagos, except for the obvious lack of UI? I really appreciate the crashcourse into optimo and especially your examples!

Well, thanks. We’re a bit off thread here I guess so we should probably discuss this in another post, but my initial two cents are this:
Cons:
-It is pretty slow.

  • It is even slower when working with Dynamo geometry, especially when you have a large population.
  • No UI as stated and very “manual” setup.
  • It can be tricky to get the replication and lacing strategies right, depending on what kind of problem you’re facing.

Pros:

  • When you finally “get it” you have a broader understanding of how optimalization works, and you can apply it to other problems quite easily.
  • The feeling when you make it work is awesome! :slight_smile:

Please feel free to post a seperate thread about this, maybe we all can learn a lot more!