Converting the points of an Arbitrary Line
In this example, we create a contextual menu for arbitrary lines in map seismic outlines. The script behind this contextual menu converts the coordinates of that line to the INLINE-XLINE coordinates of the other outline layer in the same window
The text of the script is:
window = layer.getViewerWindow()
allLayers = window.getAllLayers()
for currentLayer in allLayers:
if currentLayer != layer:
otherLayer = currentLayer
break
otherIJToXY = otherLayer.getIJToXY()
newPolyline=TraverseData('MyData', 'INLINE', 'XLINE')
allPoints = polyline.getPoints()
for currentPoint in allPoints:
x = currentPoint[0]
y = currentPoint[1]
trans = otherIJToXY.invCoordTrans(x, y)
inline = trans[0]
xline = trans[1]
newPolyline.addPoint(inline, xline)
writer=TraverseDataWriter(newPolyline)
saver = TraverseDataSaver()
saver.saveInBackground(newPolyline, None)
Place this "ConvertAndSave.py" script in the Contextual_Map_Outline_Polyline directory of your Python scripts directory
Press the button "Refresh from Disk" in your Python options. Your script should appear.
And it should be available as a contextual menu of your polyline
Select the "ConvertAndSave.py" menu item to launch this script. After performing the conversion, this script prompts the user for a location on disk where to save the converted arbitrary line. Use the "Load Arbitrary Line" menu item to load this arbitrary line onto the other layer.