Layer name auditing is too sever

Hi,

The ONX_Model::Audit method considers invalid those layer names which starts with the ‘-’ character.
If I set “bAttemptRepair = true”, then it changes all these layer names with some generated values.

For example:

  • If the desired layer name is “- my layer name” then after calling ONX_Model::Audit it will become “Layer_01”.

Why is this happening if on the Rhino UI it is allowed to specify layer names starting with ‘-’?

Thanks

Clearly the code isn’t up-to-date with what Rhino 5 is doing. I’ve checked openNURBS code for the Rhino WIP and it isn’t the same, so I don’t see any reason to report this.

If you are looking to validate object ‘names’, you can use the following:

BOOL RhinoIsValidName( const wchar_t* name )
{
  BOOL bPermitInternalSpaces = true;
  BOOL rc = false;
  BOOL bLastCharWasSpace = false;
  if ( 0 != name 
       && *name > 32 
       && *name != 127 
       && *name != '(' // first character in layer/object/... name cannot be a bracket
       && *name != ')' 
       && *name != '[' 
       && *name != ']' 
       && *name != '{' 
       && *name != '}' 
       )
  {
    rc = true;
    for ( name++; *name && rc; name++ ) {
      if ( *name == 32 ) {
        rc = bPermitInternalSpaces;
        bLastCharWasSpace = true;
      }
      else if ( *name == 127 || *name < 32 )
        rc = false;
      else
        bLastCharWasSpace = false;
    }
  }
  return (rc && !bLastCharWasSpace) ? true : false;
}

Thanks.