home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 90 / CD Actual 90.iso / Software3D / K-3D / k3d-0.4.2.1 / scripts / innovation.javascript < prev    next >
Encoding:
Text File  |  2004-07-23  |  1.4 KB  |  47 lines

  1. //javascript
  2.  
  3. function Innovate(Document)
  4. {
  5.     // Give folks a chance to bail ...
  6.     if(2 == Application.ui.QueryMessage("Are you sure?  Don't run this script on a real working document!", "innovation:", "OK", "Cancel", ""))
  7.         return;
  8.  
  9.     // Start recording changes for undo-purposes ...
  10.     Document.StartChangeSet();
  11.  
  12.     // Deliver "value" ...
  13.     var objects = Document.objects;
  14.     for(object in objects)
  15.         objects[object].name = "Microsoft " + objects[object].name + " (TM)";
  16.  
  17.     // Finish recording undos ...
  18.     Document.FinishChangeSet("Innovate!");
  19.  
  20.     // Communicate the good news to our "customer"!
  21.     Application.ui.Message("You have been Innovated ... check your document hierarchy (it's undo-able)", "innovation:");
  22. }
  23.  
  24. /// Boilerplate to determine which document to modify ...
  25. function FindDocument(ScriptName)
  26. {
  27.     if(Document)
  28.             return Document;
  29.     else
  30.             {
  31.                     if(Application.documents.length == 1)
  32.                             return Application.documents[0];
  33.                     else if(Application.documents.length == 0)
  34.                             Application.ui.ErrorMessage("You must have an open document to run this script!", ScriptName + ":");
  35.                     else
  36.                             Application.ui.ErrorMessage("Not sure which document to use ... try using the desired document's Document Window > Tools > Play Script.", ScriptName + ":");
  37.             }
  38.             
  39.     return null;
  40. }
  41.  
  42.  
  43. document = FindDocument("innovation");
  44. if(document)
  45.     Innovate(document);
  46.  
  47.