Tue, 05/23/2023 - 11:32
Hello,
I am trying to split part with a .STEP file,I can get the TopoDs_Shape but when i save it the file was no color. I dont know why,Is me lost the color when i load it?
This is my code:
string ShapeToStep1(TopoDS_Shape shape) {
string route = "E:/Share/1/test.step";
const Standard_CString aFileName = route.c_str();
STEPControl_StepModelType type = STEPControl_AsIs;
STEPControl_Writer aWriter;
aWriter.Transfer(shape, STEPControl_AsIs);
aWriter.Write(aFileName);
return aFileName;
}
Tue, 05/23/2023 - 14:53
Hello,
STEPControl_Writer doesn't support any data instead of geometry. TopoDS_Shape contains only geometry. To work with color and other attributes you need to work with TDocStd_Document.
Please take a look into Extended Data Exchange (XDE) - Open CASCADE Technology Documentation
If you need an example how to attache a color into TopoDS_Shape, let me know. But in TopoDS_Shape you can't store any attributes.
Best regards, Dmitrii,
Wed, 05/24/2023 - 06:40
Thanks,
I can save .step file with right color when i use STEPCAFControl_Writer,But when the TDF_Lable has TopoDs_Shape more than one how can i save .step with the part of label with them original color?
Wed, 05/24/2023 - 10:10
Please look into XCadDoc_Editor. I suggest, you need to create a new document and copy needed TDF_Label into new Doc (all reference attributes will be copy too)
If you will have some problem, with XcafDoc_Editor, let me know. This class has no very often usage.
Best regard, Dmitrii.
Wed, 05/24/2023 - 11:01
Thanks,I will try it
I found anther one question .when i save the part of assemb with STEPCAFControl_Writer. The parts of them get wrong location.
Wed, 05/24/2023 - 11:57
It is a normal case.You need to calculate global transform all all parents and update own transformation.
It is necessary to keep the same position on the scene.
Best regards, Dmitrii.
Wed, 05/24/2023 - 12:55
You means get some information for TDF_Label?and how to change the part location? I dont know how to do this,Can you give me some specific method,Thanks
Wed, 05/24/2023 - 13:08
So, To change position of root you need to get Handle(XCafDoc_ShapeTool) from the document and then call aShTool->SetLocation(theRootL, theLocation, theNewRootL);
theNewRootL - label with moved location.
Best regards, Dmitrii.
Thu, 05/25/2023 - 13:13
Sorry,I can't find any function about SetLocation(theRootL, theLocation, theNewRootL) in OCCT.
thanks.
Thu, 05/25/2023 - 13:31
It was implemented into OCCT 7.7.0
If you use older version, please copy-past a code to your solution from new version.
Best regards, Dmitrii.
Fri, 05/26/2023 - 11:09
sorry,I'm still can't find this function.Is it contained by TDocStd_Document.hxx or XCAFDoc_ShapeTool.hxx?I only can find TopLoc_Location GetLocation (const TDF_Label &L).
Fri, 05/26/2023 - 11:18
XCAFDoc_ShapeTool.hxx
OCCT Git - occt.git/blob - src/XCAFDoc/XCAFDoc_ShapeTool.hxx (opencascade.org)
Best regards, Dmitrii.
Mon, 05/29/2023 - 06:13
I think when i get the part label i'm already get wrong location or lost shape location.The location for .STEP what i saved was moved to origin.How do i get the original location.
vecShapelabels;
Here is my code:
bool test(Standard_CString fileloc) {
Handle(TDocStd_Document) aDocument = ReadSTEPToDocument(fileloc);
Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDocument->Main());
TDF_LabelSequence aRootLabels;
aShapeTool->GetFreeShapes(aRootLabels);
TDF_Label labelMain;
std::vector
for (TDF_LabelSequence::Iterator aRootIter(aRootLabels); aRootIter.More(); aRootIter.Next())
{
const TDF_Label& aRootLabel = aRootIter.Value();
if (XCAFDoc_ShapeTool::IsAssembly(aRootLabel)) vecShapelabels11;
{
if (labelMain.IsNull())
{
labelMain = aRootLabel;
}
}
GetAssemblyShapes(aRootLabel, vecShapelabels);
char* namee;
std::vector
for (auto it_ls = vecShapelabels.begin(); it_ls != vecShapelabels.end(); ++it_ls)
{
std::string sss = "test.STEP";
auto L2 = aShapeTool->GetLocation(*it_ls);
TDF_Label anewlabel;
bool setloc = aShapeTool->SetLocation(*it_ls, L2, anewlabel);
WriteStepByXDE(sss.c_str(), anewlabel);
}
}
return true;
}
Thanks.
Mon, 05/29/2023 - 11:20
I found I can't get any location from TDF_Label by GetLocation (const TDF_Label& L).This function always return false When i use SetLocation (const TDF_Label& theShapeLabel, const TopLoc_Location& theLoc, TDF_Label& theRefLabel) By a TopLoc_Location like jpg2.
Fri, 05/26/2023 - 14:55
is there any visual studio .sln file to read the step file and .d file. i want to read both the file. in open cascade
Fri, 05/26/2023 - 15:17
Hello,
Can you describe your goal a little detailed?
OCCT repo contains a few .step to test. Moreover, you be able to dowload installed solution from Download - Open CASCADE Technology
Best regards, Dmitrii.