Plant Replace

This python script replaces selected objects with plants from a random list of Vue’s plants.

  1. #******************************************************
  2. # Replace Place Holder Object With Plant
  3. # - plant_replace.py
  4. # - Replace Selected Objects with Plants
  5. # - By Mark Caldwell
  6. # - Version 0.2
  7. # - 5th October 2006
  8. # - Tested with Vue 5 Infinite 5.09 and Vue 6 Pre Release
  9. #
  10. # How to use in 4 easy steps
  11. #
  12. # 1. Download this file onto your computer
  13. #
  14. # 2. Edit the configuration variables below
  15. #
  16. # 3. Select Objects to be Replace in Vue Infinite
  17. #
  18. # 4. Then run script and wait for it to work
  19. # To run it go to Python -> Run Python Script
  20. # Then locate the file on your computer
  21. #
  22. #******************************************************
  23.  
  24. import random
  25.  
  26. #----------------------------------------------
  27. # Configuration: Set these to alter end result
  28. #----------------------------------------------
  29.  
  30. plantlist = ["08wMapleR",
  31. "08uMaple",
  32. "07_Plum",
  33. "08tmSummerCherry",
  34. "08tnFallCherry",
  35. "08toBlossomingCherry",
  36. "09_Acacia",
  37. "06_Fir",
  38. "10_Coconut"] # This is the file names of the plant to use
  39.  
  40. directory="C:\Documents and Settings\Mark Caldwell\My Documents\e-on software\Vue 6 Infinite\Plants\" # set the directory your plants are stored in
  41.  
  42. displacement_x=0 # This is added to the objects x position when placing the plant
  43. displacement_y=0 # This is added to the objects y position when placing the plant
  44. displacement_z=0 # This is added to the objects z position when placing the plant
  45. scale=1 # This is used to scale the plant
  46. drop=0 # If this is set to 1 the plant is dropped onto the nearest object under it
  47. shift_z=0 # If the plant is dropped the replaced object must be moved out of the way.
  48. # This is the z displacement applied to move them after they have been replaced
  49.  
  50. #----------------------------------------------
  51. # Internal Variables Set Up: Don't alter these
  52. #----------------------------------------------
  53.  
  54. poso=[]
  55. ran = random.Random()
  56. count=CountSelectedObjects()
  57. countplant=len(plantlist)-1
  58.  
  59. #----------------------------------------------
  60. # Find Selected Objects
  61. #----------------------------------------------
  62.  
  63. for i in range(0,count):
  64. object=GetSelectedObjectByIndex(i)
  65. poso.append(object.Position())
  66. object.SetPosition (0,0,shift_z)
  67.  
  68. #----------------------------------------------
  69. # Add Plants
  70. #----------------------------------------------
  71.  
  72. for i in range(0,count):
  73. file=directory+plantlist[ran.randint(0,countplant)];
  74. plant = AddPlant(file)
  75. posp=poso[i]
  76. plant.SetPosition((posp[0]+displacement_x),(posp[1]+displacement_y),(posp[2]+displacement_z))
  77. plant.Resize(scale)
  78. if drop==1:
  79. Drop()

impworks © Copyright Mark Caldwell 1996 - 2017