<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Fitting a rectangle with a given depth into another shape. in ArcGIS CityEngine Questions</title>
    <link>https://community.esri.com/t5/arcgis-cityengine-questions/fitting-a-rectangle-with-a-given-depth-into/m-p/1304543#M11059</link>
    <description>&lt;P&gt;Thank you - sounds like we have a slightly different situation in that I need to generate the plot shapes inside of CE.&amp;nbsp;&lt;/P&gt;&lt;P&gt;To simplify the original question - I need to fit a rectangle / box of a given depth into another shape - the width should be as long as can fit in that shape.&lt;BR /&gt;&lt;BR /&gt;Any ideas?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 29 Jun 2023 16:40:44 GMT</pubDate>
    <dc:creator>MattOlsen</dc:creator>
    <dc:date>2023-06-29T16:40:44Z</dc:date>
    <item>
      <title>Fitting a rectangle with a given depth into another shape.</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/fitting-a-rectangle-with-a-given-depth-into/m-p/1304350#M11054</link>
      <description>&lt;P&gt;Hi all.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to create a rule that places houses of a specified depth and width around the perimeter of a Lot.&lt;BR /&gt;&lt;BR /&gt;The lots are usually not rectangular, and I'm trying to create clusters of houses to maximise efficiency.&lt;/P&gt;&lt;P&gt;What I've tried so far is using the splitAndSetback operation, which carves the boundary into segments. Good so far. Other than houses, some of the buildings need to be perimeter blocks which wrap around the corners, so this operation is very useful.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MattOlsen_2-1688035093448.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/74476i7D3A95EC82BD6348/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MattOlsen_2-1688035093448.png" alt="MattOlsen_2-1688035093448.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm then trying to use the innerRectangle function to create a rectangle, that I can then split into individual shapes that will become the houses.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately, sometimes the innerRectangle is narrower than the depth I need for the houses - see shape on the left.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MattOlsen_0-1688034900684.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/74474i0032D05BC35FF068/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MattOlsen_0-1688034900684.png" alt="MattOlsen_0-1688034900684.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone think of a way to alternate way to fit a rectangle with a fixed depth into these shapes, as pictured below in green?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MattOlsen_1-1688034943687.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/74475iE4AD982D771B04D1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MattOlsen_1-1688034943687.png" alt="MattOlsen_1-1688034943687.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jun 2023 10:39:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/fitting-a-rectangle-with-a-given-depth-into/m-p/1304350#M11054</guid>
      <dc:creator>MattOlsen</dc:creator>
      <dc:date>2023-06-29T10:39:34Z</dc:date>
    </item>
    <item>
      <title>Re: Fitting a rectangle with a given depth into another shape.</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/fitting-a-rectangle-with-a-given-depth-into/m-p/1304354#M11055</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MattOlsen_0-1688035627810.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/74477iB8961CA2857188D1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MattOlsen_0-1688035627810.png" alt="MattOlsen_0-1688035627810.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;For reference, the end goal is something similar to this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jun 2023 10:47:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/fitting-a-rectangle-with-a-given-depth-into/m-p/1304354#M11055</guid>
      <dc:creator>MattOlsen</dc:creator>
      <dc:date>2023-06-29T10:47:52Z</dc:date>
    </item>
    <item>
      <title>Re: Fitting a rectangle with a given depth into another shape.</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/fitting-a-rectangle-with-a-given-depth-into/m-p/1304403#M11056</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I had a similar challenge in a project so I ended up placing the buildings as fixed objects with the correct sizes using the 'i' operation. Thus, regardless of the shape of the &lt;EM&gt;InnerRectangle&lt;/EM&gt;, the building kept its size.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2023-06-29 132947.png" style="width: 453px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/74490iFBB5C1EB876BE5E9/image-dimensions/453x374?v=v2" width="453" height="374" role="button" title="Screenshot 2023-06-29 132947.png" alt="Screenshot 2023-06-29 132947.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had 3 typologies, for the left, right and middle position. I also added scope controls for tunning the position and rotation.&lt;/P&gt;&lt;P&gt;Here's the CGA code:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;/**	
 * File:    Townhouses.cga
 * Created: 24 May 2023 13:17:26 GMT
 * Author:  PFontes
 */

version "2022.1"

@Enum("Lawn 1", "Lawn 2") @Order(3)
attr grassType = "Lawn 1"
@Order(4)
attr xTextureSize = 5
@Order(5)
attr zTextureSize = 5

@Range(min=-180, max=180, restricted=true)
attr rotateScope = 90

@Range(min=-10, max=10, restricted=false)
attr scopeTranslateX = 0
@Range(min=-10, max=10, restricted=false)
attr scopeTranslateY = 0
@Range(min=-10, max=10, restricted=false)
attr scopeTranslateZ = 0

@Enum("Left", "Right", "Centre")
attr villaType = "Centre"

@Enum("uvtest", "white")
attr textureType = "uvtest"

Lot --&amp;gt;
    innerRectangle(scope) { shape: GrassTexture Insert | remainder: GrassTexture}

InsertVilla --&amp;gt;
	case villaType == "Left":
		i("Townhouses/Townhouse Semi Left.dae", yUp, keepSizeAndPosition) 
		center(xz) 
		projectUV(0) 
		softenNormals(0) 
		comp(f){horizontal: GenericTexture | all: GenericTexture}
	case villaType == "Right":
		i("Townhouses/Townhouse Semi Right.dae", yUp, keepSizeAndPosition) 
		center(xz) projectUV(0) 
		softenNormals(0) 
		comp(f){horizontal: GenericTexture | all: GenericTexture}
	else:
		i("Townhouses/Townhouse.dae", yUp, keepSizeAndPosition) 
		center(xz) 
		softenNormals(0) 
		comp(f){horizontal: GenericTexture | all: GenericTexture}

Insert --&amp;gt;
		rotateScope(0, rotateScope, 0)
		t(scopeTranslateX, scopeTranslateY, scopeTranslateZ)
		alignScopeToAxes(y)
		InsertVilla

GenericTexture --&amp;gt;
	case textureType == "uvtest":
		texture("/ESRI.lib/assets/General/uvtest.png")
		setupProjection(0, scope.xy, 1, 1, 0, 0, 1)
		projectUV(0)
	else: White.
		
 GrassTexture --&amp;gt;
    case grassType== "Lawn 1":
		setupProjection(0, scope.xz, xTextureSize, zTextureSize)
		texture("assets/Lawn 1.jpg")
		projectUV(0)
	else:
		setupProjection(0, scope.xz, xTextureSize, zTextureSize)
		texture("assets/Lawn 2.jpg")
		projectUV(0)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jun 2023 12:37:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/fitting-a-rectangle-with-a-given-depth-into/m-p/1304403#M11056</guid>
      <dc:creator>plfontes</dc:creator>
      <dc:date>2023-06-29T12:37:21Z</dc:date>
    </item>
    <item>
      <title>Re: Fitting a rectangle with a given depth into another shape.</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/fitting-a-rectangle-with-a-given-depth-into/m-p/1304498#M11057</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/488390"&gt;@plfontes&lt;/a&gt;&amp;nbsp;- the way you've centred the assets is useful. How are you carving up the original Lot into the individual houses (I can't see this in the CGA) - is that with the in-built subdivision types for the Block?&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jun 2023 15:47:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/fitting-a-rectangle-with-a-given-depth-into/m-p/1304498#M11057</guid>
      <dc:creator>MattOlsen</dc:creator>
      <dc:date>2023-06-29T15:47:25Z</dc:date>
    </item>
    <item>
      <title>Re: Fitting a rectangle with a given depth into another shape.</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/fitting-a-rectangle-with-a-given-depth-into/m-p/1304509#M11058</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;The plot shapes were imported from GIS. Not done in CE.&lt;BR /&gt;But this rule would have worked the same way if the subdivision was done in CE, although probably less precise.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jun 2023 15:58:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/fitting-a-rectangle-with-a-given-depth-into/m-p/1304509#M11058</guid>
      <dc:creator>plfontes</dc:creator>
      <dc:date>2023-06-29T15:58:05Z</dc:date>
    </item>
    <item>
      <title>Re: Fitting a rectangle with a given depth into another shape.</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/fitting-a-rectangle-with-a-given-depth-into/m-p/1304543#M11059</link>
      <description>&lt;P&gt;Thank you - sounds like we have a slightly different situation in that I need to generate the plot shapes inside of CE.&amp;nbsp;&lt;/P&gt;&lt;P&gt;To simplify the original question - I need to fit a rectangle / box of a given depth into another shape - the width should be as long as can fit in that shape.&lt;BR /&gt;&lt;BR /&gt;Any ideas?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jun 2023 16:40:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/fitting-a-rectangle-with-a-given-depth-into/m-p/1304543#M11059</guid>
      <dc:creator>MattOlsen</dc:creator>
      <dc:date>2023-06-29T16:40:44Z</dc:date>
    </item>
    <item>
      <title>Re: Fitting a rectangle with a given depth into another shape.</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/fitting-a-rectangle-with-a-given-depth-into/m-p/1304793#M11063</link>
      <description>&lt;P&gt;One way I can think is to use the &lt;EM&gt;offset subdivision&lt;/EM&gt; to have this level of control over the shape of the plots. But from looking at your images, seems that you have already used it. Another option would be not to use shape subdivision but use the&amp;nbsp;&lt;EM&gt;split()&lt;/EM&gt; operation and fix the size of the split on X and Z axis.&lt;/P&gt;&lt;P&gt;For example, this test rule I created while ago for filling a grid of 9x9m cell size within any given plot using&lt;EM&gt; split()&lt;/EM&gt; instead of subdividing the initial block.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;/**
 * File:    grid_test.cga
 * Created: 25 Sep 2022 07:40:38 GMT
 * Author:  PFontes
 */

version "2019.1"

attr gridCellSize = 9
attr setbackAll = 0
@Enum("Global", "Local")
attr alignment = "Global"

@StartRule
Lot --&amp;gt;
	setback(setbackAll){all: NIL | remainder: Parcel}
	
Parcel --&amp;gt;
	case alignment == "Global" :
		alignScopeToAxes(world.xyz)
		split(x){gridCellSize: mirrorScope(false,true,false) set(scope.tz, 5) split(z){gridCellSize: A}*}*
	else :
		alignScopeToGeometry(yUp, any, longest)
		split(x){gridCellSize: mirrorScope(true,false,true) set(scope.tz, -setbackAll) split(z){gridCellSize: A}*}*
	
A --&amp;gt;
	innerRectangle(scope){shape: label("Bldg") B | remainder: NIL}
	
B --&amp;gt;
	case geometry.area &amp;lt;= 60 : NIL
	else: extrude(rand(3,6))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Check if any of this can help you.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2023 09:41:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/fitting-a-rectangle-with-a-given-depth-into/m-p/1304793#M11063</guid>
      <dc:creator>plfontes</dc:creator>
      <dc:date>2023-06-30T09:41:18Z</dc:date>
    </item>
    <item>
      <title>Re: Fitting a rectangle with a given depth into another shape.</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/fitting-a-rectangle-with-a-given-depth-into/m-p/1305570#M11067</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/488390"&gt;@plfontes&lt;/a&gt;&amp;nbsp;- appreciate all of your input. I haven't been able to do exactly what I wanted, but using some of your code I've got something close.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MattOlsen_0-1688483509121.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/74773i827A3E18708C118E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MattOlsen_0-1688483509121.png" alt="MattOlsen_0-1688483509121.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jul 2023 15:12:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/fitting-a-rectangle-with-a-given-depth-into/m-p/1305570#M11067</guid>
      <dc:creator>MattOlsen</dc:creator>
      <dc:date>2023-07-04T15:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: Fitting a rectangle with a given depth into another shape.</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/fitting-a-rectangle-with-a-given-depth-into/m-p/1305578#M11068</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Glad to be of help&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jul 2023 15:25:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/fitting-a-rectangle-with-a-given-depth-into/m-p/1305578#M11068</guid>
      <dc:creator>plfontes</dc:creator>
      <dc:date>2023-07-04T15:25:01Z</dc:date>
    </item>
  </channel>
</rss>

