How to apply color to polyline in CityEngine?

512
4
01-09-2019 08:33 AM
KathrynAngleton
New Contributor III

Hi GeoNet community!

I have a boundary polyline shapefile that I've brought into CE and would like to change the color of it. Seems that the default for polylines is still graph networks. Is there a rule file to override this? If not, I do have the boundary as a polygon but really only want the outline of the polygon colored and the inside hollow to show the basemap under. The apply color rule file from the Redlands Example doesn't appear to have any language to specify an outline color to a polygon either. Any help to achieve this is greatly appreciated.

0 Kudos
4 Replies
KathrynAngleton
New Contributor III

I was able to find a workaround- converting graphs to shapes and then applying colors to the shapes with a rule file, however, if someone still has any recommendations on how to go about creating a rule file that can treat polygon coloring/symbology like it is in ArcMap with an outline and a fill, that would be great.

0 Kudos
CherylLau
Esri Regular Contributor

If you can import your shape as a polygon (instead of polyline), then you can apply a cga rule to it which only colors the edges by using the comp operation to get the edges.  You can hide the shapes (F11 or in viewport menu) so that you don't see the imported polygon face.

const edge_width = 0.2

ColorEdges -->
	comp(e) { all: Edge }
	
Edge-->
	primitiveCube
	s('1, edge_width, edge_width)
	center(yz)
	color(1,0,0)‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
DevinLavigne
Occasional Contributor III

Sorry Kathryn - I'm just seeing this now. What Cheryl Lau‌ has provided is what you would do with your shape/polygon, but I think there is a way to apply her rule directly to your polyline. The polyline will import as a graph layer. From the inspector set your sidewalk widths to zero and then your streetWidth to the width you would like your polyline to be. From there you can apply Cheryl's rule to your "street". I had to use this type of solution working with some pavement markings once. Not at all what its intended for, but a clever work around nonetheless. 

0 Kudos
CherylLau
Esri Regular Contributor

What Devin is suggesting requires even simpler code, and I would recommend doing this over the polygon option since it eliminates the need for the comp().  If you set the street width to your desired edge width, then you can also skip the resizing and centering bit.  Using extrude() instead of primitiveCube() is also an option if you want to control the height of your edge.  Extrude will handle curvy streets better.

Street -->
     extrude(edge_height)    # or: primitiveCube()
     color(1,0,0)‍‍‍‍‍‍
0 Kudos