# Kanji Colorizer: Stroke Order Diagrams \[Official Support Thread\]

**URL:** <https://forums.ankiweb.net/t/kanji-colorizer-stroke-order-diagrams-official-support-thread/1185>\
**Category:** Add-ons\
**Created:** [July 20, 2020, 2:09pm UTC](https://forums.ankiweb.net/t/kanji-colorizer-stroke-order-diagrams-official-support-thread/1185 "2020-07-20T14:09:27Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![cayenne](https://avatars.discourse-cdn.com/v4/letter/c/e8c25b/32.png) [@cayenne](https://forums.ankiweb.net/u/cayenne)\
**Post date:** [July 20, 2020, 2:09pm UTC](https://forums.ankiweb.net/t/kanji-colorizer-stroke-order-diagrams-official-support-thread/1185/1 "2020-07-20T14:09:28Z")

</div>

Hi

This is the official support thread for [https://ankiweb.net/shared/info/1964372878](https://ankiweb.net/shared/info/1964372878) .

---

<div class="post-metadata">

**Author:** ![UsableThought](https://avatars.discourse-cdn.com/v4/letter/u/958977/32.png) [@UsableThought](https://forums.ankiweb.net/u/UsableThought)\
**Post date:** [July 24, 2020, 7:40am UTC](https://forums.ankiweb.net/t/kanji-colorizer-stroke-order-diagrams-official-support-thread/1185/2 "2020-07-24T07:40:48Z")

</div>

I don’t know if this is the correct way to start a topic.

My question is, suddenly the colorizer add-on is creating stroke order diagrams for kana. I only want it for kanji, which is how it used to be. Is there a way to turn off the kana aspect? Thanks.

---

<div class="post-metadata">

**Author:** ![cayenne](https://avatars.discourse-cdn.com/v4/letter/c/e8c25b/32.png) [@cayenne](https://forums.ankiweb.net/u/cayenne)\
**Post date:** [July 25, 2020, 12:09am UTC](https://forums.ankiweb.net/t/kanji-colorizer-stroke-order-diagrams-official-support-thread/1185/3 "2020-07-25T00:09:00Z")

</div>

There isn’t, but I’ll add a config option for that in the next release.

---

<div class="post-metadata">

**Author:** ![UsableThought](https://avatars.discourse-cdn.com/v4/letter/u/958977/32.png) [@UsableThought](https://forums.ankiweb.net/u/UsableThought)\
**Post date:** [July 25, 2020, 8:35am UTC](https://forums.ankiweb.net/t/kanji-colorizer-stroke-order-diagrams-official-support-thread/1185/4 "2020-07-25T08:35:52Z")

</div>

Thanks!

---

<div class="post-metadata">

**Author:** ![cayenne](https://avatars.discourse-cdn.com/v4/letter/c/e8c25b/32.png) [@cayenne](https://forums.ankiweb.net/u/cayenne)\
**Post date:** [July 26, 2020, 6:46pm UTC](https://forums.ankiweb.net/t/kanji-colorizer-stroke-order-diagrams-official-support-thread/1185/5 "2020-07-26T18:46:15Z")

</div>

I’ve just uploaded a version with this change. In addition to the current behavior, you can configure it to never generate diagrams for anything but kanji or to always generate diagrams for all characters.

---

<div class="post-metadata">

**Author:** ![UsableThought](https://avatars.discourse-cdn.com/v4/letter/u/958977/32.png) [@UsableThought](https://forums.ankiweb.net/u/UsableThought)\
**Post date:** [July 27, 2020, 4:23am UTC](https://forums.ankiweb.net/t/kanji-colorizer-stroke-order-diagrams-official-support-thread/1185/6 "2020-07-27T04:23:00Z")

</div>

Works like a charm - thanks!

---

<div class="post-metadata">

**Author:** ![lesebb](https://avatars.discourse-cdn.com/v4/letter/l/a88e57/32.png) [@lesebb](https://forums.ankiweb.net/u/lesebb)\
**Post date:** [August 31, 2020, 7:30pm UTC](https://forums.ankiweb.net/t/kanji-colorizer-stroke-order-diagrams-official-support-thread/1185/7 "2020-08-31T19:30:10Z")

</div>

Installed the add-on and did multi restarts.  
Stroke Kanji is not showing up in Diagram field.  
Running on MacOS Catalina 10.15.6

---

<div class="post-metadata">

**Author:** ![cayenne](https://avatars.discourse-cdn.com/v4/letter/c/e8c25b/32.png) [@cayenne](https://forums.ankiweb.net/u/cayenne)\
**Post date:** [September 2, 2020, 12:10am UTC](https://forums.ankiweb.net/t/kanji-colorizer-stroke-order-diagrams-official-support-thread/1185/8 "2020-09-02T00:10:45Z")

</div>

Does this happen both when editing the card (it doesn’t update until you leave the field) and when using the menu items?

More information that might be helpful: what version of anki and what version of kanjicolorize are you running? Can you post your full config for kanji colorize and the name of the model and its source and destination fields?

---

<div class="post-metadata">

**Author:** ![CC1](https://avatars.discourse-cdn.com/v4/letter/c/9fc348/32.png) [@CC1](https://forums.ankiweb.net/u/CC1)\
**Post date:** [September 5, 2020, 2:11am UTC](https://forums.ankiweb.net/t/kanji-colorizer-stroke-order-diagrams-official-support-thread/1185/9 "2020-09-05T02:11:03Z")

</div>

the addon suddenly stops working.

---

<div class="post-metadata">

**Author:** ![gooifgeffpawkek](https://avatars.discourse-cdn.com/v4/letter/g/22d042/32.png) [@gooifgeffpawkek](https://forums.ankiweb.net/u/gooifgeffpawkek)\
**Post date:** [October 9, 2020, 11:19pm UTC](https://forums.ankiweb.net/t/kanji-colorizer-stroke-order-diagrams-official-support-thread/1185/10 "2020-10-09T23:19:27Z")

</div>

Hello, I’ve been running into this error, I haven’t touched the addon files at all. I tried restarting anki and creating a new profile with just my kanjis deck but neither made the error go away. Help would be appreciated!

Debug info:  
Anki 2.1.34 (8af8f565) Python 3.8.0 Qt 5.15.1 PyQt 5.15.1  
Platform: Windows 10  
Flags: frz=True ao=True sv=2  
Add-ons, last update check: 2020-10-08 22:53:25

Caught exception:  
Traceback (most recent call last):  
File “C:\Users\Gooifgeffpawkek\AppData\Roaming\Anki2\addons21\1964372878\kanji\_colorizer.py”, line 189, in generate\_for\_new  
for note\_id in mw.col.findNotes(search\_str):  
File “anki\collection.py”, line 453, in find\_notes  
File “anki\rsbackend\_gen.py”, line 88, in search\_notes  
File “anki\rsbackend.py”, line 267, in \_run\_command  
anki.rsbackend.InvalidInput: Invalid search - please check for typing mistakes.

---

<div class="post-metadata">

**Author:** ![cayenne](https://avatars.discourse-cdn.com/v4/letter/c/e8c25b/32.png) [@cayenne](https://forums.ankiweb.net/u/cayenne)\
**Post date:** [November 3, 2020, 6:37pm UTC](https://forums.ankiweb.net/t/kanji-colorizer-stroke-order-diagrams-official-support-thread/1185/11 "2020-11-03T18:37:21Z")

</div>

This can happen if there aren’t any models that match your config. Have you checked your source, destination, and model settings?

I just released a version with a better message in this case.

---

<div class="post-metadata">

**Author:** ![cayenne](https://avatars.discourse-cdn.com/v4/letter/c/e8c25b/32.png) [@cayenne](https://forums.ankiweb.net/u/cayenne)\
**Post date:** [November 3, 2020, 6:38pm UTC](https://forums.ankiweb.net/t/kanji-colorizer-stroke-order-diagrams-official-support-thread/1185/12 "2020-11-03T18:38:45Z")

</div>

Besides the above error message, the newly released version also includes a user contribution with a setting to not overwrite the destination field if it already has something in it.

---

<div class="post-metadata">

**Author:** ![cayenne](https://avatars.discourse-cdn.com/v4/letter/c/e8c25b/32.png) [@cayenne](https://forums.ankiweb.net/u/cayenne)\
**Post date:** [November 3, 2020, 6:41pm UTC](https://forums.ankiweb.net/t/kanji-colorizer-stroke-order-diagrams-official-support-thread/1185/13 "2020-11-03T18:41:00Z")

</div>

I can’t help without more specific information. What are you trying to do? What is happening instead? What changed between when it was working and when it wasn’t working.

---

<div class="post-metadata">

**Author:** ![galaxysprinkles](https://avatars.discourse-cdn.com/v4/letter/g/c4cdca/32.png) [@galaxysprinkles](https://forums.ankiweb.net/u/galaxysprinkles)\
**Post date:** [December 14, 2020, 7:15pm UTC](https://forums.ankiweb.net/t/kanji-colorizer-stroke-order-diagrams-official-support-thread/1185/14 "2020-12-14T19:15:27Z")

</div>

Hello! I just installed this addon, and I’m having a problem with getting the stroke order diagram to show up in a card. It doesn’t show up in Browse\>Card customization, or when I try to actually study the card. I followed (to my knowledge) all the directions on how to add the stroke order diagram (with how everything should be named an such) and it shows up and seems to work fine during the process of creating a new card, just not as I mentioned above. I have tried restarting Anki.

I’m on Windows 10 with Anki Version ⁨2.1.37. I’m not sure which version of the add-on, but I guess the latest as of December 14th, 2020, as I downloaded it today? (I’m slightly tech illiterate, so I’m very sorry if there’s something obvious I missed.)

---

<div class="post-metadata">

**Author:** ![cayenne](https://avatars.discourse-cdn.com/v4/letter/c/e8c25b/32.png) [@cayenne](https://forums.ankiweb.net/u/cayenne)\
**Post date:** [December 15, 2020, 12:23am UTC](https://forums.ankiweb.net/t/kanji-colorizer-stroke-order-diagrams-official-support-thread/1185/15 "2020-12-15T00:23:56Z")

</div>

Hi. It sounds like maybe you just haven’t generated diagrams for your existing cards. That’s at tools \> kanji colorize \> generate all new.

---

<div class="post-metadata">

**Author:** ![Specktakuler](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@Specktakuler](https://forums.ankiweb.net/u/Specktakuler)\
**Post date:** [January 29, 2021, 5:12am UTC](https://forums.ankiweb.net/t/kanji-colorizer-stroke-order-diagrams-official-support-thread/1185/16 "2021-01-29T05:12:07Z")

</div>

Hi - I’ve made some modifications to the code so that the config src and dest fields don’t have to be exactly spelled out (used the ‘in’) keyword. Also, allowed there to be multiple diagram fields so that each kanji in a compound can be written to a different field. Are you interested in seeing my modifications?

---

<div class="post-metadata">

**Author:** ![cayenne](https://avatars.discourse-cdn.com/v4/letter/c/e8c25b/32.png) [@cayenne](https://forums.ankiweb.net/u/cayenne)\
**Post date:** [February 7, 2021, 5:51pm UTC](https://forums.ankiweb.net/t/kanji-colorizer-stroke-order-diagrams-official-support-thread/1185/17 "2021-02-07T17:51:21Z")

</div>

Thanks, yes those do sound potentially useful to other people.

---

<div class="post-metadata">

**Author:** ![Specktakuler](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@Specktakuler](https://forums.ankiweb.net/u/Specktakuler)\
**Post date:** [February 12, 2021, 2:16am UTC](https://forums.ankiweb.net/t/kanji-colorizer-stroke-order-diagrams-official-support-thread/1185/18 "2021-02-12T02:16:47Z")

</div>

I’ve attached the file I made the changes in, let me know if you have any  
questions!

(Attachment kanji\_colorizer.py is missing)

---

<div class="post-metadata">

**Author:** ![Specktakuler](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@Specktakuler](https://forums.ankiweb.net/u/Specktakuler)\
**Post date:** [February 22, 2021, 2:31am UTC](https://forums.ankiweb.net/t/kanji-colorizer-stroke-order-diagrams-official-support-thread/1185/19 "2021-02-22T02:31:05Z")

</div>

I’ve attached the file with my changes, apologies for the delay! I had tried to just attach it without modifying the file extension, but that was rejected by the mail server.

(Attachment kanji\_colorizer-multidiag.txt is missing)

---

<div class="post-metadata">

**Author:** ![Specktakuler](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@Specktakuler](https://forums.ankiweb.net/u/Specktakuler)\
**Post date:** [February 28, 2021, 10:24pm UTC](https://forums.ankiweb.net/t/kanji-colorizer-stroke-order-diagrams-official-support-thread/1185/20 "2021-02-28T22:24:56Z")

</div>

Because the forums won’t allow txt or py attachments, I’m copying and pasting my changes in - hopefully with enough context that you can tell where they go

from kanjicolorizer.colorizer import (KanjiVG, KanjiColorizer,  
InvalidCharacterError)  
import string  
import re

srcField = ‘(word._Kanji._)’  
dstField = ‘(._iagram._)’

…  
model\_name = model[‘name’].lower()  
dstMatch = None  
srcMatch = None  
for name in mw.col.models.fieldNames(model):  
if dstMatch == None:  
dstMatch = re.match(dstField,name,re.IGNORECASE)  
if srcMatch == None:  
srcMatch = re.match(srcField,name,re.IGNORECASE)  
if dstMatch != None and srcMatch != None:  
break

return (‘kanji’ in model\_name and srcMatch and dstMatch)

…  
if currentFieldIndex != None: # We’ve left a field

# But it isn’t the relevant one

match = re.match(srcField,note.model()[‘flds’][currentFieldIndex][‘name’],re.IGNORECASE)  
if match == None:  
return None  
else: #We’re regenerating so need to find the src field  
for name in mw.col.models.fieldNames(note.model()):  
match = re.match(srcField,name,re.IGNORECASE)  
if match:  
break  
srcTxt = mw.col.media.strip(note[match.group(1)])

destinationNames =[]  
for name in mw.col.models.fieldNames(note.model()):  
dstMatch = re.match(dstField,name,re.IGNORECASE)  
if dstMatch != None:  
destinationNames.append(name)

destIndex = 0  
dst = ‘’  
for character in characters\_to\_colorize(unicode(srcTxt)):

# write to file; anki works in the media directory by default

try:  
filename = KanjiVG(character).ascii\_filename  
except InvalidCharacterError:

# silently ignore non-Japanese characters

continue  
char\_svg = kc.get\_colored\_svg(character).encode(‘utf\_8’)  
anki\_fname = mw.col.media.writeData(unicode(filename, ‘utf\_8’), char\_svg)  
strokeFileName = ‘ ![]()’.format(anki\_fname).encode(‘utf\_8’)  
if len(destinationNames) \> 1:  
note[destinationNames[destIndex]] = strokeFileName  
destIndex += 1  
flag = True  
else:  
dst += strokeFileName  
note[destinationNames[0]] = dst  
flag =True

note.flush()  
return flag

Hope this finally gets to you, apologies for the delay

[Next page](https://forums.ankiweb.net/t/kanji-colorizer-stroke-order-diagrams-official-support-thread/1185.md?page=2)
