Start a new topic

OpenFlight Script: Tip for batch processing database files without the Batch Run Script command in Creator

Original Post by: SteveThompson Fri Dec 2 21:59:54 2011


During the OpenFlight User Group Meeting at I/ITSEC on 11/30/2011, tips and tricks were presented for using OpenFlight Script and Creator Script.


Here is a script presented that shows how to process multiple OpenFlight database files without using the Creator Pro command Batch Run Script. Note that you can use this technique to apply OpenFlight Script commands to your databases but you cannot invoke Creator Script commands in this way.


def ProcessNodeCB (db, parent, rec, userData):

# this "mgWalk" callback processes each node visited

type = mgGetCode (rec)

if (type == fltPolygon):

# do something to the polygon

print "Processing polygon:", mgGetName(rec)

return MG_TRUE


def ProcessOneFile (db):

print "Processing file:", mgRec2Filename(db)

mgWalk (db, ProcessNodeCB, None, None, MWALK_NOREADONLY)

outs = mgPromptDialogFile (None,

MPFM_OPEN,

MPFA_FLAGS, MPFF_FILEMUSTEXIST|MPFF_MULTISELECT,

MPFA_PATTERN, "OpenFlight Files|*.flt",

MPFA_TITLE, "Select OpenFlight Files to Process" )

status = outs[0]

if (MSTAT_ISOK(status)):

numFiles = outs[1]

fileNames = outs[2:len(outs)]

for fileName in fileNames:

db = mgOpenDb (fileName)

ProcessOneFile (db)

mgWriteDb (db)

mgCloseDb (db)

print "Finished"

else:

print "User Canceled"


Login to post a comment