So all day I have been setting up some cameras and was getting annoyed at starting from the center grid each time I created a new camera. What I usually do if I have to create only a few cameras is to use the camera bookmarks and then transfer them over to the new camera, that way if I accidentally move the new camera before locking it I can easily reset the position back to the bookmark. Then I thought it would be cool to write something that did all this for me automatically so I’m just here to share with you guys what I created. Let me know if you like!
//Create Camera From View
/*
Developed by: Shawn Frueh
Web: www.shawnfrueh.com
Email: sfrueh@shawnfrueh.com
Description:
This script will create a camera from your current view using camera bookmarks.
The new camera will take the name of your current camera with the addition _NEW to the end.
UPDATE: Script now works with bookmarks that have changed from their default names.
Now closes the bookmark window after creating a bookmark.
*/
// Select the current viewports camera
string $camera;
string $curView = `getPanel -wf`;
$camera = `modelEditor -q -camera $curView`;
select ($camera+"Shape");
// Create a bookmark
cameraBookmarkEditor $camera;
cameraBookmarkNewCB cameraBookmarkWindow $camera;
// Close bookmark window
deleteUI cameraBookmarkWindow;
// Find all bookmarks on current camera
select -noExpand `listHistory ("|"+$camera+"|"+$camera+"Shape")`;
select -d ($camera+"Shape");
string $sel[] = `ls -sl`;
int $selCount = size($sel);
// Find unNamned Bookmarks
select "cameraView*";
string $sel2[] = `ls -sl`;
int $selCount2 = size($sel2);
//rename bookmark
rename ("cameraView"+$selCount2) "fromView";
// Create and name new camera
CreateCameraOnly;
rename ($camera+"_FromView");
// Add the new camera name as a string
string $cameraFV = ($camera+"_FromView");
//Connect the bookmark to the new camera
connectAttr fromView.message ($cameraFV+".bookmarks[0]");
// Apply the bookmark to the new camera
cameraView -e -animate (`optionVar -q animateRollGotoBookmark`) -camera $cameraFV -setCamera fromView;
// Remove old connection
disconnectAttr fromView.message ("|"+$camera+"|"+$camera+"Shape.bookmarks["+($selCount-1)+"]");
// Finish by renaming new camera
rename ($camera+"_FromView") ($camera+"_NEW");
rename fromView "NewfromView";