How-To: Identify missing or failing parts when loading an assembly

When HOOPS Exchange loads A CAD Assembly, the import can succeed even if some components are missing.
Some readers, such as Solidworks, can even provide the complete tessellation of the model when components are missing.

Here are the possible ways to identify the missing or failing part in an assembly:

Log file

The callback functions of HOOPS exchange gives a variety of message, warning and errors that describe what happens during the import operation.
Users can use them to understand what parts are missing or failed to load in the assembly context.

API to get dependencies list

A3DAsmGetFilesPathFromModelFile is an API that gives the list of the dependencies of an assembly and can list the missing files.

ProductOccurrence load status

You can also rely on A3DAsmProductOccurrenceData::m_eProductLoadStatus
Each part will have a status indicating if it loaded correctly or if there was a problem.

1 Like

Great post! To add on some sample code, all you need to setup to the callback functions for a log file, is to implement a couple of inline functions like below and setting them with a call to “A3DDllSetCallbacksReport(PrintLogMessage, PrintLogWarning, PrintLogError)”. Then you can just update those callback functions to post the resulting message to a specific place whether stdout, stderr, or a log file of some type.

//#################################################
inline A3DInt32 PrintLogMessage(A3DUTF8Char* pMsg)
{
  return fprintf(GetLogFile(), "%s", pMsg ? pMsg : "");
}

//##################################################
inline A3DInt32 PrintLogWarning(A3DUTF8Char* pKod, A3DUTF8Char* pMsg)
{
  return fprintf(GetLogFile(), "WAR %s - %s", pKod ? pKod : "", pMsg ? pMsg : "");
}

//###################################################
inline A3DInt32 PrintLogError(A3DUTF8Char* pKod, A3DUTF8Char* pMsg)
{
    FILE* pLogFile = GetLogFile();
    if (pLogFile == stdout) pLogFile = stderr;
    fprintf(pLogFile, "ERR %s - %s", pKod ? pKod : "", pMsg ? pMsg : "");
    return fflush(pLogFile);
}
2 Likes