Announcement

Collapse
No announcement yet.

What Revit Wants: Escape Characters For Revit and External Database Connections

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    What Revit Wants: Escape Characters For Revit and External Database Connections


    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
    The post Escape Characters For Revit and External Database Connections appeared first on What Revit Wants.



    Click here to view the entire blog post.
    Luke Johnson | Autodesk Expert Elite Member
    Author of What Revit Wants
Working...
X