Spell Checking w/ Dynamo

image by archi-lab

I am not sure how useful this would be, but I saw a question on the Dynamo Forum, where someone was asking about potential to Spell Check their Schedules in Revit. Obviously we can do spell checking on Text Notes, that is now available out of the box in Revit. However, that spell checking tool doesn’t dig into Elements and their Parameter values, so it’s kind of useless for Schedules. These as we all know are simply a tabular representation of Elements and their parameter values. How do we go about checking these for spelling mistakes? Here’s one approach:

Let’s say that we have some Elements where Comments parameter is being scheduled. Doors is a good example when we are doing Door Schedules, it’s a common occurrence to leave some directions behind in that parameter.

As you can see above there are some words that have spelling mistakes. Here’s how we can correct those:

The above script uses a simple approach where:

  • we grab the elements that we want to spell check
  • get parameter value from each one. In this case we are looking at Comments, but the goal is really to get a string value from any parameter.
  • We then feed it through a Speller node called Speller.CheckSpelling. That’s a custom node from archi-lab.net library, but more specifically it uses an Open Source project called WeCantSpell.Hunspell This is a .NET wrapper around Hunspell library, that in turn uses bunch of Open Office dictionaries. That means that we can load any of the following languages into it, for spell checking: Dictionaries By default we are using English US Dictionary.
  • Once we pass it through there, what we will get is two lists. One will contain all of the words that library found to be misspelled, and another will have all of the potential fix suggestions.
  • For this example I just grabbed first suggestion for each misspelled word, and replaced them in the string, so that I can write that new value back into the Comments parameter.

That’s it! There is no magic here. There are some issues that I can foresee but also some potential for future development. At the moment we are using out of the box dictionaries, but we all know that Architects, Engineers etc. will have a ton of custom words, abbreviations etc. that we would want to exclude. We can do that of course, I just haven’t implemented a wrapper for that.

As a bonus content here’s the same script but spell checking Text Notes. I guess it’s always good to compare to the existing solution inside of Revit to make sure that we are not making existing things worse.

Again, feel free to post any comments, or issues either here or on the archi-lab.net GitHub page.

Finally, as always samples will be available for download for my Patreon supporters. Thank you to all that have been, and continue supporting me. Enjoy!

EDIT 2020.07.26:

So I noticed that there were some questions on the Dynamo Forum asking about Spell Checking a Schedule. The more advanced users of Revit surely know that a Schedule is just a different way of looking at the same model. Each row in a Schedule is actually connected to an Element in the model, so all we have to do to Spell Check a Schedule is get these Elements. Each column in a Schedule is just a Parameter value from that Element. Here’s a quick example of Spell Checking a Door Schedule and the Comments column:

As you can see above I have also added a way to create a set of custom words in our Spell Checking library for things like Abbreviations. Yes, Architects and Engineers surely like to have a list of custom words that they would like to omit when spell checking their work. This new Speller constructor allows you to do just that. Just feed it a list of custom words.

Also, as you can see above, I am showing a different way to obtain a Dictionary. For those of you that don’t want to use the default English dictionary, you can do so by supplying a path to a dictionary and affix files. I posted a link to bunch of different languages above.

Support archi-lab on Patreon!

27 Comments

  1. Cristina Rego says:

    Hi, how can I install this package?

  2. Cristina Rego says:

    Found it. I will let you know if it works :)

  3. Yura says:

    Please,send me nod Speller speller
    Thanks

  4. Leland says:

    Can you just do it for me?

  5. Bao Huynh says:

    i got a warning massage:
    Warning: Speller..ctor operation failed.
    The type initializer for ‘WeCantSpell.Hunspell.AffixReader’ threw an exception
    How can i fix it

  6. Eric Nagel says:

    I received the same error message as Bao Huynh (Nov 30th, 2020). I posted the issue to the github location that you provided. Please advise.

  7. Eric Nagel says:

    Hello Konrad,
    I am receiving the same warning message as Bao Huynh. I posted the entire issue on your github. Can you please let me know if there is a fix / solution to this issue? Thank you.

  8. Daniele Volo says:

    Hi Konrad, I have still the issue “‘WeCantSpell.Hunspell.AffixReader” with Revit 2020, Dynamo 2.3.1.11830, and Achi-lab 2022.2101721
    I’m using last version italian dictionary

    Attachment:  spell.jpg

  9. jarod says:

    I love the tool but has anyone made an interface that lets you choose what spelling you want some of them just kind of randomly changes them to the first slot. (for example try Hellp and Tessting. you get Helli and Tess ting ugh lol

    • Yeah, that sucks, and no, I haven’t thought about an interface here. I guess a pop-up window with all of the found misspells and ability to choose a replacement would be nice. I can’t promise that I will get around to this anytime soon. It’s a free tool, so I cannot commit to any deadlines. Apologies. Until then, you are gonna have to do. Sorry.

  10. Eric Nagel says:

    Hello again! I am attempting to re-work/update a script that I have developed that uses the CheckSpelling node. I have the latest package version installed and I am using R2022.1. I am noticing an odd behavior when a “/” is used in the string of text that I am check. For example: if I feed the string “sheet/set” the result is indicated by the misspelling “sheetset” (it drops the /) with the list of some suggestions that include: sheet set and sheet-set. When I switch this up and feed in “sheet-set”, the node does not indicate that there are any spelling errors. Reference the attached image. Is the code dropping the “/” for a reason? It appears to work just fine with the “-“. Is there anything that can be done to update the code to accept the “/”?

    Attachment:  sp_img1.jpg

    • Try putting in two “//” one after another. I am curious if its because slashes are special characters. Normally a “\” is an escape character for other special characters. A forward slash though should be fine.

      • Eric Nagel says:

        As requested, I tried the following…
        test string: “tabletopp//below graade”

        When this test string is run thru the script I get these results…
        misspelled: tabletoppbelow
        suggestions: tablespoonful
        …and…
        misspelled: graade
        suggestions: grade, grad

        The two forward slashes were dropped as well.

Leave a Comment