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.

[codesyntax lang=”python”]

#******************************************************
# Find the Centre
#
# - centrefinder.py
# - Finds the Centre of a Group of Selected Objects
# - By Mark Caldwell
# - Version 0.1
# - 9th May 2006
# - Copyright Mark Caldwell 2006
# - Tested with Vue 5 Infinite 5.09 and Vue 6 Pre Release
#
# How to use in 3 easy steps
#
# 1. Download this file onto your computer
#
# 2. Select Objects to be find centre of
#
# 3. Then run script and wait for it to work
#    To run it go to Python -> Run Python Script
#    Then locate the file on your computer
#
#******************************************************
#----------------------------------------------
# Internal Variables Set Up: Don't alter these
#----------------------------------------------

countobj=CountSelectedObjects()
centre=[0,0,0]

#----------------------------------------------
# Find Selected Objects Calculate the Centre
#----------------------------------------------
if countobj>1:
    for i in range(0,countobj):
        object=GetSelectedObjectByIndex(i)
        pos=object.Position()
        centre[0]=centre[0]+pos[0]
        centre[1]=centre[1]+pos[1]
        centre[2]=centre[2]+pos[2]

    centre[0]=centre[0]/countobj
    centre[1]=centre[1]/countobj
    centre[2]=centre[2]/countobj

#----------------------------------------------
# Find Selected Objects
#----------------------------------------------

    cube=AddCube()

    cube.SetPosition(centre[0],centre[1],centre[2])

#----------------------------------------------
# Refresh Vue's Display
#----------------------------------------------

    Refresh()

#----------------------------------------------
# End of Script
#----------------------------------------------

[/codesyntax]

impworks © Copyright Mark Caldwell 1996 - 2024