EcoSystem to Objects
This is a python script that will place a cube at the same location as each instance in an EcoSystem. It gives each cube the same rotation as the instance. It also scales it by the same scale factor in each direction as the instance. There is an additional parameter to allow the scaling to be modified to give better results. A second parameter limits the number of instances that will have objects created for them as the script can crash Vue if large numbers of objects are created. You can increase this number if your computer can cope with larger numbers of objects.
An enhanced version developed for Vue 6 using Vue 6 Pre Release is also included in the zip file. It includes a simple interface so you don’t need to edit the script. It place any of the standard Vue primitive solids at the position of each instance of an object in an ecosystem. You can optionally group or create a metablob from the objects.
These scripts have been supperseeded by the addition of a better feature to do this in Vue itself I’ve left them here as examples of what can be achieved in Vue using Python.
EcoSystem to Objects 0.1 & 0.4 (5k Zip Archive Released)
Python Code – ecotoobject_vue6.py
- #******************************************************
- # Place an object at the position of each instance
- # in an ecosystem
- #
- # - ecotoobject.py
- # - By Mark Caldwell
- # - Version 0.4
- # - 24th April 2007
- # - Tested with Vue 6 Infinite
- #
- # How to use in 4 easy steps
- #
- # 1. Download this file onto your computer
- #
- # 2. Select an object with a populated EcoSystem applied
- #
- # 3. Then run script
- # To run it go to Python -> Run Python Script
- # Then locate the file on your computer
- #
- # 4. Respond to the scripts options and then wait for
- # it to work
- #
- #******************************************************
-
- #----------------------------------------------
- # Collect the user's input
- #----------------------------------------------
-
- group=Prompt('Group Objects?\n 1: Group\n 2: Metablob \n3: No','1',true,'')
-
- form=Prompt('Object Type?\n 1: Cube\n 2: Sphere \n3: Cylinder \n4: Pyramid\n5: Cone\n 6: Torus','1',true,'')
-
- maximum_objects=int(Prompt('Maximum number of objects to create?','1000',true,''))
-
- scale_factor=float(Prompt('Scale Factor for Objects','0.1',true,''))
-
- #--------------------------------------------------------------------------
- # Test the user has a scene loaded
- #--------------------------------------------------------------------------
-
- if TestLoaded():
-
- #--------------------------------------------------------------------------
- # Test the user has 1 object selected with an Eco System on it
- #--------------------------------------------------------------------------
-
- numselected=CountSelectedObjects()
-
- if numselected>1:
- message="Please select only one object."
- elif numselected<1:
- message="Please select an object."
- else:
-
- #--------------------------------------------------------------------------
- #Set Up a Few Variables
- #--------------------------------------------------------------------------
-
- bObject=GetSelectedObjectByIndex(0) # Get first selected object
- Eco = GetEcosystemOnObject(bObject) # Get EcoSystem on first selected
-
- if Eco==None:
- message="Please select an object with an EcoSystem material applied to it."
- elif bObject.IsLocked(): # Check object isn't locked
- message="Please select an object that isn't locked."
- else:
- ecocount=Eco.GetInstanceCount () # Count number of instances in EcoSystem
-
- if ecocount>maximum_objects: # If this is greater than maximum_objects restrict it to maximum objects
- ecocount=maximum_objects
-
- if ecocount==0:
- message="Please select an EcoSystem that has been populated."
- else:
-
- #--------------------------------------------------------------------------
- # Create Objects
- #--------------------------------------------------------------------------
-
- for i in range(0,ecocount):
- pos=Eco.GetInstancePosition (i) # Get instance position
- rot=Eco.GetInstanceRotation (i) # Get instance rotation
- sca=Eco.GetInstanceScale (i) # Get instance scale
-
- if form=='2':
- obj=AddSphere()
- elif form=='3':
- obj=AddCylinder()
- elif form=='4':
- obj=AddPyramid()
- elif form=='5':
- obj=AddCone()
- elif form=='6':
- obj=AddTorus()
- else:
- obj=AddCube() # Create Object
- obj.SetPosition(pos[0],pos[1],pos[2]) # Set object's position
- obj.Rotate(rot[0],rot[1],rot[2]) # Set object's rotation
- obj.ResizeAxis(sca[0]*scale_factor,sca[1]*scale_factor,sca[2]*scale_factor) # Set object's size
-
- if group=='1' or group=='2':
- if i>0:
- obj.SetName(name)
- else:
- name=obj.Name()
-
- DeselectAll()
-
- if group=='1':
- SelectByName(name)
- Group()
- elif group=='2':
- SelectByName(name)
- MetaBlob()
-
- DeselectAll()
- Select(bObject)
-
- message="Eco to Object Successful"
- else:
- message="No Scene Loaded"
-
- Message(message) # Display message
-
- #--------------------------------------------------------------------------
- # End of Script
- #--------------------------------------------------------------------------
Python Code – ecotoobject.py
- #******************************************************
- # Place a cube at the position of each instance of an
- # object in an ecosystem
- #
- # - ecotoobject.py
- # - By Mark Caldwell
- # - Version 0.1
- # - 29th June 2006
- # - Tested with Vue 5 Infinite 5.10 and Vue 6 Pre Release
- #
- # How to use in 4 easy steps
- #
- # 1. Download this file onto your computer
- #
- # 2. Edit the configuration variable maximum_objects below
- # if you want to risk more that 1000 objects
- #
- # 3. Select an object with a populated EcoSystem applied
- #
- # 4. 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
- #
- #******************************************************
-
- #----------------------------------------------
- # Configuration: Set these to alter end result
- #----------------------------------------------
-
- maximum_objects=1000 # maximum_objects sets the maximum number of instances that the script will replace with objects
- # this stops it running away and crashing Vue by trying to add 1 million cubes
-
- #--------------------------------------------------------------------------
- # Test the user has a scene loaded
- #--------------------------------------------------------------------------
-
- if TestLoaded():
-
- #--------------------------------------------------------------------------
- # Test the user has 1 object selected with an Eco System on it
- #--------------------------------------------------------------------------
-
- numselected=CountSelectedObjects()
-
- if numselected>1:
- message="Please select only one object."
- elif numselected<1:
- message="Please select an object."
- else:
-
- #--------------------------------------------------------------------------
- #Set Up a Few Variables
- #--------------------------------------------------------------------------
-
- bObject=GetSelectedObjectByIndex(0) # Get first selected object
- Eco = GetEcosystemOnObject(bObject) # Get EcoSystem on first selected
-
- objlist=[bObject]
-
- if Eco==None:
- message="Please select an object with an EcoSystem material applied to it."
- elif bObject.IsLocked(): # Check object isn't locked
- message="Please select an object that isn't locked."
- else:
- ecocount=Eco.GetInstanceCount () # Count number of instances in EcoSystem
-
- if ecocount>maximum_objects: # If this is greater than maximum_objects restrict it to maximum objects
- ecocount=maximum_objects
-
- if ecocount==0:
- message="Please select an EcoSystem that has been populated."
- else:
-
- #--------------------------------------------------------------------------
- # Create Objects
- #--------------------------------------------------------------------------
-
- for i in range(0,ecocount):
- pos=Eco.GetInstancePosition (i) # Get instance position
- rot=Eco.GetInstanceRotation (i) # Get instance rotation
- sca=Eco.GetInstanceScale (i) # Get instance scale
- object=AddCube() # Create Object
- object.SetPosition(pos[0],pos[1],pos[2]) # Set object's position
- object.Rotate(rot[0],rot[1],rot[2]) # Set object's rotation
- object.ResizeAxis(sca[0],sca[1],sca[2]) # Set object's size
-
- message="Eco to Object Successful"
- else:
- message="No Scene Loaded"
-
- Message(message) # Display message
-
- #--------------------------------------------------------------------------
- # End of Script
- #--------------------------------------------------------------------------


