How to use a texture path outside of the project?

720
1
11-11-2016 06:10 AM
LauraK_
New Contributor

Hi everyone! I' relatively new to texturing with CityEngine and ArcGIS Pro. The starting issue was that texturing wall in ArcGIS Pro (v. 1.3.1) didn't work as expected, you can scale the texture, but only both sides at once. I have a photo of my wall and the extruded polygon where I want to drape it on, but it repeated the photo as a pattern. When scaling it larger, the image got cut off on top and bottom of the wall.

Thus, I changed to CityEngine to drape the texture on the wall manually with a rule file. In the rule file, I can specify UV, the file path and other parameters so that the image is not cut off, and rotated correctly. However, this only works as long as I have the rule in "MyProject/rules" and the texture photo in "MyProject/images/image.jpg". My problem is now that I want the image to be replacable so that I can share the rule package to a person and this person can use it in ArcGIS Pro for a wall, choose the path of the texture file and gets the textured wall as output. To enable the input of the texture path, I want to use the object attributes, so that the file path is written in a column of the attribute table.

However, it doesn't matter whatever I use as filepath, it just does not work at all. The only correct path in CityEngine was the relative path "/MyProject/images/image.jpg". I tried using the fileSearch, an absolute path "C:\users\user\ArcGIS\etc...", tried using "/" and "\" and even putting the texture file on a server. Nothing worked.

attr InfraImage = ""

Infra = InfraImage

@StartRule
@InMesh
Facade -->
    texture(Infra)


I use the attribute "InfraImage" which is mapped to the object attribute "InfraImage". This object attribute then contains the path to the file. It is then used to texture the facade.

Does anyone know how include a path to a texture in a rule file?

0 Kudos
1 Reply
CherylLau
Esri Regular Contributor

First, in the rule above, I noticed that the UV texture coordinates are not set.  The texture() operation only sets the filename but does not set the UV coordinates.  If the shape doesn't have UV coordinates, it can be set and applied using setupProjection() and projectUV().  (But, you mention this in the text that you were able to get this working, so maybe this is not the problem.)

Second, using file paths that reference something outside of the CityEngine workspace is not possible.  This is why paths that start with "C:/" will not work.  You can only access files within the CityEngine workspace.  You can access files outside of the current project though.  See Matt's reply to this post about absolute and relative paths.  https://community.esri.com/thread/184099-import-cga-rule-from-different-cityengine-project?et=watche... 

For example, ESRI.lib is outside of your project but inside the workspace.  Here is some code that uses a texture from ESRI.lib.  The attribute wall_tex has the @File annotation which allows users to choose a file through a file browser (click on drop down arrow for attribute in Inspector).  Alternatively, you can link the attribute to get the filepath from the object attribute wall_tex which is assigned to the shape (Click on drop down arrow next to attribute -> Connect Attribute -> Select "Object attribute").

@File
attr wall_tex = "/ESRI.lib/assets/Facades/International/Groundfloors/g_f001_t001_Educational_000.jpg"

Lot -->
     extrude(50)
     comp(f) { all: Face }
     
Face -->
     setupProjection(0, scope.xy, '1, '1)
     texture(wall_tex)
     projectUV(0)
0 Kudos