Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Error in hyperlink script

$
0
0
I wrote a hyperlink script in Python for the Display tab. It has an if/elif structure based on the value of a field. With just the if clause, it runs fine an opens the document. But when I add the elif clause, Arc gives me an error saying '...name OpenLink is not defined'. This makes no sense to me, it's the default name of the function. Any ideas? Thanks.

Code:

import os, threading
def OpenLink ([SubtypeCD], [Name] ):
    if [SubtypeCD] == 'Recorded' and [Name] is not None:
        parsedName = [Name].partition('-')
        folderPrefix = parsedName[0].zfill(4)
        fileSuffix = parsedName[2].zfill(4)
        extension = '.TIF'
        fileName = folderPrefix + fileSuffix + extension
        loc = r"\\base\path"
        image = os.path.join(loc, folderPrefix, fileName)
        threading.Thread(target=os.startfile, args=(image,)).start()
    elif [SubtypeCD] == 'Unrecorded' and [Name] is not None:
        parsedName =[Name].split('-')
        folderOne = parsedName[0] + '_Survey'
        folderTwo = [Name]
        fileName = [Name] + '0001.tif'
        loc = r"\\other\base\path'
        image = os.path.join(loc, folderOne, folderTwo, fileName)
        threading.Thread(target=os.startfile, args=(image,)).start() 
    else:
        pass
 
    return

Attached Thumbnails
Click image for larger version

Name:	Capture.PNG‎
Views:	N/A
Size:	16.3 KB
ID:	32643  

Viewing all articles
Browse latest Browse all 2485

Trending Articles