
Fri, 03/17/2023 - 17:10
Hi everyone,
I am experiencing some weird behavior with the STEP export of this 3D Text.
When I save the document in native XBF format everything works fine, just when I export to Step somehow the color is lost.
This only happens with StdPrs_BRepTextBuilder shapes for me, when I generate a BRepPrimAPI_MakeBox(5.0, 5.0, 5.0) the color gets exported without a problem. To verify I open both XBF and STEP with the CAD Assistant. I'm running this on Linux with cmake default options and V7_6_3.
Have a nice day!
Code:
Handle_TDocStd_Application app = new TDocStd_Application;
BinXCAFDrivers::DefineFormat(app);
Handle_TDocStd_Document doc;
app->NewDocument("BinXCAF", doc);
StdPrs_BRepFont brep_font("/usr/share/fonts/truetype/ubuntu/Ubuntu-R.ttf", 11, 0);
StdPrs_BRepTextBuilder builder;
TopoDS_Shape shape = builder.Perform(brep_font, "Awesome");
Handle_XCAFDoc_ShapeTool shapeTool = XCAFDoc_DocumentTool::ShapeTool(doc->Main());
Handle_XCAFDoc_ColorTool colorTool = XCAFDoc_DocumentTool::ColorTool(doc->Main());
TDF_Label label = shapeTool->AddShape(shape);
colorTool->SetColor(label, Quantity_NOC_GOLDENROD3, XCAFDoc_ColorGen);
app->SaveAs(doc, "/home/peterbe/hello_occ.xbf");
STEPCAFControl_Writer writer;
auto result = writer.Transfer(doc, STEPControl_AsIs);
if (result == Standard_True)
result = writer.Write("/home/peterbe/hello_occ.stp") == IFSelect_RetDone;
Fri, 03/17/2023 - 17:56
Hello,
Can you share a result xbf file?
Best regards, Dmitrii.
Mon, 03/20/2023 - 12:25
Hi Dmitrii,
of course, thanks for looking into this :)
I tried another thing. When I load the STEP file in CAD Assistant and set the color there and load it back to my program, I can export and the color gets persisted in STEP.
Best regards,
Peter
Mon, 03/20/2023 - 14:34
Thank you for your update.
I detect problem with your generated shape. There incorrect transformation ( I think that result of building has default transformation with error flag SCALED) It can be a regression. I need to check. As a result, when you call AddShape() tool add transform reference label. And you add your color on dummy label. So, I recommended 2 way - clear transformation of build shape (Set default transformation), the second way - use GetRefferedShape to get valid label to put attributes (XCAFDoc_ShapeTool::GetReferredShape(aNotValidL, aValidL)
I will check the status of build alghoritm and its output. But it will impact on the next release.
Best regards, Dmitrii.
Fri, 03/24/2023 - 11:34
Hi Dmitrii,
I could not get the fixes working but I probably did something wrong anyway.
As you suggested the new version 7_7_1 fixes the problem so I switched and everything works fine.
Thank you!
Tue, 03/28/2023 - 10:58
Hi, I think I found another possible problem regarding the color export. When used as a top level shape as in the code above all works as expected in 7_7_1 , but we do build a hierarchy of assemblies and there the color is missing in the final step file.
Best regards, Peter
Edit: Updated with correct exports
Tue, 03/28/2023 - 12:56
Thank you.
You create not usual assembly. Your assembly has 2 level reference.
I will create the ticket, but it has low priority.
Please use the next code to avoid creating dummy reference.
Best regards, Dmitrii.