Skip to content

Commit

Permalink
Remove special characters from part names
Browse files Browse the repository at this point in the history
Replace `"` with `in` in part names since it the quote breaks the
generated XML. Also replace `'` with `ft` for consistency.
  • Loading branch information
Ryan Sinnet committed Jul 4, 2022
1 parent 07d9fb3 commit f5c70a5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions onshape_to_robot/onshape_to_robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,15 @@ def partIsIgnore(name):
else:
return name not in config['whitelist']

# Adds a part to the current robot link

def renamePart(name):
"""Remove special characters from part names."""
return name.replace('"', "in").replace("'", "ft")

def addPart(occurrence, matrix):
"""Add a part to the current robot link."""
part = occurrence['instance']
part['name'] = renamePart(part['name'])
part['configuration'] = renamePart(part['configuration'])

if part['suppressed']:
return
Expand Down

0 comments on commit f5c70a5

Please sign in to comment.