I’m using openNURBS 7.x. I’ve tried setting the text height on both the ON_Text and ON_DimStyle object, neither produce the result I’m looking for. I suspect I’m not adding the ON_DimStyle to the document correctly or the ID of the ON_DimStyle referenced by the ON_Text is changing after adding.
Here is a snippit of the last thing I tried. Here I’m just using the ID of the DimStyle before adding it to the model. I’ve also tried casting dimRef to a ON_DimStyle to retrieve the ID, but that didn’t work.
ONX_Model = ...;
ON_Text* pText = someText.Duplicate();
// Create the attributes
ON_3dmObjectAttributes *pObjAttribs = someAttributes.Duplicate();
pObjAttribs->m_color.SetRGB(255, 0, 0);
// Create and add the DimStyle
// ON_DimStyle::DefaultMillimeterSmall fails here for some reason
ON_DimStyle* pTextDimStyle = pText->DimensionStyle(ON_DimStyle::SystemDimstyleFromIndex(-5)).Duplicate();
ON_ModelComponentReference dimRef = model.AddManagedModelGeometryComponent(pTextDimStyle, nullptr);
// Add the text to the document
ON_ModelComponentReference ref = model.AddManagedModelGeometryComponent(pText, pObjAttribs);
I’m really not sure of the proper way to handle the ON_DimStyles. I’ve never worked with them before. My assumption is this that I need to create a new ON_DimStyle, set the text height, then add it to the ONX_Model. Then I need to get the ID of the newly added DimStyle and use ON_Text::SetDimensionStyleId to set the text ON_DimStyle before adding it to the ONX_Model. Is this correct?
I was able to create some text and a DimStyle and add them to a Rhino document just fine. But for whatever reason, I just can’t get it to work in openNURBS.
Is there an example of how to do this?