Close

Relief for ODA Team in Ukraine

Learn more
ODA PRC SDK
Export a .prc File to an .xml File
This topic describes how to export (or dump) the contents of a .prc file to an .xml file. Exporting to an .xml file allows you to see and analyze the .prc file structure without using any special software such as OdaPrcApp.

The OdPrcToXml sample application contains code that illustrates how to use export to .xml functionality.

Exporting to an .xml file

  1. Create an instance of OdPrcToXmlModule. This module implements dumping a .prc content to an .xml file:
    
              OdPrcToXmlModulePtr pModule = ::odrxDynamicLinker()->loadModule(OdPrcToXmlModuleName, false);
            
  2. Create a stream buffer for writing contents to an .xml file:
    
              OdStreamBufPtr pXmlStream = odrxSystemServices()->createFile(xmlName, (Oda::FileAccessMode)(Oda::kFileWrite), Oda::kShareDenyNo, Oda::kCreateAlways);
            
  3. Create a stream buffer for reading the contents of a .prc file:
    
              OdStreamBufPtr pPrcStream = odrxSystemServices()->createFile(prcName, Oda::kFileRead, Oda::kShareDenyNo, Oda::kOpenExisting);
            
  4. Run the dumping process and check its result:
    
              OdResult res = pModule->prcToXml(pPrcStream, pXmlStream, bAuditMode ? ControlFlags::kWithAudit : ControlFlags::kDefaultMode);
              if (res != eOk)
              {
                throw OdError(res);
              }
            

To provide correct handling of possible errors, the dumping operation can use a try ... catch section:


      try
      {
        OdPrcToXmlModulePtr pModule = ::odrxDynamicLinker()->loadModule(OdPrcToXmlModuleName, false);

        OdStreamBufPtr pXmlStream = odrxSystemServices()->createFile(xmlName, (Oda::FileAccessMode)(Oda::kFileWrite), Oda::kShareDenyNo, Oda::kCreateAlways);
        OdStreamBufPtr pPrcStream = odrxSystemServices()->createFile(prcName, Oda::kFileRead, Oda::kShareDenyNo, Oda::kOpenExisting);

        OdResult res = pModule->prcToXml(pPrcStream, pXmlStream, bAuditMode ? ControlFlags::kWithAudit : ControlFlags::kDefaultMode);
        if (res != eOk)
        {
          throw OdError(res);
        }
      }
      catch(OdError& e)
      {
        odPrintConsoleString(L"\n\nError: %ls", e.description().c_str());
        nRes = -1;
      }
      catch(...)
      {
        odPrintConsoleString(L"\n\nUnexpected error.");
        nRes = -1;
        throw;
      }
    

Export parameters

To specify parameters of export a .prc file to an .xml file, an instance of the ControlFlags class is used. This class stores a set of export parameters and provides methods for getting and setting parameter values.

Note: Currently only the audit parameter for dumping is implemented. Other parameters are ignored during the process.

See Also:

Audit of a .prc File
Export a Drawing to a .prc File
Copyright © 2002 – 2022. Open Design Alliance. All rights reserved.