Hi TechSoft3D Team,
I am trying to export a CAD file to shattered SCZ , SCS and master.xml using HOOPS Communicator/Authoring SDK, but I am only getting a single .scz and .scs file, instead of multiple shattered parts.
Here’s the code I am using:
bool HoopsConverter::ExportToShattered(const MY_CHAR* license, const MY_CHAR* input, const MY_CHAR* output) {
std::string startTime = GetFormattedTime();
auto start = std::chrono::high_resolution_clock::now();
try {
// Initialize converter
Converter converter;
converter.SetLogfile(logFilePath.c_str());
if (!converter.Init(license)) {
LogMessage("ERROR: SCZ Converter initialization failed.");
return false;
}
Importer importer;
if (!importer.Init(&converter)) {
LogMessage("ERROR: SCZ Importer initialization failed.");
return false;
}
SC_Import_Options importOptions;
if (!importer.Load(input, importOptions)) {
LogMessage("ERROR: Failed to load input file: " + std::string(input));
return false;
}
Exporter exporter;
if (!exporter.Init(&importer)) {
LogMessage("ERROR: SCZ Exporter initialization failed.");
return false;
}
// Ensure directories exist
std::string outputDir = std::string(output);
std::string scsDir = outputDir + "/scs";
std::string sczDir = outputDir + "/scz";
fs::create_directories(outputDir);
fs::create_directories(scsDir);
fs::create_directories(sczDir);
std::string xmlFile = outputDir + "/master.xml";
// Setup export options
SC_Export_Options exportOptions;
exportOptions.export_assemblytree = true;
exportOptions.export_materials = true;
exportOptions.export_physical_properties = true;
exportOptions.export_attributes = true;
exportOptions.export_measurement = true;
exportOptions.prepare_shattered_xml = xmlFile;
exportOptions.prepare_shattered_scs_parts = scsDir;
exportOptions.prepare_shattered_parts = sczDir;
exportOptions.compute_bounding_boxes = "All";
// Export shattered SCZ
if (!exporter.WriteSCShattered(exportOptions)) {
LogMessage("ERROR: Failed to export SCZ files.");
return false;
}
if (!fs::exists(xmlFile)) {
LogMessage("WARNING: master.xml not created at: " + xmlFile);
}
} catch (const std::exception& e) {
LogMessage(std::string("Exception in ExportToSCZ: ") + e.what());
return false;
}
return true;
}
Problem:
-
The export completes successfully, and I get one
.sczfile inscz/and one.scsfile inscs/. -
The
master.xmlfile is created correctly but not sure is correct . -
No other shards are generated, even though my CAD model contains multiple components/subassemblies.
What I want:
-
Multiple shattered
.sczfiles for each part/component. -
Corresponding
.scsfiles for each part/component. -
master.xmllisting all part/component.
Questions:
-
Is there any issue in my code that prevents shattering?
-
Are there additional
SC_Export_Optionsflags I need to set to force shattering? -
Could the problem be related to input file naming, directory paths, or something else?
Any help or guidance would be appreciated!
Thanks.