PDA

View Full Version : Global Smooth script....


sinistar
12-06-2006, 09:06 PM
Hi,

I want to mimic Keegan3Ds script to work in Maya6 on linux. Basically all I need to do is get all of the polySmoothFace.division attributes on all objects in my scene to be at the same level of divisions.

Unfortunately, whenever I try this:
setAttr "polySmoothFace*.divisions" 0;

I get this error:
// Error: Not enough data was provided. The last 10 items will be skipped. //

So apparantly asterisks don't work in this situation? Could someone tell me a way I could pull that off?

thanks

unsmoothed
12-06-2006, 10:07 PM
You can use the,
ls -g;
command to get all the names of the scene's geometry into an array, then use 'objectType' on each one to determine whether it's a 'mesh' or 'nurbsSurface', smooth it if it needs smoothing and/or set the division level at the same time.

-u(n)

grantimus
12-06-2006, 10:41 PM
here ya go:


string $smoothNodes[] = `ls -type polySmoothFace`;
for($smoothNode in $smoothNodes)
setAttr ($smoothNode + ".divisions") 0;

unsmoothed
12-06-2006, 10:52 PM
or you could just do it the shorter way.... :D

sinistar
12-07-2006, 02:46 PM
thanks guys,

Unsmoothed I would like to understand how to use the ls -g along with object type. Maybe you could show me how it would work here.

ANd Grantimus thanks man. I think this will work for the most part but unfortunately some of the "polySmoothFace" nodes have incoming connections as they are connected to resolution level controls..... this seems to trip up the script :(

grantimus
12-07-2006, 07:41 PM
if you can't run setAttr on the ".divisions" attribute because somthing is already connected to it, then run this script:


string $smoothNodes[] = `ls -type polySmoothFace`;
string $connectionPlugs[];
for($smoothNode in $smoothNodes){
$connectionPlugs = `listConnections -p 1 ($smoothNode + ".divisions")`;
if(size($connectionPlugs) == 0)
setAttr ($smoothNode + ".divisions") 0;
else{
setAttr $connectionPlugs[0] 0;
}
}

unsmoothed
12-07-2006, 10:19 PM
here it is in full... hope it helps
-U



window;
columnLayout -adj 1;
intSliderGrp -label "Divisions" -f 1 -min 0 -max 4 -fmn 0 -fmx 4 -v 1 -dc "adjustSmooth(`intSliderGrp -q -v divSliderCtrl`)" divSliderCtrl;
setParent ..;

showWindow;

global proc adjustSmooth(int $numberOfSmoothDivisions) {
// put the shape names of all geo into an array
string $geometryNameArray[] = `ls -g`;
string $geometryNameItem;

string $hasSmoothNode[];

for ($geometryNameItem in $geometryNameArray) {
// only act on poly meshes...
if (`objectType $geometryNameItem` == "mesh") {
// check for the smooth node...
$hasSmoothNode = `listConnections -et 1 -t "polySmoothFace" $geometryNameItem`;

if (startsWith ($hasSmoothNode[0], "polySmoothFace") == 1) {
// has been smoothed previously, so set the .division level using '$numberOfSmoothDivisions'
setAttr ($hasSmoothNode[0] + ".divisions") $numberOfSmoothDivisions;
} else {
// no smooth node found, so add one using '$numberOfSmoothDivisions' at the same time...
polySmooth -mth 0 -dv $numberOfSmoothDivisions -c 1 -kb 1 -ksb 1 -khe 0 -kt 1 -kmb 1 -suv 1 -sl 1 -dpe 1 -ps 0.1 -ro 1 -ch 1 $geometryNameItem;
}
}

}

select -cl;
}

grantimus
12-08-2006, 01:00 AM
another good way of generating an array that references all the mesh objects in the scene is like this:

filterExpand -sm 12 `ls -tr`;

sinistar
12-11-2006, 12:49 AM
thanks Grantimus that worked great! and I willl try the one you posted too Unsmoothed when i'm at a maya station

CGTalk Moderation
12-11-2006, 12:49 AM
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.