How-To: Identify missing or part in error 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 parts in an assembly:

Log file

The callback functions of HOOPS Exchange provide a variety of messages, warnings and errors that describe what happens during the import operation. Developers can use those to understand what parts are missing or failed to load in the assembly context.

API to get dependencies list

A3DAsmGetFilesPathFromModelFile returns the list of the dependencies of an assembly and can list the missing files.

ProductOccurrence load status

Developers 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