Skip to main content
Topic: Quickly Set Visibility for Selected Items (Read 10118 times) previous topic - next topic

Quickly Set Visibility for Selected Items

This script enables fast alteration of the visibility property for selected items. It allows you to skip certain types of objects, such as bar lines, text, or any other object identified in its skip list.

Code: [Select · Download]
<?php
/*******************************************************************************
nwsw_Visibility Version 1.01

This script enables fast alteration of the visibility property for selected
items.

Copyright © 2007 by NoteWorthy Software, Inc.
All Rights Reserved

History:
[2007-01-03] Version 1.01 - Inclusion in starter kit
[2006-07-11] Version 1.00 - Initial release
*******************************************************************************/
//
//AdvisoryInvocation:"/visibility=<PROMPT:Set Visibility to:=|Default|Always|TopStaff|Never|>" "/skip=<PROMPT:Skip:=|None|Bar|Bar,Text|Bar,Text,Flow,Ending|>"

require_once("lib/nwc2clips.inc");

$clip = new NWC2Clip('php://stdin');

$opts = array('visibility' => 'hide','skip' => 'all');
foreach ($argv as $k => $v) {
if (!$k) continue;

if (preg_match('/^\/([a-z]+)\=(.*)$/',$v,$m)) {
$optname = $m[1];
$optvalue = $m[2];
$opts[strtolower($optname)] = $optvalue;
}
}

$opts['skip'] = strtolower($opts['skip']);
$skiplist = explode(',',$opts['skip']);

echo $clip->GetClipHeader()."\n";
//
foreach ($clip->Items as $item) {
$o = new NWC2ClipItem($item);
//
$skipit = false;
//
if ($opts['skip'] == 'all') $skipit = true;
else if ($opts['skip'] != 'none') $skipit = in_array(strtolower($o->GetObjType()), $skiplist);
//
if ($skipit) {
echo $item;
continue;
}

$o->Opts['Visibility'] = $opts['visibility'];
echo $o->ReconstructClipText()."\n";
}

echo NWC2_ENDCLIP."\n";
exit(NWC2RC_SUCCESS);
?>

In order to install this script, you need to do the following:

  • Install the NWC2 User Tool Starter Kit
  • Select all of the script text that appears above this bulleted list and press Ctrl+C to copy it
  • Open a Notepad window
  • Paste the contents of the script into the Notepad window
  • In Notepad, select File, Save As, and navigate to the Scripts area of your NWC2 installation, which is usually at "C:\Program Files\NoteWorthy Composer 2\Scripts"
  • Enter the File name as nwsw_Visibility.php and press enter
  • Close Notepad
  • In NWC2, press Alt+F8, then click the New button
  • For Name, enter Visibility (nwsw)
  • For Command, use the Browse button to navigate to to your nwsw_Visibility.php script and press Open
  • Click in the Command field, press End on the keyboard, add a space, then paste the following into the end of the command:
    Quote
    "/visibility=<PROMPT:Set Visibility to:=|Default|Always|TopStaff|Never|>" "/skip=<PROMPT:Skip:=|None|Bar|Bar,Text|Bar,Text,Flow,Ending|>"
  • Press OK to complete your addition of this script to your tool library

Edit: This script is automatically included in version 1.22 or later of the User Tool Starter Kit.

 

Re: Quickly Set Visibility for Selected Items

Reply #1
This script is now included in our starter kit, with version 1.22 and later.