STL to STEP

Hello everyone,

I import stl file with method RWStl::ReadFile because I have a large size STL so old fashion way takes (I mean StlAPI_Reader) too much time. And after import stl file want to convert to STEP file. But I couldn't convert that . In writer.Transfer section status returns fail. For any idea I will be appreciated.

        TCollection_AsciiString theFileName = Utilities::ToAsciiString(inp);
	auto aTris = RWStl::ReadFile(theFileName.ToCString(), 0.1);
	auto face = TopoDS_Face();
	auto aBuilder = BRep_Builder();
	aBuilder.MakeFace(face, aTris);

        STEPControl_Writer writer;

	IFSelect_ReturnStatus status = writer.Transfer(face, STEPControl_ManifoldSolidBrep);
	const TCollection_AsciiString asciiExportPath = Utilities::ToAsciiString(exportPath);
	status = writer.Write(asciiExportPath.ToCString());

	return true;
Dmitrii Pasukhin's picture

Hello,

Can you share OCCT version, that you use?

Support of STEP tessalating was released in 7.7.0.

Best regards, Dmitrii.

Batuhan Cengiz's picture

I use 7.6.0 but of course can update the version if there is a solution in 7.7.0

Batuhan Cengiz's picture

I just updated the OCCT to 7.7.0. What should I do next?

Dmitrii Pasukhin's picture

Setting up schema to 242:

Interface_Static::SetCVal("write.step.schema","AP242DIS"); 

And then just export.

Best regards, Dmitrii.

Dmitrii Pasukhin's picture

Sorry, addionally you need to accept only tess entities:

STEPControl_Controller::Init();

    Interface_Static::SetCVal("write.step.schema","AP242DIS"); 

    Interface_Static::SetCVal("write.step.tessellated", "On");

Best regards, Dmitrii.

Batuhan Cengiz's picture

I don't understand how to use these lines in my code? Can you explain more please?

Dmitrii Pasukhin's picture

Just copy-past before writing. Please read STEP Translator - Open CASCADE Technology Documentation