def rungx() makes my script fail

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

  • 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)
    
  • 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.
  • Sorry the forum is messing up the code indentation. The intent was that all lines under def rungx should be indented.
  • 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.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!