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.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") |
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
See the end of this message for details on invoking | |
just-in-time (JIT) debugging instead of this dialog box. | |
************** Exception Text ************** | |
System.ArgumentException: Requested value 'Polygon' was not found. | |
at System.Enum.EnumResult.SetFailure(ParseFailureKind failure, String failureMessageID, Object failureMessageFormatArgument) | |
at System.Enum.TryParseEnum(Type enumType, String value, Boolean ignoreCase, EnumResult& parseResult) | |
at System.Enum.Parse(Type enumType, String value, Boolean ignoreCase) | |
at DMS.SyncFramework.Models.GeometryColumnInfoDB.get_geometry_type_as_integer() in c:\TeamCityBuildAgent\work\15504c2943e7c40b\SyncFramework\SyncFramework\Models\GeometryColumnInfoDB.cs:line 234 | |
at DMS.SyncManager.SyncManagerGui.selectTablesR_SelectedIndexChanged(Object sender, EventArgs e) in c:\TeamCityBuildAgent\work\15504c2943e7c40b\SyncManager\SyncManager\SyncManager.cs:line 1523 |
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
QToolTip | |
{ | |
border: 1px solid #222; | |
background-color: #333; | |
color: @text; | |
} | |
QWidget | |
{ | |
color: @text; |
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 PyQt4.QtCore import QThread, QObject, pyqtSignal | |
import time | |
class Worker(QObject): | |
done = pyqtSignal() | |
finalResult = pyqtSignal(int) | |
def __init__(self, parent=None): | |
super(Worker, self).__init__(parent) |
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
import os | |
from PyQt4.QtCore import * | |
from PyQt4.QtGui import * | |
outdir = '~/temp/' | |
size = QSize(32, 32) | |
def get_gen(name): | |
gen = QSvgGenerator() |
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.utils import iface | |
from qgis.core import QGis | |
from qgiscommand.command import command | |
@command() | |
def bbox(): | |
layer = iface.activeLayer() | |
def pbounds (Lextent,s): | |
e = Lextent |
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
import re | |
from qgis.core import QgsMapLayerRegistry | |
from qgis.utils import iface | |
from qgiscommand.command import command, complete_with, check | |
from qgiscommand.qgis_commands import layer_by_name, layers | |
def layer_exists(data): | |
try: | |
layer_by_name(data) |
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
# Command bar init file. Lines starting with # are ignored | |
alias lp load-project | |
alias @ alias |
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
def complete_projects(argname, data): | |
# TODO Add auto complete for paths | |
projects = [] | |
for path in project_paths: | |
projects += [os.path.basename(f) for f in glob.glob(path + "/*.qgs")] | |
return projects | |
@command.command("Name") | |
@command.complete_with(name=complete_projects) | |
def load_project(name): |
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
sym = QgsLineSymbolV2.createSimple({}) | |
r = QgsRuleBasedRendererV2(sym) | |
sym2 = QgsLineSymbolV2.createSimple({}) | |
exp = "sewer_type = 'Pipe'" | |
rule = QgsRuleBasedRendererV2.Rule(sym2, filterExp=exp) | |
r.rootRule().appendChild(rule) | |
iface.activeLayer().setRendererV2(r) |