Close

Relief for ODA Team in Ukraine

Learn more
ODA PRC SDK
Creation of a .prc File
The topic describes how to create a .prc file and fill it with contents: file structures, global data, tessellation, geometry data, etc.

For creating a new .prc file with one file structure (one product definition and one file structure), use the following steps:

  1. Create an instance of the OdPrcFile class (assuming that svcs is an instance of MyService class described in Create client applications):
    
              OdPrcFilePtr pFile = svcs.createObject();
            
  2. Initialize the model file data section and set common information for the newly created file (minimal version for reading: the authoring version and units):
    
              pFile->setVersions(8137, 8137);
              pFile->modelFileData().unit().setUnitFromCADFile(true);
              pFile->modelFileData().unit().setUnit(1); 
            
  3. Generate a new unique identifier for the .prc file header (containing data section about file structures):
    
              pFile->fileStructureId() = OdPrcUniqueId::generateUID();
            
  4. Get a reference to the file structures array of the created .prc file:
    
              OdPrcFileStructurePtrArray &fileStructures = pFile->fileStructures();
            
  5. Create a new file structure, generate a unique identifier for it, and append it to the file structures array and to the .prc file:
    
              OdPrcFileStructurePtr newStructure = OdPrcFileStructure::createObject();
              newStructure->fileStructureId() = OdPrcUniqueId::generateUID();
              fileStructures.append(newStructure);
              pFile->addFileStructure(*newStructure);
            
  6. Create a global data section for the new file structure and set tessellation data for it:
      
              OdPrcFileStructureGlobals& fileStructureGlobals = newStructure->fileStructureGlobals();
              fileStructureGlobals.setTessellationChordHeightRatio(2000);
              fileStructureGlobals.setTessellationAngleDegree(40);
            
  7. Create a new part definition, add it to the newly created file structure, and push it to the end of the file structure tree:
    
              OdPrcPartDefinitionPtr newDefinition = OdPrcPartDefinition::createObject();
              newStructure->addObject(newDefinition);
              newStructure->fileStructureTree().partDefinition().push_back(newDefinition->objectId());
            
  8. Create a new product occurrence section and make it correspond with the part definition created in the previous step:
    
              OdPrcProductOccurrencePtr newProductOccurrence = OdPrcProductOccurrence::createObject();
              newStructure->addObject(newProductOccurrence);
              newProductOccurrence->referencesOfProductOccurrence().setCorrespondingPartDefinition(newDefinition->objectId());
              newProductOccurrence->productInformation().unitInformation().setUnit(1);
              newStructure->fileStructureTree().productOccurrence().push_back(newProductOccurrence);
            
  9. Make the created product occurrence the file structure root:
      
              newStructure->fileStructureTree().internalData().setRootProductOccurrence(newProductOccurrence->objectId());
            
  10. Add an exact geometry section to the file section:
    
              OdPrcContextAndBodies newContextAndBodies;
              newContextAndBodies.topoContext().setBehaviour(6);
              newContextAndBodies.topoContext().setGranularity(1e-8);
              newContextAndBodies.topoContext().setTolerance(1e-6);
              newStructure->fileStructureGeometry().fileStructureExactGeometry().topologicalContext().push_back(newContextAndBodies);
            
  11. Initialize the file structure header section by setting the minimal version for reading and authoring:
      
              newStructure->setVersions(8137, 8137);
            
  12. Make the product occurrence the start root occurrence for the model file:
    
              pFile->modelFileData().addStartRootOccurrence(*newProductOccurrence);
            

See Also:

Export a Drawing to a .prc File
Work with .prc Files and File Structures
Copyright © 2002 – 2022. Open Design Alliance. All rights reserved.