<?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: Dynamic case? in ArcGIS CityEngine Questions</title>
    <link>https://community.esri.com/t5/arcgis-cityengine-questions/dynamic-case/m-p/200862#M2651</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ZR,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In that case, it is possible to do this if you are ok with splitting by percentile.&lt;/P&gt;&lt;P&gt;For example lets say we have 10 floors. The split.index tells me what floor my rule is currently evaluating, and the split.total tells me how many total floors there are.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So lets say I want the first 20% to be one color, and the next percentage to be another color.&lt;/P&gt;&lt;P&gt;Pseudo code would be: &lt;BR /&gt;attr split_Percent_1=.2&lt;/P&gt;&lt;P&gt;attr split_Percent_2=.4&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;case split.index/split.total-1&amp;lt;= split_Percent_1: color(1,0,0)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;case (split.index/split.total-1)-split_Percent_1&amp;lt;= split_Percent_2: color(1,1,0)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;else: color(1,1,1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This code has errors/problems, but the idea is that you are coloring based on the percent of the total number of floors. If you want something more complex there are other options to try. I am trying to understand the design specifications you have for this split.index based rule.&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 08 Jan 2015 00:32:13 GMT</pubDate>
    <dc:creator>DavidWasserman</dc:creator>
    <dc:date>2015-01-08T00:32:13Z</dc:date>
    <item>
      <title>Dynamic case?</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/dynamic-case/m-p/200859#M2648</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm generating some buildings (well, building envelopes) with variable floor counts (attribute "aog") and color for each of the floors. Right now I simply have the maximum number of floors inserted manually and catch the top with "aog-1". Is there a way to do this in a more flexible way?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's the rule file:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;version "2014.0"


attr aog = 0
attr maxLength = scope.sx
attr maxWidth = scope.sz
attr maxHeight = 3.0*aog
attr opacityslider = 0.8


#--------------------------------


Lot --&amp;gt;
&amp;nbsp; set(material.opacity,opacityslider)
&amp;nbsp; innerRect
&amp;nbsp; s(maxLength+1,'1,maxWidth+1)
&amp;nbsp; center(xyz)
&amp;nbsp; extrude(maxHeight)
&amp;nbsp; Building

Building --&amp;gt;
&amp;nbsp; comp(f){side: BuildingBody | top: Roof }


BuildingBody --&amp;gt;
&amp;nbsp; split(y){ maxHeight/aog: BuildingFloors }*


BuildingFloors --&amp;gt;
&amp;nbsp; comp(f){all: ColorMe(split.index)}



ColorMe(FloorIndex) --&amp;gt;
&amp;nbsp; case FloorIndex == aog-1: color(0,1,1)
&amp;nbsp; case FloorIndex == 0: color(1,0,0)
&amp;nbsp; case FloorIndex == 1: color(0,1,0)
&amp;nbsp; case FloorIndex == 2: color(0,0,1)
&amp;nbsp; case FloorIndex == 3: color(1,1,0)
&amp;nbsp; case FloorIndex == 4: color(1,0,0)
&amp;nbsp; case FloorIndex == 5: color(0,1,0)
&amp;nbsp; case FloorIndex == 6: color(0,0,1)
&amp;nbsp; case FloorIndex == 7: color(1,1,0)
&amp;nbsp; case FloorIndex == 8: color(1,0,0)
&amp;nbsp; case FloorIndex == 9: color(0,1,0)
&amp;nbsp; case FloorIndex == 10: color(0,0,1)
&amp;nbsp; case FloorIndex == 11: color(1,1,0)
&amp;nbsp; else: color(0.5,0,0)



Roof --&amp;gt;
&amp;nbsp; color(1,1,1)
&amp;nbsp; roofGable(35,0,0,false)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="colormeeee.png" class="jive-image image-1" src="https://community.esri.com/legacyfs/online/48281_colormeeee.png" style="width: 620px; height: 280px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:59:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/dynamic-case/m-p/200859#M2648</guid>
      <dc:creator>LR</dc:creator>
      <dc:date>2021-12-11T09:59:53Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic case?</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/dynamic-case/m-p/200860#M2649</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Z R, &lt;BR /&gt;This depends on what you are trying to do. Do the colors have to be the colors you selected? Can they be random colors?&lt;/P&gt;&lt;P&gt;When working with buildings often it helps to develop ranges of color rather than specific floors. So for example I might define that the 1st to 5th floor to be red (FloorIindex&amp;lt;=5), and everything else to be be another color. If you need each floor be a unique color you could just use&amp;nbsp; color(rand(0,1),rand(0,1), rand(0,1)).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you need something to be related to the total number of floors, you can also call the &lt;A href="http://cehelp.esri.com/help/index.jsp?topic=/com.procedural.cityengine.help/html/cgareference/attr_split.html"&gt;split.total &lt;/A&gt;to get that total number of splits. I have used this with some basic arithmetic to create automatic ranges and make decisions based on how big or long something actually is. This could for example be used to create a gradient based on the floors starting at one value at the top and descending to another at the bottom.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are options. I hope this is helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Jan 2015 22:24:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/dynamic-case/m-p/200860#M2649</guid>
      <dc:creator>DavidWasserman</dc:creator>
      <dc:date>2015-01-07T22:24:17Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic case?</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/dynamic-case/m-p/200861#M2650</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a gradient would be good - the current colors are just for testing. Ideally I'd like to create dynamic rules for each split (basically like rule_splitindex) but that doesn't seem possible. For full-range rand the range doesn't have to be specified, if you want to save some typing. It's also not really random but uses the lot's seed.. which can be set with set(seedian, &amp;lt;somenumber&amp;gt;). Now if only there was some seed that produced gradients.. &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/silly.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jan 2015 00:15:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/dynamic-case/m-p/200861#M2650</guid>
      <dc:creator>LR</dc:creator>
      <dc:date>2015-01-08T00:15:10Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic case?</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/dynamic-case/m-p/200862#M2651</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ZR,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In that case, it is possible to do this if you are ok with splitting by percentile.&lt;/P&gt;&lt;P&gt;For example lets say we have 10 floors. The split.index tells me what floor my rule is currently evaluating, and the split.total tells me how many total floors there are.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So lets say I want the first 20% to be one color, and the next percentage to be another color.&lt;/P&gt;&lt;P&gt;Pseudo code would be: &lt;BR /&gt;attr split_Percent_1=.2&lt;/P&gt;&lt;P&gt;attr split_Percent_2=.4&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;case split.index/split.total-1&amp;lt;= split_Percent_1: color(1,0,0)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;case (split.index/split.total-1)-split_Percent_1&amp;lt;= split_Percent_2: color(1,1,0)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;else: color(1,1,1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This code has errors/problems, but the idea is that you are coloring based on the percent of the total number of floors. If you want something more complex there are other options to try. I am trying to understand the design specifications you have for this split.index based rule.&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jan 2015 00:32:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/dynamic-case/m-p/200862#M2651</guid>
      <dc:creator>DavidWasserman</dc:creator>
      <dc:date>2015-01-08T00:32:13Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic case?</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/dynamic-case/m-p/200863#M2652</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but I need to use fixed heights (floors*3m), so it's not applicable in this case. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Might come in handy later, though!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jan 2015 02:12:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/dynamic-case/m-p/200863#M2652</guid>
      <dc:creator>LR</dc:creator>
      <dc:date>2015-01-08T02:12:00Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic case?</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/dynamic-case/m-p/200864#M2653</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's how to do a gradient (using red, blue, or green). Change your BuildingFloors rule to this, and omit ColorMe rule:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BuildingFloors --&amp;gt; color(1, split.index/(split.total-1), split.index/(split.total-1))&amp;nbsp; &lt;/P&gt;&lt;P&gt;# Change placement of 1 to do the other colors.(G and B)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Capture2.JPG" class="jive-image image-1" src="https://community.esri.com/legacyfs/online/48485_Capture2.JPG" style="height: auto;" /&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use two ones to make CMYK colors:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BuildingFloors --&amp;gt; color(1, 1, split.index/(split.total-1))&amp;nbsp; # Yellow gradient&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or use built in CityEngine colorRamp function:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BuildingFloors --&amp;gt; color(colorRamp("greenToRed", split.index/(split.total-1)))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Capture3.JPG" class="jive-image image-2" src="https://community.esri.com/legacyfs/online/48486_Capture3.JPG" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 1.5;"&gt;To make roof match, color it using:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 1.5;"&gt;color(colorRamp("greenToRed", 1)) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let us know if this this works, then we talk about the rule_ thing.&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jan 2015 15:04:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/dynamic-case/m-p/200864#M2653</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2015-01-08T15:04:36Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic case?</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/dynamic-case/m-p/200865#M2654</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's just what I was looking for. Thanks &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jan 2015 16:06:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/dynamic-case/m-p/200865#M2654</guid>
      <dc:creator>LR</dc:creator>
      <dc:date>2015-01-08T16:06:34Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic case?</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/dynamic-case/m-p/200866#M2655</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The Gradient is a lot easier to do than a percentile split. This is the best option if this is what you need. Glad Chris could make an example. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jan 2015 16:47:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/dynamic-case/m-p/200866#M2655</guid>
      <dc:creator>DavidWasserman</dc:creator>
      <dc:date>2015-01-08T16:47:39Z</dc:date>
    </item>
  </channel>
</rss>

