[Qgis-developer] Setting snapping settings via Python

John Stevenson john.stevenson at thinkwhere.com
Fri Jan 22 03:57:55 PST 2016


Thanks for help so far.

These suggestions seem to be more complicated than I require.  I do not need to use the snapper to modify geometries in a custom tool, just to turn snapping on for the current layer when the user begins editing it.  I tried the following, based on Etienne's inasafe example, but nothing happens:

layer = canvas.layer(0)
point_locator = QgsPointLocator(layer)
units = QgsTolerance.LayerUnits
layer_config = QgsSnappingUtils.LayerConfig(layer, point_locator.Types(), 50, units)
snapper = QgsSnappingUtils()
snapper.setLayers([layer_config])
snapper.setSnapToMapMode(QgsSnappingUtils.SnapAdvanced)

Is there another snapper already created by QGIS when editing begins that I can access?

Cheers
John


John Stevenson
Senior Developer


[cid:image8bc20c.PNG at 67520999.41b46f51]<http://www.thinkwhere.com>


t: 01786 476060 (Office)
t: 01786 476093 (Direct Dial)
w:www.thinkwhere.com<http://www.thinkwhere.com>


Glendevon House
Castle Business Park
Stirling FK9 4TZ


[cid:image295644.PNG at b1051cba.4e97df2b]<https://twitter.com/thinkWhere1> [cid:imagea7a708.PNG at 070b5c8d.4fa6e904] <http://www.linkedin.com/company/1509510?trk=companies_home_ycp_logo_forth-valley-gis>


This email and its attachments are private and confidential. If you believe you have received this email in error, please contact the sender immediately on 01786 476060. If you are not the intended recipient, you may not rely on, use or disclose this email or any attachments in any way.

thinkWhere Limited does not accept any liability for any damage that may be caused to the recipient's system or data by this email or any attachments. Please note that our email system may be subject to random monitoring by us. This Company accepts no liability for personal emails.

thinkWhere is a limited company registered in Scotland with Registered Number SC315349 and having its Registered Office at Glendevon House, Castle Business Park, Stirling, FK9 4TZ.

________________________________
From: Qgis-developer [qgis-developer-bounces at lists.osgeo.org] on behalf of Thomas Gratier [osgeo.mailinglist at gmail.com]
Sent: 21 January 2016 11:04
To: Tom Chadwin
Cc: qgis-developer
Subject: Re: [Qgis-developer] Setting snapping settings via Python

Hi,

I'm maybe wrong but you'd better look at QgsSnappingUtils http://qgis.org/api/classQgsSnappingUtils.html
It seems more simple and should do the job for you.

Cheers

Thomas Gratier

2016-01-20 20:32 GMT+01:00 Tom Chadwin <tom.chadwin at nnpa.org.uk<mailto:tom.chadwin at nnpa.org.uk>>:
This old thread might also help:

http://osgeo-org.1560.x6.nabble.com/getting-QgsMapCanvasSnapper-to-work-td4147067.html



--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Setting-snapping-settings-via-Python-tp5246362p5246373.html
Sent from the Quantum GIS - Developer mailing list archive at Nabble.com.
_______________________________________________
Qgis-developer mailing list
Qgis-developer at lists.osgeo.org<mailto:Qgis-developer at lists.osgeo.org>
List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20160122/9efaf15b/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image8bc20c.PNG
Type: image/png
Size: 7004 bytes
Desc: image8bc20c.PNG
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20160122/9efaf15b/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image295644.PNG
Type: image/png
Size: 3618 bytes
Desc: image295644.PNG
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20160122/9efaf15b/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: imagea7a708.PNG
Type: image/png
Size: 3751 bytes
Desc: imagea7a708.PNG
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20160122/9efaf15b/attachment-0005.png>


More information about the Qgis-developer mailing list