How to get embedded texture images

By opening a 3dm file with texture in Rhino, a folder named _embedded_files is created. I wonder how to get these embedded images by openNurbs c++ sdk? Thank you!

@johnc - is this something you can help with?

Hi @jiangz-a,

The embedded texture files are written to the 3dm file by the RDK plug-in. Currently OpenNurbs does not have access to this information so it’s not possible to get those images by using the OpenNurbs C++ SDK. This may change, however, as we are considering adding access to RDK data from OpenNurbs in a future release.

John

Thank you very much!

I would like to know if Opennurbs still doesn’t support embedded textures?

Hi @maiken,

I believe we are planning on exposing RDK data in openNURBS 8. For now, you’ll need to be inside of Rhino to access it, either by way of a Rhino plug-in or by running Rhino inside of your application.

– Dale

Excuse me, does the latest openNurbs support extracting the embedded images from 3dm files?

Hi @sw11,

When you say “embedded images”, are you referring to material textures?

– Dale

yes, I want to get the texture files.

@johnc - can you help?

Hi @sw11,

Here is some example C++ code that loads a 3dm file, iterates over all the embedded texture files, and saves them to a folder. You should just have to fill in your own file and folder names to get the code to compile. It should work using the latest OpenNURBS release.

I hope this helps,

John

bool TestExtractEmbeddedFiles(void)
{
    ONX_Model model;

    if (!model.Read(::YOUR 3DM FILENAME HERE::))
      return false;

    ONX_ModelComponentIterator it(model, ON_ModelComponent::Type::EmbeddedFile);
    const auto* component = it.FirstComponent();
    while (nullptr != component)
    {
      const auto* embedded_file = ON_EmbeddedFile::Cast(component);
      if (nullptr != embedded_file)
      {
        const ON_wString original_full_path = embedded_file->Filename();
        const ON_wString file_name = ON_FileSystemPath::FileNameFromPath(original_full_path, true);
        const ON_wString new_full_path = ON_wString(::YOUR FOLDER WITH / HERE::) + file_name;
        embedded_file->SaveToFile(new_full_path);
      }

      component = it.NextComponent();
    }

    return true;
}
1 Like