DATAKIT SDK  V2026.4
testlibstepwrite.cpp File Reference

Namespaces

 stepw
 Exported APIs for STEP Write Library.
 
 stepw::sample
 Set of sample functions to write specific data into a .stp file.
 

Functions

Dtk_AxisSystemPtr stepw::sample::CreateAxisSystem ()
 
void stepw::sample::CreateTransforms (Dtk_transfo &outFirst, Dtk_transfo &outSecond, Dtk_transfo &outThird, Dtk_transfo &outFourth)
 
DtkErrorStatus StepWriteSample (const Dtk_string &inResultDirectory)
 
DtkErrorStatus stepw::sample::Write_MinimumViableFile (const Dtk_string &inPartName, int &outPartID)
 
DtkErrorStatus stepw::sample::Write_UserDefinedHeader (const Dtk_string &inPartName, int &outPartID)
 
DtkErrorStatus stepw::sample::WriteAssembly (const Dtk_string &inRootAssemblyName)
 
DtkErrorStatus stepw::sample::WriteAssembly_BasicExternalReference_DimensionFDT (const Dtk_string &inRootAssemblyName)
 
DtkErrorStatus stepw::sample::WriteAssembly_BasicExternalReferences (const Dtk_string &inRootAssemblyName)
 
DtkErrorStatus stepw::sample::WriteAssembly_DimensionFDT (const Dtk_string &inRootAssemblyName)
 
DtkErrorStatus stepw::sample::WriteAssembly_InstanceAttributes (const Dtk_string &inRootAssemblyName)
 
DtkErrorStatus stepw::sample::WriteAssembly_InstanceOverride (const Dtk_string &inRootAssemblyName)
 
DtkErrorStatus stepw::sample::WriteAssembly_NestedExternalReferences (const Dtk_string &inRootAssemblyName)
 
DtkErrorStatus stepw::sample::WriteAssembly_WithProperties (const Dtk_string &inRootAssemblyName)
 
DtkErrorStatus stepw::sample::WritePart_BodyAndMeshFromTessellation (const Dtk_string &inPartName, int &outPartID)
 
DtkErrorStatus stepw::sample::WritePart_BodyInNamedLayer (const Dtk_string &inPartName, int &outPartID)
 
DtkErrorStatus stepw::sample::WritePart_BodyOnly (const Dtk_string &inPartName, int &outPartID)
 
DtkErrorStatus stepw::sample::WritePart_BodyWithAxisSystem (const Dtk_string &inPartName, int &outPartID)
 
DtkErrorStatus stepw::sample::WritePart_Datum (const Dtk_string &inPartName, int &outPartID)
 
DtkErrorStatus stepw::sample::WritePart_GeometricalTolerance (const Dtk_string &inPartName, int &outPartID)
 
DtkErrorStatus stepw::sample::WritePart_MeshOnly (const Dtk_string &inPartName, int &outPartID)
 
DtkErrorStatus stepw::sample::WritePart_MeshWithFaceColors (const Dtk_string &inPartName, int &outPartID)
 
DtkErrorStatus stepw::sample::WritePart_UsedByExternalAssembly (const Dtk_string &inPartName, int &outPartID)
 
DtkErrorStatus stepw::sample::WritePart_WireframeOnly (const Dtk_string &inPartName, int &outPartID)
 
DtkErrorStatus stepw::sample::WritePart_WithProperties (const Dtk_string &inPartName, int &outPartID)
 

Function Documentation

◆ StepWriteSample()

DtkErrorStatus StepWriteSample ( const Dtk_string &  inResultDirectory)
821 {
822  Dtk_string outputFileName, outputDirectory;
823 
824  std::cout << std::endl << "----------------------------------------------" << std::endl;
825  std::cout << "Step Write start" << std::endl;
826 
827  stepw_SetModeProp( 3 );
828  stepw_SetModeFdt( 1 );
829  //stepw_SetModeFdt( 1, 5 ); Call this function to write both presentation placeholder and frozen graphic as PMI representation.
830 
831  // Choosing output directory and file name
832  outputDirectory = inResultDirectory + L"Step/";
833  outputDirectory.FixPathSeparator();
834  outputDirectory.mkdir();
835 
836  // First, initialize the Step writer
837  //int codeForAP203 = 1;
838  int codeForAP214 = 2;
839  //int codeForAP203E2 = 3;
840  int codeForAP242 = 4;
841  int codeForAP242Edition4 = 5;
842  int dummy;
843  {
844  outputFileName = outputDirectory + L"SampleMinimumProduct.step";
845  PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP214 ) );
846  PRINT_ERROR( stepw::sample::Write_MinimumViableFile( L"SampleMinimumProduct", dummy ) );
848  std::cout << "=> " << outputFileName.c_str() << std::endl;
849  }
850  //[...]
851  //end_of_mainstepwrite
852  {
853  outputFileName = outputDirectory + L"SampleMinimumProduct_UserDefinedHeader.step";
854  PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP214 ) );
855  stepw::sample::Write_UserDefinedHeader( L"SampleMinimumProduct_UserDefinedHeader", dummy );
857  std::cout << "=> " << outputFileName.c_str() << std::endl;
858  }
859  {
860  outputFileName = outputDirectory + L"SamplePart_BodyOnly.step";
861  PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP214 ) );
862  stepw::sample::WritePart_BodyOnly( L"SamplePart_BodyOnly", dummy );
864  std::cout << "=> " << outputFileName.c_str() << std::endl;
865  }
866  {
867  outputFileName = outputDirectory + L"SamplePart_BodyWithAxisSystem.step";
868  PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP214 ) );
869  stepw::sample::WritePart_BodyWithAxisSystem( L"SamplePart_BodyWithAxisSystem", dummy );
871  std::cout << "=> " << outputFileName.c_str() << std::endl;
872  }
873  {
874  outputFileName = outputDirectory + L"SamplePart_WireframeOnly.step";
875  PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP214 ) );
876  stepw::sample::WritePart_WireframeOnly( L"SamplePart_WireframeOnly", dummy );
878  std::cout << "=> " << outputFileName.c_str() << std::endl;
879  }
880  {
881  outputFileName = outputDirectory + L"SamplePart_MeshOnly.step";
882  PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP214 ) );
883  stepw::sample::WritePart_MeshOnly( L"SamplePart_MeshOnly", dummy );
885  std::cout << "=> " << outputFileName.c_str() << std::endl;
886  }
887  {
888  outputFileName = outputDirectory + L"SamplePart_MeshWithFaceColors.step";
889  PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP214 ) );
890  stepw::sample::WritePart_MeshWithFaceColors( L"SamplePart_MeshWithFaceColors", dummy );
892  std::cout << "=> " << outputFileName.c_str() << std::endl;
893  }
894  {
895  outputFileName = outputDirectory + L"SamplePart_BodyAndMeshFromTessellation.step";
896  PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP214 ) );
897  stepw::sample::WritePart_BodyAndMeshFromTessellation( L"SamplePart_BodyAndMeshFromTessellation", dummy );
899  std::cout << "=> " << outputFileName.c_str() << std::endl;
900  }
901  {
902  outputFileName = outputDirectory + L"SamplePart_WithProperties.step";
903  PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP214 ) );
904  stepw::sample::WritePart_WithProperties( L"SamplePart_WithProperties", dummy );
906  std::cout << "=> " << outputFileName.c_str() << std::endl;
907  }
908  {
909  outputFileName = outputDirectory + L"SamplePart_BodyInNamedLayer.step";
910  PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP242 ) );
911  stepw::sample::WritePart_BodyInNamedLayer( L"SamplePart_BodyInNamedLayer", dummy );
913  std::cout << "=> " << outputFileName.c_str() << std::endl;
914  }
915  {
916  outputFileName = outputDirectory + L"SamplePart_Datum.step";
917  PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP242Edition4 ) );
918  stepw::sample::WritePart_Datum( L"SamplePart_Datum", dummy );
920  std::cout << "=> " << outputFileName.c_str() << std::endl;
921  }
922  {
923  outputFileName = outputDirectory + L"SamplePart_GeometricalTolerance.step";
924  PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP242Edition4 ) );
925  stepw::sample::WritePart_GeometricalTolerance( L"SamplePart_GeometricalTolerance", dummy );
927  std::cout << "=> " << outputFileName.c_str() << std::endl;
928  }
929  {
930  outputFileName = outputDirectory + L"SamplePart_UsedByExternalAssembly.step";
931  PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP242 ) );
932  stepw::sample::WritePart_UsedByExternalAssembly( L"SamplePart_UsedByExternalAssembly", dummy );
934  std::cout << "=> " << outputFileName.c_str() << std::endl;
935  }
936  {
937  outputFileName = outputDirectory + L"SampleAssembly.step";
938  PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP242Edition4 ) );
939  stepw::sample::WriteAssembly( L"SampleAssembly" );
941  std::cout << "=> " << outputFileName.c_str() << std::endl;
942  }
943  {
944  outputFileName = outputDirectory + L"SampleAssembly_InstanceOverride.step";
945  PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP242 ) );
946  stepw::sample::WriteAssembly_InstanceOverride( L"SampleAssembly_InstanceOverride" );
948  std::cout << "=> " << outputFileName.c_str() << std::endl;
949  }
950  {
951  outputFileName = outputDirectory + L"SampleAssembly_DimensionFDT.step";
952  PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP242Edition4 ) );
953  stepw::sample::WriteAssembly_DimensionFDT( L"SampleAssembly_DimensionFDT");
955  std::cout << "=> " << outputFileName.c_str() << std::endl;
956  }
957  {
958  outputFileName = outputDirectory + L"SampleAssembly_WithProperties.step";
959  PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP242 ) );
960  stepw::sample::WriteAssembly_WithProperties( L"SampleAssembly_WithProperties");
962  std::cout << "=> " << outputFileName.c_str() << std::endl;
963  }
964  {
965  outputFileName = outputDirectory + L"SampleAssembly_InstanceAttributes.step";
966  PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP242 ) );
967  stepw::sample::WriteAssembly_InstanceAttributes( L"SampleAssembly_InstanceAttributes" );
969  std::cout << "=> " << outputFileName.c_str() << std::endl;
970  }
971  {
972  outputFileName = outputDirectory + L"SampleAssembly_BasicExternalReferences.step";
973  PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP242 ) );
974  stepw::sample::WriteAssembly_BasicExternalReferences( L"SampleAssembly_BasicExternalReferences");
976  std::cout << "=> " << outputFileName.c_str() << std::endl;
977  }
978  {
979  outputFileName = outputDirectory + L"SampleAssembly_BasicExternalReference_DimensionFDT.step";
980  PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP242 ) );
981  stepw::sample::WriteAssembly_BasicExternalReference_DimensionFDT( L"SampleAssembly_BasicExternalReference_DimensionFDT");
983  std::cout << "=> " << outputFileName.c_str() << std::endl;
984  }
985  {
986  outputFileName = outputDirectory + L"SampleAssembly_NestedExternalReferences.step";
987  PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP242 ) );
988  stepw::sample::WriteAssembly_NestedExternalReferences( L"SampleAssembly_NestedExternalReferences");
990  std::cout << "=> " << outputFileName.c_str() << std::endl;
991  }
992 
993  std::cout << "Step Write end" << std::endl;
994 
995  return dtkNoError;
996 }
stepw::sample::WritePart_MeshOnly
DtkErrorStatus WritePart_MeshOnly(const Dtk_string &inPartName, int &outPartID)
Definition: testlibstepwrite.cpp:123
stepw::sample::WriteAssembly_InstanceOverride
DtkErrorStatus WriteAssembly_InstanceOverride(const Dtk_string &inRootAssemblyName)
Definition: testlibstepwrite.cpp:426
Dtk_string
This is a high level string class.
Definition: dtk_string.hpp:53
stepw::sample::WritePart_BodyWithAxisSystem
DtkErrorStatus WritePart_BodyWithAxisSystem(const Dtk_string &inPartName, int &outPartID)
Definition: testlibstepwrite.cpp:86
PRINT_ERROR
#define PRINT_ERROR(inStatus)
Definition: testwriters.h:9
stepw::sample::WritePart_WireframeOnly
DtkErrorStatus WritePart_WireframeOnly(const Dtk_string &inPartName, int &outPartID)
Definition: testlibstepwrite.cpp:106
stepw_SetModeProp
DtkErrorStatus stepw_SetModeProp(const int inMode)
Activates/Deactivates writing of properties : User Attributes, Product Data.
stepw_InitFile
DtkErrorStatus stepw_InitFile(const Dtk_string &inFileName, const char *inOriginatingSystem=" user ", const int inSchema=0)
Initializes a file to be written.
stepw::sample::WriteAssembly_BasicExternalReferences
DtkErrorStatus WriteAssembly_BasicExternalReferences(const Dtk_string &inRootAssemblyName)
Definition: testlibstepwrite.cpp:658
stepw::sample::WritePart_BodyOnly
DtkErrorStatus WritePart_BodyOnly(const Dtk_string &inPartName, int &outPartID)
Definition: testlibstepwrite.cpp:68
stepw_SetModeFdt
DtkErrorStatus stepw_SetModeFdt(const int inMode, const int inPolyline=2)
Activates/Deactivates writing of FDT.
stepw::sample::Write_MinimumViableFile
DtkErrorStatus Write_MinimumViableFile(const Dtk_string &inPartName, int &outPartID)
Definition: testlibstepwrite.cpp:43
stepw::sample::WritePart_BodyInNamedLayer
DtkErrorStatus WritePart_BodyInNamedLayer(const Dtk_string &inPartName, int &outPartID)
Definition: testlibstepwrite.cpp:354
stepw::sample::WritePart_Datum
DtkErrorStatus WritePart_Datum(const Dtk_string &inPartName, int &outPartID)
Definition: testlibstepwrite.cpp:228
stepw::sample::WriteAssembly_InstanceAttributes
DtkErrorStatus WriteAssembly_InstanceAttributes(const Dtk_string &inRootAssemblyName)
Definition: testlibstepwrite.cpp:616
stepw::sample::WriteAssembly_BasicExternalReference_DimensionFDT
DtkErrorStatus WriteAssembly_BasicExternalReference_DimensionFDT(const Dtk_string &inRootAssemblyName)
Definition: testlibstepwrite.cpp:739
stepw_EndFile
DtkErrorStatus stepw_EndFile()
Ends the writing of the current STEP file.
Dtk_string::c_str
const char * c_str() const
Retrieve the ASCII conversion string.
stepw::sample::Write_UserDefinedHeader
DtkErrorStatus Write_UserDefinedHeader(const Dtk_string &inPartName, int &outPartID)
Definition: testlibstepwrite.cpp:54
Dtk_string::mkdir
int mkdir() const
File Utility : Create a Directory.
Dtk_string::FixPathSeparator
void FixPathSeparator()
File Utility : Fixes path separator consistency. It lets you replace the '\' or '/' by the OS needed ...
stepw::sample::WritePart_UsedByExternalAssembly
DtkErrorStatus WritePart_UsedByExternalAssembly(const Dtk_string &inPartName, int &outPartID)
Definition: testlibstepwrite.cpp:327
stepw::sample::WriteAssembly_WithProperties
DtkErrorStatus WriteAssembly_WithProperties(const Dtk_string &inRootAssemblyName)
Definition: testlibstepwrite.cpp:562
stepw::sample::WritePart_GeometricalTolerance
DtkErrorStatus WritePart_GeometricalTolerance(const Dtk_string &inPartName, int &outPartID)
Definition: testlibstepwrite.cpp:276
stepw::sample::WriteAssembly_NestedExternalReferences
DtkErrorStatus WriteAssembly_NestedExternalReferences(const Dtk_string &inRootAssemblyName)
Definition: testlibstepwrite.cpp:697
stepw::sample::WritePart_BodyAndMeshFromTessellation
DtkErrorStatus WritePart_BodyAndMeshFromTessellation(const Dtk_string &inPartName, int &outPartID)
Definition: testlibstepwrite.cpp:161
stepw::sample::WritePart_WithProperties
DtkErrorStatus WritePart_WithProperties(const Dtk_string &inPartName, int &outPartID)
Definition: testlibstepwrite.cpp:186
stepw::sample::WriteAssembly
DtkErrorStatus WriteAssembly(const Dtk_string &inRootAssemblyName)
Definition: testlibstepwrite.cpp:387
stepw::sample::WriteAssembly_DimensionFDT
DtkErrorStatus WriteAssembly_DimensionFDT(const Dtk_string &inRootAssemblyName)
Definition: testlibstepwrite.cpp:476
dtkNoError
@ dtkNoError
Definition: error_dtk.hpp:151
stepw::sample::WritePart_MeshWithFaceColors
DtkErrorStatus WritePart_MeshWithFaceColors(const Dtk_string &inPartName, int &outPartID)
Definition: testlibstepwrite.cpp:141