Creating PRC Entities
This section explains how to create the PRC entities that represent the structure of the PRC file, such as the model file, product occurrences, and part definitions. The names of structure module entities have the form A3DAsm***Entity_name** *.
If the model file references multiple product occurrences, create an array to accommodate a pointer that references each product occurrence.
For each product occurrence in the model file, create a pointer that references a populated product occurrence entity. (See Creating PRC Entities). In the following example, createOccurrence is a private function that returns a pointer to a populated product occurrence.
A3DAsmProductOccurrence* p = createOccurrence();
Declare and initialize a model file data structure and set the values of its members, as follows:
m_uiPOccurrencesSize represents the number of child product occurrences.
m_dUnit is a multiple of millimeters that specifies the units used by the 3D data in the structure element.
m_ppPOccurrences references the array of product occurrence pointers.
A3DAsmModelFileData sData; A3D_INITIALIZE_DATA(sData); sData.m_uiPOccurrencesSize = 1; sData.m_dUnit = 1.0; sData.m_ppPOccurrences = &p;
Encapsulate the model file data by invoking the A3DAsmModelFileCreate function. The first argument is a pointer to the model file data, and the second argument is a pointer to the model file entity.
A3DInt32 iRet = A3DAsmModelFileCreate(&sData, &pModelFile);
Optionally, associate the model file entity with root-level attributes (Defining Root-Level Attributes for a PRC Entity).
Declare a null pointer to a product occurrence.
A3DAsmProductOccurrence* pProductOccurrrence = NULL;
Create a pointer to a populated part definition. (See Creating PRC Entities.) In the following example, createPart is a private function that returns a pointer to a populated part definition entity.
A3DAsmPartDefinition* p = createPart();
Set the m_pPart member to reference the part created in Step 2.
A3DAsmProductOccurrenceData sData; A3D_INITIALIZE_DATA(sData); sData.m_pPart = p;
Package the product occurrence data as a PRC entity by invoking the A3DAsmProductOccurrenceCreate function. The first argument is a pointer to the product occurrence data, and the second argument is an indirect pointer to the product occurrence.
A3DInt32 iRet = A3DAsmProductOccurrenceCreate(&sData, &pProductOccurrence);
Define the cascaded attributes for the product occurrence. (See Creating PRC Entities)
Declare a null pointer to a part definition.
A3DAsmPartDefinition* pPartDefinition = NULL;
Declare and initialize a part definition data structure, as shown in the following example.
A3DAsmPartDefinitionData sData; A3D_INITIALIZE_DATA(sData);
For each representation item referenced by this part definition, create a pointer to that representation item and populate it. (See Creating Representation Item PRC Entities) In the following example, createRIBrep is a private function that returns a pointer to a populated B-rep representation item.
A3DRiRepresentationItem* p = createRIBrep();
Set the m_uiRepItemsSize member of the part definition to the number of representation items.
Set the m_ppRepItems member of the part definition to the array of pointers for the representation items. The following example describes a part definition that references a single representation item:
sData.m_uiRepItemsSize = 1; sData.m_ppRepItems = &p;
Package the part definition data as a PRC entity by invoking the A3DAsmPartDefinitionCreate function. The first argument is a pointer to the product occurrence data, and the second is the pointer to the part definition created in Step 1.
A3DInt32 iRet = A3DAsmPartDefinitionCreate(&sData, &pPartDefinition);