Last active
October 17, 2015 15:59
-
-
Save mtravis/72c3a80397bd67421a25 to your computer and use it in GitHub Desktop.
turn snapping on/off in QGIS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from qgis.core import * | |
from qgis.utils import iface | |
from PyQt4.QtCore import * | |
from PyQt4.QtGui import * | |
def snapping_toggle(): | |
layer = QgsMapLayerRegistry.instance().mapLayersByName("topographicline")[0] | |
#layer = iface.activeLayer() | |
_, enabled, _, _, _, _ = QgsProject.instance().snapSettingsForLayer(layer.id()) | |
QgsProject.instance().setSnapSettingsForLayer(layer.id(), not enabled, 0, 1, 10, True) | |
print "set {} snapping {}".format(layer.name(), "Off" if not enabled else "On") | |
shortcut = QShortcut(QKeySequence(Qt.SHIFT + Qt.Key_S), iface.mainWindow()) | |
shortcut.setContext(Qt.ApplicationShortcut) | |
shortcut.activated.connect(snapping_toggle) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment