Select to view content in your preferred language

Creating Rule Package With Dropdown of Texture Options

152
1
12-31-2024 07:11 AM
Kayleigh_T
New Contributor

I am attempting to create a rule package that contains a variety of textures that will be selectable in a dropdown list under the inspector tab using an ESRI texture package for signs. I am able to add the texture names under the Enum function, however, I am unsure where I would insert the texture link within the code that the Enum would draw from. The code I have is attached in the screenshots below. I am relatively new to CityEngine and CGA so any help would be appreciated.

Screenshot 2024-12-31 090714.pngScreenshot 2024-12-31 090804.png

0 Kudos
1 Reply
JonasObertuefer
Esri Contributor

Hi @Kayleigh_T ,

See the snippet below for a minimal solution. Instead of storing the list of textures as const array you could also read from a CSV file with the same structure. In the RPK creation dialog you then need to make sure everything is included under "Additional Files".

@Enum (valuesAttr = textureNames)
attr selectedTexture = textureNames[0]
@Hidden
attr textureNames = textureArray[[0:2:size(textureArray)-1]]

const texturePath = "/ESRI.lib/assets/Fences/Textures/"
// for many texture consider reading from a CSV
const textureArray = [
	"brick", "brick_01.jpg";
	"brick2", "brick_03.jpg";
	"stone", "stone_01.jpg" 
]

@StartRule
Lot -->
	primitiveCube()
	texture(texturePath+textureArray[findFirst(textureArray, selectedTexture)+1])

 

Hope this helps,

Cheers
Jonas

0 Kudos