Community
Maya Animation and Rigging
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya animation topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to access Camera Bookmark Editor with hotkeys?

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
amaterasu-qbb
652 Views, 8 Replies

How to access Camera Bookmark Editor with hotkeys?

Hi! everyone.

 

I want to access Camera Bookmark Editor with a hotkey. I found this command is MEL Procedure.

# mel procedure
cameraBookmarkEditor;

Is there a command to access this in either Pymel or maya.cmds or MEL to access the Camera Bookmark Editor?

Any help would be appreciated.

Bookmark EditorBookmark Editor

Thanks,

Labels (3)
8 REPLIES 8
Message 2 of 9
dinofiguera
in reply to: amaterasu-qbb

The command wants you to specify also a camera. For example, "persp".
cameraBookmarkEditor persp;

Message 3 of 9
amaterasu-qbb
in reply to: dinofiguera

Hi! @dinofiguera .

 

Thanks for your answer.


@dinofiguera wrote:

The command wants you to specify also a camera. For example, "persp".
cameraBookmarkEditor persp;



It works when I use the cameraBookmarkEditor persp;
But the camera name has to be accepted no matter what it is. So, the commands I thought I could use are cmds.ls(camera = True) and cmds.listCameras().

import maya.cmds as cmds

def getCameraName:
    getCamName = cmds.ls(ca = True)
    camList = cmds.listCameras(getCamName)

# Error: invalid syntax

I don't know what kind of code I should make.

Any help would be appreciated.

Message 4 of 9
dinofiguera
in reply to: amaterasu-qbb

Unfortunately, I never used Python in my life. I´m an old-school MEL grampa, 
I write my tools in MEL, and guess what? I´m not even a programmer. I just learned how to assemble code pieces that I find around. 
Getting the camera from the viewport sounds simpler than it actually is.  There might be a one-line code in Python
But I have always used this piece of MEL code in my scripts, 
That has been always reliable.


global string $gMainPane;
 
string $mainPaneCtls[];
string $visPanels[];
string $panelName;
string $panelCtl, $edCtl;
string $modelEd;
int    $nArr;
int    $i;
string $newViewFound;
string $newView;
 
//
//  First try to find something in the main pane.
//
if ($gMainPane != "") {
 
 
$mainPaneCtls = `paneLayout -q -ca $gMainPane`;
$nArr = size($mainPaneCtls);
for ($i = 0; $i < $nArr; $i++) {
$panelName = `getPanel -containing $mainPaneCtls[$i]`;
if ("" != $panelName) {
if ("modelPanel" == `getPanel -to $panelName`) {
if (!`control -q -io $mainPaneCtls[$i]`) {
$modelEd = `modelPanel -q -modelEditor $panelName`;
if ("" != $modelEd) {
//
// If this view is already active, let's
// continue to use it.
//
if (`modelEditor -q -activeView $modelEd`)
{
$newView = $modelEd;
string $camera = `modelPanel -q -camera $newView`;
print $camera;
 
 
//put your commands to execute here
 
break;
}
}
}
}
}
}
}
return $newView;
 
//Hope this helps!
//Dino
Message 5 of 9
amaterasu-qbb
in reply to: dinofiguera

Hi! @dinofiguera .
I have put cameraBookmarkEditor into //put your commands to execute here in your code.
I entered the following error code and could not open the Camera Bookmark Editor.

global string $gMainPane;
 
string $mainPaneCtls[];
string $visPanels[];
string $panelName;
string $panelCtl, $edCtl;
string $modelEd;
int    $nArr;
int    $i;
string $newViewFound;
string $newView;
 
//
//  First try to find something in the main pane.
//
if ($gMainPane != "") {
 
 
$mainPaneCtls = `paneLayout -q -ca $gMainPane`;
$nArr = size($mainPaneCtls);
for ($i = 0; $i < $nArr; $i++) {
$panelName = `getPanel -containing $mainPaneCtls[$i]`;
if ("" != $panelName) {
if ("modelPanel" == `getPanel -to $panelName`) {
if (!`control -q -io $mainPaneCtls[$i]`) {
$modelEd = `modelPanel -q -modelEditor $panelName`;
if ("" != $modelEd) {
//
// If this view is already active, let's
// continue to use it.
//
if (`modelEditor -q -activeView $modelEd`)
{
$newView = $modelEd;
string $camera = `modelPanel -q -camera $newView`;
print $camera;
 
cameraBookmarkEditor
 
break;
}
}
}
}
}
}
}
return $newView;
// Error: break;
// Error: Line 40.5: Syntax error
// Error: return $newView;
// Error: Line 48.16: Use of "return" statement is only valid within a procedure definition.
editMenuUpdate MayaWindow|mainEditMenu;

To confirm, cameraBookmarkEditor was able to find the code for the mel Procedure.

//
//  Procedure Name:
//      cameraBookmarkEditor
//
//  Description:
//      Display an editor for editting the bookmarks associated with
//      camera.
//
global proc cameraBookmarkEditor( string $camera )
{
    string $title = (uiRes("m_cameraBookmarkEditor.kBookmarkEditor"));
    $title = `format -s $camera $title`;

    string $win = `window -title $title -iconName (uiRes("m_cameraBookmarkEditor.kBookmarks")) cameraBookmarkWindow`;
        formLayout winForm;
            textScrollList -height 180 list;

            columnLayout -adj true col;
                textFieldGrp -label (uiRes("m_cameraBookmarkEditor.kName")) name;
                textFieldGrp -label (uiRes("m_cameraBookmarkEditor.kDescription")) desc;
                separator -style none -height 15;

                formLayout btnForm;
                    button -label (uiRes("m_cameraBookmarkEditor.kApply")) apply;
                    button -label (uiRes("m_cameraBookmarkEditor.kAddToShelf")) shelf;
                    button -label (uiRes("m_cameraBookmarkEditor.kNewBookmark")) new;
                    button -label (uiRes("m_cameraBookmarkEditor.kNew2DBookmark")) new2D;
                    button -label (uiRes("m_cameraBookmarkEditor.kDelete")) del;
                setParent ..;

                button -label (uiRes("m_cameraBookmarkEditor.kClose")) close;


    formLayout -e
        -af apply left 0
        -af apply top 0
        -ap apply right 2 15
        -af apply bottom 10

        -af shelf top 0
        -ap shelf left 0 15
        -ap shelf right 2 35
        -af shelf bottom 10

        -af new top 0
        -ap new left 0 35
        -ap new right 2 58
        -af new bottom 10

        -af new2D top 0
        -ap new2D left 0 58
        -ap new2D right 2 85
        -af new2D bottom 10

        -af del right 0
        -af del top 0
        -ap del left 0 85
        -af del bottom 10

        btnForm;

    formLayout -e
        -af list left 15
        -af list top 10
        -af list right 15
		-ac list bottom 10 col

        -af col left 10
        -af col bottom 10
        -af col right 10

        winForm;

   buildBookmarkList($camera);

   textScrollList -e -sc ("cameraBookmarkListCB "+$win) list;
   textScrollList -e -dcc ("cameraBookmarkApplyCB "+$win+" "+$camera) list;
   textScrollList -e -dkc ("cameraBookmarkDelCB "+$win+" "+$camera) list;
   textFieldGrp -e -cc ("cameraBookmarkNameCB "+$win+" "+$camera) name;
   textFieldGrp -e -cc ("cameraBookmarkDescCB "+$win+" "+$camera) desc;
   button -e -c ("cameraBookmarkApplyCB "+$win+" "+$camera) apply;
   button -e -c ("cameraBookmarkShelfCB "+$win+" "+$camera) shelf;
   button -e -c ("cameraBookmarkNewCB "+$win+" "+$camera) new;
   button -e -c ("cameraBookmarkNew2DCB "+$win+" "+$camera) new2D;
   button -e -c ("cameraBookmarkDelCB "+$win+" "+$camera) del;
   button -e -c ("deleteUI "+$win) close;

    showWindow $win;
}

I would like to follow @dinofiguera 's example of how you were able to create an awesome MEL command even though you are not a programmer. I'm not a programmer either, but I want to do my best.😄

Any help would be appreciated.

Message 6 of 9
dinofiguera
in reply to: amaterasu-qbb

My mistake, as the error said, the command "Return" needs to be inside a procedure, and to simplify, I took out the script from its procedure. That´s a non-programmer mistake. 🙂
This is the correct code to open the camera bookmark editor from your current view.
If this worked out for you, please accept it as a solution.

global proc string openBookmarkEditor() {
 
global string $gMainPane;
 
string $mainPaneCtls[];
string $visPanels[];
string $panelName;
string $panelCtl, $edCtl;
string $modelEd;
int    $nArr;
int    $i;
string $newViewFound;
string $newView;
 
//
//  First try to find something in the main pane.
//
if ($gMainPane != "") {
 
 
$mainPaneCtls = `paneLayout -q -ca $gMainPane`;
$nArr = size($mainPaneCtls);
for ($i = 0; $i < $nArr; $i++) {
$panelName = `getPanel -containing $mainPaneCtls[$i]`;
if ("" != $panelName) {
if ("modelPanel" == `getPanel -to $panelName`) {
if (!`control -q -io $mainPaneCtls[$i]`) {
$modelEd = `modelPanel -q -modelEditor $panelName`;
if ("" != $modelEd) {
 
if (`modelEditor -q -activeView $modelEd`)
{
$newView = $modelEd;
string $camera = `modelPanel -q -camera $newView`;
cameraBookmarkEditor $camera;
print $camera;
break;
}
}
}
}
}
}
}
return $newView;
}
 
openBookmarkEditor();




"I would like to follow @dinofiguera 's example of how you were able to create an awesome MEL command even though you are not a programmer. I'm not a programmer either, but I want to do my best."

Not sure what you mean but I like to think there is no negative irony here, 
Just because I am spending time of my life to solve your problem. 🙂
Cheers

Dino

 

Message 7 of 9
amaterasu-qbb
in reply to: dinofiguera

Thank you very much. @dinofiguera .
I was able to confirm that your code solves the problem. I decided to write a new message to you because just accepting your solution is not enough to express my gratitude.


I am sorry if my writing offended you. I apologize. I usually double-check my sentences after translating them with the Deepl translation tool, but I still ended up with such a rude sentence. I promise to be very careful not to do that in the future.

 

What I wanted to say was that I feel like I can't do anything and that I need to learn and improve, and that it is my dream to be able to help this community.

Anyway, to @dinofiguera , thank you very much.

Message 8 of 9
dinofiguera
in reply to: amaterasu-qbb

Hey Man, no problem. I´m glad that this helped out. Don´t worry, It is not easy to offend me 😄  
I wrote that answer in a good mood, I´m just a straightforward Italian guy. I like to be direct and to fight 
this political correctness that is destroying humanity 😄

 

Message 9 of 9
amaterasu-qbb
in reply to: dinofiguera


@dinofiguera wrote:

Hey Man, no problem. I´m glad that this helped out. Don´t worry, It is not easy to offend me 😄  
I wrote that answer in a good mood, I´m just a straightforward Italian guy. I like to be direct and to fight 
this political correctness that is destroying humanity 😄

 


Ha ha. I did not expect to hear the term "political correctness" mentioned.🤣🤣🤣
I too dislike political correctness. It is unfortunate that I am in Japan, the most separated country with regard to political correctness. However, Autodesk may see what we are talking about and block us. I don't care what happens to me. (However, I will be marching in protest to tell Autodesk Japan to get out of Japan.)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report