Selecting Random OBJ from assets folder

1004
2
08-30-2016 04:19 AM
KristianMortensen1
New Contributor III

Hello, I'm new to city engine and is trying to write a cga rule file which will import one of 14 sketchup models (parking towers) onto a lot. I have imported  the models into the asset folder as OBJ files and then use this piece of code

Street -->
      i(listRandom(fileSearch("Towers/Tower_*.obj")))
      s(8.5,12.17,5.59)
      rotate(abs, world, 0, 90, 0)
      center(xz) #ParkingTower

which works, now comes the problem, when I add the rulefile to more that one piece of "shape" and update Seed it chooses the same model at all the shapes which are not what I wanted, I wanted 14 shapes ~ 14 different towers. 

I can update each segment of the road, which will give me a new building on that segment, but if I update it 3 times and then update another segment 3 times it will generate the same building, so it seems that it is not random at all  Does anybody have any advice on how I can make it chose a truly random obj?

Tags (3)
0 Kudos
2 Replies
KennethLindhardt
Occasional Contributor

If I understand you correctly…

I would do it like this

 

Street --> 
      i(fileRandom("Towers/Tower_*.obj"))
      s(8.5,12.17,5.59) 
      rotate(abs, world, 0, 90, 0) 
      center(xz) #ParkingTower

KristianMortensen1
New Contributor III

Thanks Kenneth, that solved the problem!

0 Kudos