# Space Planning within a Polygon

**URL:** <https://forum.dynamobim.com/t/space-planning-within-a-polygon/62579>\
**Category:** Generative Design\
**Tags:** geometry, dynamo, refinery, generative-design\
**Created:** [April 6, 2021, 4:31pm UTC](https://forum.dynamobim.com/t/space-planning-within-a-polygon/62579 "2021-04-06T16:31:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![michelle.mackD3WWQ](https://avatars.discourse-cdn.com/v4/letter/m/9f8e36/32.png) [@michelle.mackD3WWQ](https://forum.dynamobim.com/u/michelle.mackD3WWQ)\
**Post date:** [April 6, 2021, 4:31pm UTC](https://forum.dynamobim.com/t/space-planning-within-a-polygon/62579/1 "2021-04-06T16:31:22Z")

</div>

Hello, I’m trying to use Dynamo and Refinery to create options for laying out rectangles within a polygon (or boundary). The goal is to use generative design to find different options for rectangle placements within a boundary and score the designs based on the rectangles proximity to one another and eventually what is the usability of the leftover space once all the rectangles have been placed. I haven’t built all the scoring criteria out yet, but my main issue is that I cannot get the rectangles to stay within the given boundary - which in my case is a polygon - and results in creating ONLY false options being shown in Refinery. I’ve tried scoring the outputs of the polygon.contains and geometry.doesintersect nodes to try and “maximize” those values in the optimization study in Refinery with no luck. How do I either filter out options which are not within the boundary before going into Refinery, or not allow the options to be created in the first place within the code? Below is my graph, the outputs I’m getting in Refinery (ran multiple ways using Randomize, Optimize, etc and all the results look like this), and and example of the expected outputs.

my graph:

 ![Space Analysis - GD](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/3/e360ce83823cc8c744d89dd67797a45bc0e09a88.png)

my Refinery outputs (note: it only displays rectangles if they fit within the boundary which in this case is none, so that’s why you only see the 3 points which are the centerpoint of the rectangles):

 ![Refinery Outputs](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/f/3f095d8e76a292af8fbe485f8f95c2ec2bb16352.png)

and what I am trying to achieve by fitting the rectangles within the boundary:  
 ![Expected Results dynamo](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/4/04bfac6f5e4a16692581db864801d21dec5881ec.png)

Any help would be appreciated. I’m still quite new to this 🙂 Thank you!

 ![Space Analysis - GD](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/3/e360ce83823cc8c744d89dd67797a45bc0e09a88.png)

---

<div class="post-metadata">

**Author:** ![565384351](https://avatars.discourse-cdn.com/v4/letter/5/7cd45c/32.png) [@565384351](https://forum.dynamobim.com/u/565384351)\
**Post date:** [June 28, 2021, 3:03pm UTC](https://forum.dynamobim.com/t/space-planning-within-a-polygon/62579/2 "2021-06-28T15:03:37Z")

</div>

Has your problem been solved? I also encountered a similar problem.

---

<div class="post-metadata">

**Author:** ![michelle.mackD3WWQ](https://avatars.discourse-cdn.com/v4/letter/m/9f8e36/32.png) [@michelle.mackD3WWQ](https://forum.dynamobim.com/u/michelle.mackD3WWQ)\
**Post date:** [June 28, 2021, 3:38pm UTC](https://forum.dynamobim.com/t/space-planning-within-a-polygon/62579/3 "2021-06-28T15:38:19Z")

</div>

nope not yet, sorry

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [June 28, 2021, 4:49pm UTC](https://forum.dynamobim.com/t/space-planning-within-a-polygon/62579/4 "2021-06-28T16:49:34Z")

</div>

You can’t exactly tell GD not to create options that fail if it won’t know they fail until the option has been created. You have to take a more proactive approach. Think about the constraints of your design. Since the dimensions of your rectangles and boundary are already known, you can constrain the allowable locations for each rectangle to stay within the boundary. Rather than your number slider representing the location within the maximum extents of the boundary, have them represent a percentage within the _allowable_ range of the boundary. This should drastically reduce the number of “bad” options you get. It also doesn’t look like you’re running nearly enough iterations for GD to determine an optimized location for something that is going to have a lot of failed options.

---

<div class="post-metadata">

**Author:** ![565384351](https://avatars.discourse-cdn.com/v4/letter/5/7cd45c/32.png) [@565384351](https://forum.dynamobim.com/u/565384351)\
**Post date:** [July 1, 2021, 11:28am UTC](https://forum.dynamobim.com/t/space-planning-within-a-polygon/62579/5 "2021-07-01T11:28:56Z")

</div>

Hello! How to ensure that the rectangles in the generated plan do not overlap each other?

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [July 1, 2021, 1:16pm UTC](https://forum.dynamobim.com/t/space-planning-within-a-polygon/62579/6 "2021-07-01T13:16:37Z")

</div>

That’s where your fitness function comes in. Again, you can’t tell the computer not to do something that won’t actually fail until it happens. Your fitness function would probably just be to minimize the amount of overlap area.
