I have modeled a 3D image of a whale and have to scale the total length (in the y dimension) and then scale individual vertex groups (in the x and z direction).
The scaling factors used for the vertex groups are based on the radial measurement I want it to reflect divided by the radial measurement of the individual model. However, using measureit I have found that when scaling the length only in the y direction is still slightly changes the radial measurement of the vertex groups, and therefore changes what the scaling factor for the vertex groups should be.
Since I am working with a large amount of data I cannot scale the total length, measure the circumference of the vertex groups and then scale the vertex groups accordingly. Is there any way to insure that while scaling in the y direction all other measurements are secured in place?
The code I am using is as follows:
import bpy
obj = bpy.context.active_object
totallength = .843504
whale = [0]
vgrp = ['Face', 'Reye', 'Rpostpec', 'Rantdslfin', 'Rpostpdslfin', 'Ranus',
'Rmidkeel', 'Rend']
sfac =[0.792018666, 0.792018666, 0.818984445,0.857604997,0.821038612,0.623493015,0.56712762,0.56712762] #list of all scaling factors for vertex groups
def scale(vgrp,sfac):
'''
scale vertex group of name vgrp
based on scaling factor of name sfac
'''
bpy.ops.object.mode_set(mode='EDIT') #set program in edit mode
bpy.ops.mesh.select_all(action='DESELECT') #deselect any previously selected vertex groups
bpy.ops.object.vertex_group_set_active(group=vgrp) #set vertex group active based on name in vgrp
bpy.ops.object.vertex_group_select() #select active vertex group
bpy.ops.transform.resize(value=(sfac, 1, sfac)) #resize vertex group by sfac
bpy.ops.object.mode_set(mode='OBJECT') #set program in object mode
def scale_whale(a,whale,vgrp,sfac):
bpy.ops.object.mode_set(mode='OBJECT') #set program in object mode
bpy.ops.transform.resize(value=(1, totallength, 1)) #resizes the length of the whale (only the y axis) based on an index in total length corresponding to the index in whale
for v in vgrp:
scale(v, sfac[vgrp.index(v)])
scale_whale(obj, whale, vgrp, sfac)
