Assign default name of import group based on name of imported file.

[git-p4: depot-paths = "//depot/solvespace/": change = 2133]
This commit is contained in:
Jonathan Westhues 2010-05-02 21:38:25 -08:00
parent 01ecb986f4
commit 7bd871ad28
2 changed files with 25 additions and 2 deletions

View File

@ -237,7 +237,31 @@ void Group::MenuGroup(int id) {
if(strlen(g.impFile) == 0) {
if(!GetOpenFile(g.impFile, SLVS_EXT, SLVS_PATTERN)) return;
}
g.name.strcpy("import");
// Assign the default name of the group based on the name of
// the imported file.
char groupName[MAX_PATH];
strcpy(groupName, g.impFile);
char *dot = strrchr(groupName, '.');
if(dot) *dot = '\0';
char *s, *start = groupName;
for(s = groupName; *s; s++) {
if(*s == '/' || *s == '\\') {
start = s + 1;
} else if(isalnum(*s)) {
// do nothing, valid character
} else {
// convert invalid characters (like spaces) to dashes
*s = '-';
}
}
if(strlen(start) > 0) {
g.name.strcpy(start);
} else {
g.name.strcpy("import");
}
g.meshCombine = COMBINE_AS_ASSEMBLE;
break;
}

View File

@ -2,7 +2,6 @@ add checked/unchecked checkbox and radio button
fix bug with rotation in plane where green line stays displayed
lock point where dragged constraint
expose transformed point stuff in library, and email McNeel
assign default name for import groups based on filename
-----
rounding, as a special group