How to avoid duplicate materials when importing SKP created from SDK

#1

Most of us are probably aware that if you manually import a Component into SketchUp and the component includes identical materials to those that are already in your model, SketchUp will not create duplicate materials. Instead, it will assign the existing matching materials to the newly imported Component.

I am having trouble replicating this behavior when importing a Component that I exported using the SDK. I believe that the Component (skp file) has identical material properties to the existing materials in the model. The materials are all simple colors. All material properties appear to match:

  • Same Name
  • Same Color
  • Same Alpha
  • Same colorize_type
  • Same Display Name
  • Same materialType
  • Same texture (nil)
  • Same use_alpha?
  • Same colorize_deltas
  • Same attribute dictionaries (nil)

Even so, when I import the SKP that was generated using the SDK, duplicate materials get created by SketchUp. Am I missing something or could this be a bug?

Thanks!

0 Likes

#2

Hmm… First time I’ve heard of that. Sounds like a bug to me.

Can you try to save a copy of the SUModelRef your importer is building? Then import from the UI and see if that changed behaviour?

If it does, can you log it in our issue tracker? https://github.com/SketchUp/api-issue-tracker/issues

0 Likes