I discovered today that fileSearch and fileRandom will not return a result if there is a space in the path.
For example print(fileRandom(/Project Name/*.*)) will not work but print(fileRandom(/DifferentProjectName/*.*)) does. I renamed my project but it broke a ton of references in other places. Is there a way to get around this limitation? or chr(32)...something like that?
It is incredible how much of rule design is just filename management.
This is actually not a bug. Whitespace inside the searchQuery string in fileSearch/filesSearch indicates AND in the query. Using whitespace, two or more queries can be AND-ed. See the last example in the doc.
https://doc.arcgis.com/en/cityengine/latest/cga/cga-file-search-function.htm
The same applies to other functions which use fileSearch: assetApproxRatio, assetApproxSize, assetBestRatio, assetBestSize, assetFitSize, fileRandom, imageApproxRatio, imageBestRatio
In order to put whitespace into a filepath, use single quotes:
filesSearch("'Wall Textures/*.png'")
Alternatively, the escape characters \s and \x20 also work to replace a space. Note that an extra backslash is needed so the cga compiler interprets it correctly (instead of as a normal backslash).
filesSearch("Wall\\sTextures/*.png")
filesSearch("Wall\\x20Textures/*.png")