View Full Version : how to resize spheres in a cluster
11-11-2006, 05:01 AM
Don't know if this is exactly a MEL question but am posting it here any way. I work at a drug development company and some of us are working on a project where we are creating an animation on the drug development process. We exported a 3D protein molecule from another application and ran it through the Rheingold conversion app, to convert it into a .MA file. It opens up fine in Maya and shows up as a large cluster of about 9000 spheres. There is plenty of space between the spheres and what we want to do it scale all the spheres so they mesh and overlap each other, so it looks like a big clump of spheres instead of a cluster of individual spheres. Problem is when you select all the objects in the Outliner list and then hit R to resize the objects Maya resizes the objects by enlarging the whole group, i.e. by expanding the distance between the spheres instead of the spheres themselves. Might it be that all 9000 objects have the same scale pivot point, which is in the center of the cluster? Is there any way to change the scale pivot point (assuming my theory is right) on all the objects, so that scaling the objects will make them larger so that they start to overlap each other instead of making the overall cluster larger?
11-12-2006, 06:22 AM
Just gotta make a script that will go to each individual sphere and scale it the way you want. Here's an example to make all the selected objects' scale values double in size:
string $selected = `ls -sl`;
float $scaleVal = 2;
for ($current in $selected)
float $scaleX = `getAttr ($current + ".scaleX")`;
float $scaleY = `getAttr ($current + ".scaleY")`;
float $scaleZ = `getAttr ($current + ".scaleZ")`;
setAttr ($current + ".scaleX") ($scaleX * $scaleVal);
setAttr ($current + ".scaleY") ($scaleY * $scaleVal);
setAttr ($current + ".scaleZ") ($scaleZ * $scaleVal);
11-18-2006, 07:21 PM
Thanks for your reply BlackHwk4, that should get me going once I get past this first hump. I just realized something odd about this protein object. Again it started out as a .pdb file (Protein Data Bank) file, I converted it to .MA format using the 3DWin5 converter in the Rheingold 3D suite. The object in Maya consists of about 9000 spheres in one big cluster, and I want to resize the spheres so they overlap each other. They aren't grouped or parented, all the objects seem to be standalone.
Problem is all the object center points look to be at 0,0,0. I'm fairly new to Maya but I can't find any attribute on any of the spheres that show their actual 3D coordinates, or even their offset from 0,0,0. So when you manually resize any sphere you are actually only increasing the distance from 0,0,0, so it's like the distance from the origin point is considered part of the object. And without finding any actual XYZ location info (other than 0,0,0) in any of the attribute tabs (unless I'm looking in the wrong place) I can't see any way to script the process of modifying the scale center point, then the object size itself. Very strange.
I'm going to see if the 3DWin5 converter offers any options that might change this.
11-19-2006, 02:41 AM
in that case, all you have to do is add
xform -cp $current;
inside the loop of the script above...that moves the pivot to the center of each sphere's bounding box....once you center a pivot you will see the offset in the translation part of the transform. It is a classic affine transformation matrix and detailed in "xform" from the mel command reference on your help menu at the top....
11-19-2006, 09:35 PM
Perfecto! Thank you to both of you, that did the trick. I need to read up on "xform".
11-19-2006, 09:35 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2015, Jelsoft Enterprises Ltd.