Equal Scale Replicate

This python script can be run to equalise the scaling of replicated objects. First you replicate an object in the usual way in Vue (Using Edit -> Replicate) and then you run this script. If you applied a scale to any of the dimensions it will alter the way they are scaled. Vue’s normal scaling for replicate is to scale each object by applying the scale factor to the previous object created. This script sets the scaling to be uniform from one object to the next. This allows stepped pyramids and other similar structures to be quickly created.

[codesyntax lang=”python”]

######################################################################################################
# Equally stepped scalling for objects produced using Vue's replicate feature
#
# - equalreplicate.py
# - By Mark Caldwell
# - Version 0.1.0
# - 7th January 2008
# - Copyright Mark Caldwell 2008
# - Tested with Vue 6 Infinite on a PC
#
# How to use in 3 easy steps
#
# 1. Download and unzip this file onto your computer
#
# 2. Replicate an object in Vue
#
# 3. With the replicated objects still selected run this script
#
######################################################################################################

count=CountSelectedObjects() # Count the number of objects selected

if count>2: # Check there are more than 2 objects so the script will do something

    # Use 2nd and 3rd objects replicated as scale return from first object can be missleading

    object=GetSelectedObjectByIndex(1) # Get the second object
    xyz1=object.GetScale() # Get the scale of the second object
    object=GetSelectedObjectByIndex(2) # Get the third object
    xyz2=object.GetScale() # Get the scale of the third object

    sfx=xyz1[0]/xyz2[0] # Scale factor for x to restore to full size
    sfy=xyz1[1]/xyz2[1] # Scale factor for y to restore to full size
    sfz=xyz1[2]/xyz2[2] # Scale factor for z to restore to full size

    stepx=1-(1/sfx) # Calculate the step scale for equal steps in x
    stepy=1-(1/sfy) # Calculate the step scale for equal steps in y
    stepz=1-(1/sfz) # Calculate the step scale for equal steps in z

    for i in range(1,count): # Loop through the selected objects
        object=GetSelectedObjectByIndex(i) # Get the object
        object.ResizeAxis(sfx**(i+1),sfy**(i+1),sfz**(i+1)) # Scale it to unscaled size
        object.ResizeAxis(1-stepx*i,1-stepy*i,1-stepz*i) # Apply scaling for step

Refresh() # Refresh the display to show the effect of script running

[/codesyntax]

impworks © Copyright Mark Caldwell 1996 - 2024