Material.name / Material.display_name max size?

Is there an internal maximum length limit for the material name / display name or AttributeDictionary key name?
For example 60 characters, MAX_PATH or etc?

We intend to cache the names of materials and we are curious if we can reserve a “maximum size” for these names.

Off topic:
Is any documentation about Sketchup limits? Somewhere on forum I found that the maximum precision of SU data is 0.001 inch, but what about max size of textures, names etc?

I’ve never thought about making material names longer than I’d liek to read. However it’s failry simple to test if there is a limit. Just assign a really long name to a material and see if it gets truncated.

You may need to save and re-open the model in between though. I had some issue years back and can’t remember the details but I think an empty Array could be saved as an attribute, but only for that SU session. When re-opening the model the value had changed to nil meaning the data in memory and data saved to disk may not always be identical.

I don’t know any articles about SU limits/precision but I’m also interested in this.

are you talking about storing in the skp file using the SDK as the topic suggests?

any ‘additional’ stored items will bloat the model and slow it down,

material names should be as short as possible for readability…

check the FreeImageLibrary and OpenGL restrictions for names and paths…

john

No, I’m going to cache on my side material names from Sketchup and I’m curious if SU names have any size restrictions (maximum size).

@DanRathbun thank you for your response, but this is Sketchup SDK section, I’m asking from skp-reader/importer C-API perspective (sorry no Ruby here :slight_smile:) and my material “cache” is not on Sketchup side.

I agree with you all that the names should be as short as possible, but we must support what has been provided by SU, and I am just looking for some optimization.

Drop this code in the Ruby Console and you’ll see that a material name of 10k characters will work just fine. So to answer your question, I don’t think there is a limit on material names within Sketchup. I didn’t try this with AttributeDictionary key names.

module SW::Matname
  name = 'aaaaaaaaaa'
  model = Sketchup.active_model
  materials = model.materials
  material = materials.add(name)

  1000.times {
    puts name.length
    material.name= name
    break if name != material.display_name
  
    name += 'aaaaaaaaaa'
  }

  puts 'length = ' + material.display_name.length.to_s

end

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.