SetUserString() call on On_BrepEdge not being saved to 3dm file

So i’m setting some data via SetUserString() on a brep edge that is then saved to a 3dm file like so

sorry for the formatting, i can’t figure out your forum’s codeblock syntax

    ONX_Model model;
    ON_TextLog errorLog;
    const int version = 60; // write 6.0 compatible

    model.m_properties.m_Application.m_application_name = "engine";
    model.m_properties.m_Application.m_application_URL = "";

        model.m_properties.m_Application.m_application_details = "";
        model.AddDefaultLayer(L"brep", ON_Color::UnsetColor);

        for(const auto &brep : breps)
        {
            ON_3dmObjectAttributes attributes;
            attributes.m_name = "brep";

            brep->preserveEdgeUUIDs(); //calls setCustomId

            model.AddModelGeometryComponent(brep->get(), &attributes, true);
            model.m_sStartSectionComments = "";
        }

        ok = model.Write(filename.c_str(), version, &errorLog);

—-

and loading it like so

    if(model.Read(filename.c_str(), &errorLog))
        {
            ONX_ModelComponentIterator it(model, ON_ModelComponent::Type::ModelGeometry);
            const ON_ModelComponent *mc = nullptr;

            auto &renderer = Graphics::Core::Renderer::current();
            auto transferCommands = renderer.getFrameTransferCommandList();
            Graphics::Core::PipelineState defaultState;
            defaultState.setDefault();

            auto solidPipeline = renderer.getPipeline(Graphics::Core::Renderer::ShaderType::PBR_BASIC_SS_TRIM_GBUFFER, &defaultState);
            auto material = BasicPBRMaterial::createDefaultMaterial(solidPipeline, transferCommands);

            for(mc = it.FirstComponent(); mc; mc = it.NextComponent())
            {
                if(auto geometry = ON_ModelGeometryComponent::Cast(mc))
                {
                    if(auto fileBrep = ON_Brep::Cast(geometry->Geometry(nullptr)))
                    {
                        for(int ei = 0; ei < fileBrep->m_E.Count(); ei++)
                        {
                            auto edge = fileBrep->Edge(ei);
                            if(auto id = Utils::ON::getCustomId(edge, L"source-uuid"))
                            {
                                logger << "got one!  " << id->toString() << endl;
                            }
                        }
//….

where

template 
std::optional<Utils::UUID> getCustomId(const P &obj, const wchar_t \*key)
{
ON_wString onStr;
if(obj->GetUserString(key, onStr))
{
return Utils::UUID(std::wstring(onStr.Array()));
}
return std::nullopt;
}

template 
void setCustomId(P &obj, const wchar_t \*key, const Utils::UUID &id)
{
std::wstring uuidStr = id.toString<wchar_t>();
obj->SetUserString(key, uuidStr.c_str());
}

I’ve been able to confirm via breakpoints that the archive write method and read methods for the user string lists are being called, but for some reason no matter what I try, I simply cannot get the user string back from the 3dm file.

ah, i see what happened. the edges acting as curve proxies passed the data down to the underying curves themselves. so my id data got sent down to the m_C3’s upon write/read of the 3dm file.

edit: but for only 2 curves out of my whole scene? I’m still at a complete loss as to what’s going on here.

Code markup is your regular MarkDown approach. I have fixed it in your post. Just enclose code in triple backticks, and no backticks in-between them. Instead of backticks you could also use triple tilde.

```
some code here
```

or

~~~
more code here
~~~

Hi @Michael_Farrell,

Attached any user data to curves in the ON_Brep::m_C3 array. If you have an edge, use ON_BrepEdge::EdgeCurveIndexOf to get the index into the array.

– Dale

thanks Dale. I’ll give that a shot.