Wednesday, September 13, 2017

Musings on being a senior programmer

In some context's the title would mean being an experienced, admired, authoritative person.  Alas for me it just means being old, and in retrospect using the word programmer is a bit of a stretch.  Maybe it is harder to remember things because every day I have so much more important information to pack away for later retrieval, or maybe it is just harder to remember.  As we evolve as a company I find myself adding layer names and function keys that I know I'll use again but not often enough that I'll probably remember them.  Gone are the days when a function was one of 120 three digit numbers (which of course I still remember because I've been using most of them for 30 years). I quit trying to remember things I can Google long ago so why not treat the new layers and functions the same, after all if I expose myself to them often enough I'll eventually remember, and if I don't then searching is easy enough.  Enter sealay and seafk.  Now if I forget what the layer number is, but remember that it had the word "Wall" in the name I can just
sealay wall
and like magic I am presented with a list of options which when selected issues a lay= command.

  Likewise if I forget a function key and don't want the entire funkey command list I can just...
seafk odot
and all the appropriate function keys are presented.

It must be nice to have a limitless unhindered storage capacity, but for those of us who have more useful years in the past than in the future, search is our friend.

They both essentially work the same, just one searches the layer names and one searches the function keys.  Here is an example but you get the idea.

print 'seafky.py modified 9:11 AM 7/27/2017'# Display FKeys matching search string
'''
Copyright 2017 Dennis Shimer
Vr Mapping copyright Cardinal Systems, LLC
No warranties as to safety or usability expressed or implied.
Free to use, copy, modify, distribute with author credit.

Prompts user for Fkey name (or any part) then displays Fkey
'''

def lines2lists(AListOfDataLines):
    DataList=[]
    for Line in AListOfDataLines:
        DataList.append(Line.split())
    return DataList

PrintList=[]

if VrArgs:
    SearchText=VrArgs[0]
else:
    SearchText=PyVrGui().InputDialog ('Search String', 'Partial Funkey Name')[1]

FunKeyFile = open(VrCfg().GetFkeyFileName() , 'r')
FunkeyData = FunKeyFile.readlines()
FunKeyFile.close()
DataList = lines2lists(FunkeyData)

for DataLine in DataList :
    if len(DataLine) == 3 :
        if DataLine[1]=='KeyName':
            if DataLine[2].upper().count(SearchText.upper()):
                PrintList.append(DataLine[2])

if PrintList:
    PromBox = VrPromBox ("Run Fkey", 60, 1)
    PromBox.AddList ("Function Key", 40, len(PrintList)+1, 0)
    for FkeyItem in PrintList:
        PromBox.AddListItem (FkeyItem)
    if (PromBox.Display(0) == 0):
        RunFkey = PromBox.GetListByPrompt ("Function Key")
    else: RunFkey=0
    if RunFkey : PyVrGui().PushKeyin(RunFkey)
    else: PyVrGui().MsgBox('No Match to {:s}'.format(SearchText), 'Matching Layers')

Post a Comment
For anyone interested in trying VrPython for the first time or if you are early in the game, I suggest going to the earliest posts and working forward. I use VrPython every day for many wonderful things, needless to say it will change and could potentially damage a file. Any risk associated with using VrPython or any code or scripts mentioned here lies solely with the end user.

The "Personal VrPython page" in the link section will contain many code examples and an organized table of contents to this blog in a fairly un-attractive (for now) form.