Skip to main content
Topic: Python NWC tool to reverse selected notes in a staff. (Read 4979 times) previous topic - next topic

Python NWC tool to reverse selected notes in a staff.

Here’s the python code. Enjoy. :)

This code needs to import  nwctxt.py see https://github.com/nwsw/nwc2ut-python

Love and peace,
Joe

Code: [Select · Download]
"""joeSelReverse.py Reverses the Notes that are selected in a NoteWorthy Composer staff
 
see:
    https://github.com/nwsw/nwc2ut-python    
"""
 
import sys
# import joeNWCtxtInPythonNew as nwctxt
import nwctxt # see https://github.com/nwsw/nwc2ut-python
import logging
logging.basicConfig(filename='joeNWC_PY.log',level=logging.DEBUG)  # DEBUG => print ALL msgs
 
clip = nwctxt.NWC2Clip()
PlayContext = nwctxt.NWC2PlayContext()
txtItemL = clip.Items
clipItemL = [nwctxt.NWC2ClipItem(txtItem) for txtItem in txtItemL]
first2 = clipItemL[:2]
reversedClipItemL = first2 + list(reversed(clipItemL[2:]))
reversedTextItemL = [item.ReconstructClipText() for item in reversedClipItemL]
 
print clip.GetClipHeader()
for textItem in reversedTextItemL[2:]:
    #print "clipItem.GetObjType()= %s, type(clipItem.GetObjType())= %s, "%(clipItem.GetObjType(), type(clipItem.GetObjType()))
    print textItem
print clip.GetClipFooter()
 
 
# TO DEBUG uncomment below to report to NWC STDOUT DIALOG & to CAUSE NO STAFF MODIFICATION
# sys.exit(nwctxt.NWC2RC_REPORT)
Love and peace,
Joe

Re: Python NWC tool to reverse selected notes in a staff.

Reply #1
Thanks for the link.  nwctxt.py made for interesting reading. Much cleaner than the PHP library. I've not used python so there is not much more I can say. I've resolved to upgrade beyond WinXP before taking on any new languages.
Registered user since 1996

 

Re: Python NWC tool to reverse selected notes in a staff.

Reply #2
Thanks for the comment, Rick.
Quote
Much cleaner than the PHP library.
For me, Python reads easier than any of the other languages I use.
Eric's nwctxt.py is an example.
Thanks again, Rick.
Love and peace,
Joe
Love and peace,
Joe