Centre Finder

If you need to find the centre point of a group of selected objects this script will save you a lot of number crunching.

  1. #******************************************************
  2. # Find the Centre
  3. #
  4. # - centrefinder.py
  5. # - Finds the Centre of a Group of Selected Objects
  6. # - By Mark Caldwell
  7. # - Version 0.1
  8. # - 9th May 2006
  9. # - Copyright Mark Caldwell 2006
  10. # - Tested with Vue 5 Infinite 5.09 and Vue 6 Pre Release
  11. #
  12. # How to use in 3 easy steps
  13. #
  14. # 1. Download this file onto your computer
  15. #
  16. # 2. Select Objects to be find centre of
  17. #
  18. # 3. 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. # Internal Variables Set Up: Don't alter these
  25. #----------------------------------------------
  26.  
  27. countobj=CountSelectedObjects()
  28. centre=[0,0,0]
  29.  
  30. #----------------------------------------------
  31. # Find Selected Objects Calculate the Centre
  32. #----------------------------------------------
  33. if countobj>1:
  34. for i in range(0,countobj):
  35. object=GetSelectedObjectByIndex(i)
  36. pos=object.Position()
  37. centre[0]=centre[0]+pos[0]
  38. centre[1]=centre[1]+pos[1]
  39. centre[2]=centre[2]+pos[2]
  40.  
  41. centre[0]=centre[0]/countobj
  42. centre[1]=centre[1]/countobj
  43. centre[2]=centre[2]/countobj
  44.  
  45. #----------------------------------------------
  46. # Find Selected Objects
  47. #----------------------------------------------
  48.  
  49. cube=AddCube()
  50.  
  51. cube.SetPosition(centre[0],centre[1],centre[2])
  52.  
  53. #----------------------------------------------
  54. # Refresh Vue's Display
  55. #----------------------------------------------
  56.  
  57. Refresh()
  58.  
  59. #----------------------------------------------
  60. # End of Script
  61. #----------------------------------------------

impworks © Copyright Mark Caldwell 1996 - 2017