diff --git a/core/src/net/sf/openrocket/file/wavefrontobj/export/OBJExporterFactory.java b/core/src/net/sf/openrocket/file/wavefrontobj/export/OBJExporterFactory.java index b9e6f52b3..11a607146 100644 --- a/core/src/net/sf/openrocket/file/wavefrontobj/export/OBJExporterFactory.java +++ b/core/src/net/sf/openrocket/file/wavefrontobj/export/OBJExporterFactory.java @@ -154,6 +154,7 @@ public class OBJExporterFactory { // Component exporting String groupName = idx + "_" + component.getName(); + groupName = sanitizeGroupName(groupName); handleComponent(obj, this.configuration, this.options.getTransformer(), component, groupName, materials.get(obj), this.options.getLOD(), options, warnings); @@ -293,6 +294,20 @@ public class OBJExporterFactory { return sortedComponents; } + /** + * Sanitize the group name by replacing illegal characters with underscores. + * @param groupName the group name to sanitize + * @return the sanitized group name + */ + private static String sanitizeGroupName(String groupName) { + Character c = FileUtils.getIllegalFilenameChar(groupName); + while (c != null) { + groupName = groupName.replace(c, '_'); + c = FileUtils.getIllegalFilenameChar(groupName); + } + return groupName; + } + private void addChildComponentToList(RocketComponent parent, Set components, Set sortedComponents) { for (RocketComponent child : parent.getChildren()) { if (components.contains(child)) {