If you try to build a connector to get some Revit data to a database like MySQL, you may hit an issue where some strings that are allowed in Revit will do funny things to your SQL instructions, like this:
What to do? We need to ‘escape’ these characters during our data export or INSERT to create something that the database engine can consume. There are some exotic ways to get around this (like encode your text in base-64), but in my case I just wanted to replace the problem character with the escaped version. Ideally, we would use characters that we know will never be found in Revit Type or Family Names.
Revit does not allow these characters in most type and family names:
Looks like a backslash could work, as this is an escape character in MySQL, and it is not allowed by Revit as above.
You can do this a lot of ways in various coding languages, but an easy way is with a String Replace in Dynamo, like:
This workaround doesn’t handle every situation – like if you are pulling parameters out of Revit that contain all kind of characters, you may have to look at a more reliable text cleanup or encoding solution. But this helps with the Type and Family names at least 🙂