On 14 April 2016 at 14:26, Tudorache, Marian
<marian.tudora...@navcanada.ca> wrote:
> Hi everyone,
>
> I have a question about how to use CADDigitize plugin from pyqgis.
>
> 1.       I would like to get the active instance of this plugin from
> QgisInterface (iface). I understand when the plugin is installed there is a
> reference of this plugin recorded here (iface).
>
> Is it possible to do this?

Depends on what you want to do. If you just want to trigger the
actions (e.g. the equivalent to clicking the toolbar buttons), then
you may be able to access them via QgisInterface, but if you want to
script them you'd be better off importing the code into your script.

After a quick look at the code, I don't think the CADDigitize QActions
have object names or parents set that make it possible to find them
directly, nor do the QToolButtons on the toolbar. You could try
grabbing the list of toolbar buttons using something like the
following, but telling which is which is probably going to require
looking at the icon names or something like that.

   buttons = QgisInterface.instance().mainWindow().findChild(QToolBar,
"CADDigitize").findChildren(QToolButton)

You're probably better off just importing the code and calling the
functions you want directly, see
https://github.com/lbartoletti/CADDigitize/blob/master/CADDigitize/CADDigitize.py.
for hints on how to do that.

John.
_______________________________________________
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: http://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to