Oasis Montaj gxpy edb.lock() issue

Hi All. I am trying to write a custom coordinate conversion as n extension in Python. I am coming across an error where I get the current edb and lock it to create a db handle to read and write data in to the database. My code looks like this (for testing this error only).

def rungx():
gxpy.utility.check_version("9.2")

def rungx():
gxpy.utility.check_version("9.2") with gxpy.gx.gx():

edb = gxapi.GXEDB.current() # current edited database

try:
gdb = edb.lock() # lockedb, get GXDB handle

if gdb is None or gdb.is_null():
gxpy.utility.display_message(
"Lock_EDB returned an invalid database handle."
)
return

Any clues as to why I can not lock the edb to get a db ahndle would be appreciated.

Tagged:

Best Answer

  • TimNixon1
    TimNixon1 Posts: 6 Calcite Rank Badge
    Answer ✓

    Hi Marin. I am running this inside Oasis as an extension. I found an alternative way to access the database by getting the current database name and opening it explicitly using the name. Note this has to be in an interactive session. Not sure how my message was working previously.

    def rungx():
    gxpy.utility.check_version("9.2") with gxpy.gx.gx():

    db_path = get_active_db_path_from_edb()
    if not db_path:
    gxpy.utility.display_message("Error", "No active database window. Click in the DB and rerun.")
    return


    # Open the database by name.
    with gxdb.Geosoft_gdb.open(db_path) as gdb: …

Answers

  • PrachiChitkara
    PrachiChitkara Posts: 434 admin

    @NivedithaPoolla @EmilNielsen @DaveCullen would any of you know a way around this?

  • SerbanMarin1
    SerbanMarin1 Posts: 7 Staff

    Hi @TimNixon1. Are you running this python script inside oasis montaj? It will not work as a command line script.

    I ran the code locally and it was working for me. Perhaps there is something special about gpf or gdb files?

    One thing that may or may not be related, the gxpy.utility.display_message requires two parameters, title and message and in your example you seem to only have the message specified.