def rungx() makes my script fail

Options
DaveHildes1
DaveHildes1 Posts: 3 Calcite Rank Badge
edited February 2023 in GeoStudio
Hello,

I understand that I need the rungx() if I am running a python script from Oasis. But I don't understand this result:

This code works:
import geosoft.gxpy as gxpy
import geosoft.gxpy.grid as gxgrd

#def rungx():
#    raise Exception("This is not an Oasis extension.  Please run through a python interpreter.")

gxc = gxpy.gx.GXpy()
xyz=[(450.,10.,100.),(60.,25.,77.),(50.,8.,80.)]
gridName = "test.grd"
grid = gxgrd.Grid.minimum_curvature(xyz,file_name=gridName,overwrite=True)
while this code fails:
import geosoft.gxpy as gxpy
import geosoft.gxpy.grid as gxgrd

#def rungx():
#    raise Exception("This is not an Oasis extension.  Please run through a python interpreter.")

gxc = gxpy.gx.GXpy()
xyz=[(450.,10.,100.),(60.,25.,77.),(50.,8.,80.)]
gridName = "test.grd"
grid = gxgrd.Grid.minimum_curvature(xyz,file_name=gridName,overwrite=True)
So what is going on?

Thanks,
Dave

Comments

  • DaveHildes1
    Options
    Sorry, copy/paste error. This code fails.
    import geosoft.gxpy as gxpy
    import geosoft.gxpy.grid as gxgrd
    
    def rungx():
        raise Exception("This is not an Oasis extension.  Please run through a python interpreter.")
    
    gxc = gxpy.gx.GXpy()
    xyz=[(450.,10.,100.),(60.,25.,77.),(50.,8.,80.)]
    gridName = "test.grd"
    grid = gxgrd.Grid.minimum_curvature(xyz,file_name=gridName,overwrite=True)
    
  • JacquesBeaurain
    Options
    All the code should be inside the rungx method for a montaj Python GX script. E.g.:

    import geosoft.gxpy as gxpy import geosoft.gxpy.grid as gxgrd def rungx(): gxc = gxpy.gx.GXpy() xyz=[(450.,10.,100.),(60.,25.,77.),(50.,8.,80.)] gridName = "test.grd" grid = gxgrd.Grid.minimum_curvature(xyz,file_name=gridName,overwrite=True)

    The exception code inside a rungx() method seems to be for a standalone script to not be unintentionally used as a Python GX script.
  • JacquesBeaurain
    Options
    Sorry the forum is messing up the code indentation. The intent was that all lines under def rungx should be indented.
  • DaveHildes1
    Options
    Thanks Jacques.

    But my intention is to run it as a standalone script, so I had that exception code in there for exactly the purpose that you pointed out. But it fails as a standalone script unless I comment out the rungx exception section.

    I have other standalone scripts where this works fine - it seems like it is the Grid.minimum_curvature that doesn't like the rungx exception section.
This discussion has been closed.