Change Deck of Cards

Hello guys,

i’m trying to make my own addon, so i want to programmatically change the deck of some cards.
Is this possible and how?

Thanks in advance,
Tobi7

You can use mw.col.set_deck(), passing it a list of card IDs and the ID of the deck:

cids = [1642081338943, ...]
mw.col.set_deck(cids, deck_id)
3 Likes

Sorry but that didn’t work for me, mw..col doesn’t have a method set_deck, but mw.col.decks, does.
So mw.col.decks.setDeck(cids, did) worked for me!

mw.co.set_deck() was introduced in 2.1.36 apparently, and mw.col.decks.setDeck was deprecated

3 Likes

You may wish to take a look at these pages dealing with setting up your IDE for code completion.

https://addon-docs.ankiweb.net/editor-setup.html

This is a good way to discover what you need, although digging around in the source code is also necessary a lot of the time - the places to start are usually /qt/aqt/ or /pylib/anki/

1 Like