ok so currently i have this
string $cam[] = `ls -sl`;
string $camR[] = listRelatives($cam[0]);
string $camC[] = listConnections($camR[0]);
if (getAttr($camC[0]+".depth" == 2)){
setAttr $camC[0]+".depth" = 10000;
setAttr $camC[0]+".alpha" = 0.5;
setAttr $camR[0]+".nearClipPlane" = 1;
};
which should give you a rough idea of what im trying to do.
it needs to be dynamic so it works with any camera, any name and multiple connections/relations attached to that camera. Basically, if it's a camera that has an imagePlane attached, this script must edit all attributes.
Any suggestions?
Solved! Go to Solution.
ok so currently i have this
string $cam[] = `ls -sl`;
string $camR[] = listRelatives($cam[0]);
string $camC[] = listConnections($camR[0]);
if (getAttr($camC[0]+".depth" == 2)){
setAttr $camC[0]+".depth" = 10000;
setAttr $camC[0]+".alpha" = 0.5;
setAttr $camR[0]+".nearClipPlane" = 1;
};
which should give you a rough idea of what im trying to do.
it needs to be dynamic so it works with any camera, any name and multiple connections/relations attached to that camera. Basically, if it's a camera that has an imagePlane attached, this script must edit all attributes.
Any suggestions?
Solved! Go to Solution.
Solved by Kahylan. Go to Solution.
Solved by Kahylan. Go to Solution.
Hi!
If I understand you correctly, you want to change attributes on all cameras that have connected image planes.
For that you just need to understand some fundamentals about hierarchy and object types.
The shape nodes of Cameras have type "camera" which has its own tag in the ls command.
The shapeNodes of imagePlanes are type "imagePlane" which can be queried during listRelatives. Also imageplanes are children of the shape node of the Camera.
//get all Cameras
string $cams[] = `ls -cameras`;
// loop through cameras
for ($c in $cams){
//get all image Planes parented to camera
string $planes[] = `listRelatives -ad -typ "imagePlane" $c`;
//check if there are image planes
if (size($planes) != 0){
//setAttr on cam
setAttr ($c + ".nearClipPlane") 1;
//setAttr for all imagePlanes
for($p in $planes){
setAttr ($p +".depth") 10000;
setAttr ($p +".alphaGain") 0.5;
}
}
}
This worked for me. But it just made my plane disappear because 10000 is an extremely high depth value.
I hope this helps!
Hi!
If I understand you correctly, you want to change attributes on all cameras that have connected image planes.
For that you just need to understand some fundamentals about hierarchy and object types.
The shape nodes of Cameras have type "camera" which has its own tag in the ls command.
The shapeNodes of imagePlanes are type "imagePlane" which can be queried during listRelatives. Also imageplanes are children of the shape node of the Camera.
//get all Cameras
string $cams[] = `ls -cameras`;
// loop through cameras
for ($c in $cams){
//get all image Planes parented to camera
string $planes[] = `listRelatives -ad -typ "imagePlane" $c`;
//check if there are image planes
if (size($planes) != 0){
//setAttr on cam
setAttr ($c + ".nearClipPlane") 1;
//setAttr for all imagePlanes
for($p in $planes){
setAttr ($p +".depth") 10000;
setAttr ($p +".alphaGain") 0.5;
}
}
}
This worked for me. But it just made my plane disappear because 10000 is an extremely high depth value.
I hope this helps!
Thank you for the reply.
your code does work, but i need it to work for a specific Selection of cameras.
Which is why i used
string $cams[] = `ls -sl`;
could you please modify your code for this scenario?
Thank you for the reply.
your code does work, but i need it to work for a specific Selection of cameras.
Which is why i used
string $cams[] = `ls -sl`;
could you please modify your code for this scenario?
Ah ok, I understand.
Just exchange the declaration of $cams with:
string $cams[] = `ls -sl -dag -lf -cameras`;
Depending on your maya version you'll have to restart your maya before executing the modified script, because the old variable $cams will still be stored in memory.
I hope this helps!
Ah ok, I understand.
Just exchange the declaration of $cams with:
string $cams[] = `ls -sl -dag -lf -cameras`;
Depending on your maya version you'll have to restart your maya before executing the modified script, because the old variable $cams will still be stored in memory.
I hope this helps!
thanks a lot 🙂
and yea i wish there was a way to clear script cache so variables don't get permanently saved into the session.
I've had so many issues because of that "feature"
thanks a lot 🙂
and yea i wish there was a way to clear script cache so variables don't get permanently saved into the session.
I've had so many issues because of that "feature"
Can't find what you're looking for? Ask the community or share your knowledge.