// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // // // Creation Date: October 25, 1996 // // Description: // This a helper script which will create a new bookmark // containing the objects displayed within an editor. // // Input Arguments: // The name of the editor to modify // The type of the bookmark to create // // Whether a dialog should be popped to prompt the // user for a bookmark name or not. // // Return Value: // None. // global proc createBookmark (string $editor, string $type, int $popDialog) { // The default base name for bookmarks // string $defaultBaseName = "Bookmark"; // Make sure the editor exists // if (!`editor -exists $editor`) { error (uiRes("m_createBookmark.kEditorNotFound")); } // First, find out what is connected to this editor // string $mainListConnection = `editor -query -mainListConnection $editor`; if ($mainListConnection == "") { if (`modelEditor -exists $editor`) { $mainListConnection = "activeList"; } else { error (uiRes("m_createBookmark.kNoObjectsToBookmark")); } } // Now create a new bookmark, and add all of the objects to it // string $objects[]; // If this is a model editor and it has an objectSet then bookmark those members // int $foundObjects = false; if (`modelEditor -exists $editor`) { string $objectSet = `modelEditor -query -viewObjects $editor`; if ($objectSet != "") { $objects = `sets -query $objectSet`; $foundObjects = true; } } if (!$foundObjects) { $objects = `selectionConnection -query -object $mainListConnection`; } if (size ($objects) > 0) { // Create a bookmark set and get its suggested name // string $bookmark = `sets -text $type -name $defaultBaseName $objects`; if( $popDialog ) { // Let the user name the bookmark // string $OK = (uiRes("m_createBookmark.kOk")); string $cancel = (uiRes("m_createBookmark.kCancel")); string $response = `promptDialog -title (uiRes("m_createBookmark.kCreateBookmark")) -message (uiRes("m_createBookmark.kBookmarkName")) -text $bookmark -button $OK -button $cancel -defaultButton $OK -cancelButton $cancel -dismissString $cancel`; if ($response == $OK ) { // // If the user is happy, then add the bookmark // string $name = `promptDialog -query -text`; rename $bookmark $name; } else { // Otherwise delete the bookmark set // delete $bookmark; } } } else { warning (uiRes("m_createBookmark.kNoObjectsToBookmarkWarning")); } }