// =========================================================================== // 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 24, 1996 // // Description: // This a helper script which will add a given bookmark // to the mainListConnection of an editor. // // Input Arguments: // The name of the editor to modify // The name of the bookmark to connect // Flag to indicate use or detach // // Return Value: // None. // global proc useBookmark (string $editor, string $bookmark, int $use) { // Make sure the editor exists // if (!`editor -exists $editor`) { error (uiRes("m_useBookmark.kEditorNotFound")); } // And make sure the bookmark exists // if (catch (`sets -query -text $bookmark`)) { error (uiRes("m_useBookmark.kBookmarkNotFound")); } // First, find out what is connected to this editor // string $mainListConnection = `editor -query -mainListConnection $editor`; // Then check to see if this is already connected to the bookmark // string $objectConnection; if ($mainListConnection != "") { $objectConnection = `selectionConnection -findObject $bookmark -query $mainListConnection`; } // See if we want to use this bookmark, or disconnect it // if ($use) { if ($objectConnection == "") { // Create a selection connection to wrap this bookmark // string $connection = `selectionConnection -object $bookmark -parent $editor`; // And attach it to the editor // string $id; if ($mainListConnection != "") { $id = `selectionConnection -query -identify $mainListConnection`; } if (($mainListConnection == "") || (($id != "listList") && ($id != "objectList"))) { // We can attach it directly // editor -edit -mainListConnection $connection $editor; } else if (($id == "listList") && !`selectionConnection -query -switch $mainListConnection`) { // There is a list connection that we can attach to // selectionConnection -edit -add $connection $mainListConnection; } else { // Create a new list connection // string $listConnection = `selectionConnection -connectionList -parent $editor`; editor -edit -mainListConnection $listConnection $editor; if ($id == "objectList") { selectionConnection -edit -add $mainListConnection $listConnection; } selectionConnection -edit -add $connection $listConnection; } } } else { if ($objectConnection != "") { if ($objectConnection == $mainListConnection) { toggleAutoLoad $editor true; } else { if ($mainListConnection != "") { // Remove the objectConnection from the list connection // selectionConnection -edit -remove $objectConnection $mainListConnection; // Check to see if there is anything else still connected // string $id = `selectionConnection -query -identify $mainListConnection`; if ($id == "listList") { string $list[] = `selectionConnection -query -connectionList $mainListConnection`; if (size ($list) <= 1) { toggleAutoLoad $editor true; } } } } // deleteUI $objectConnection; } } }