sdaiSaveModelAsXmlBN

This function saves the model as XML according to IFC2x3's way of XML serialization (char file name).

Syntax

//
//   Strong typing definition
//
void            sdaiSaveModelAsXmlBN(
                        SdaiModel               model,
                        SdaiString              fileName
                    );

static  inline  void    sdaiSaveModelAsXmlBN(
                                SdaiModel               model,
                                char                    * fileName
                            )
{
    return  sdaiSaveModelAsXmlBN(
                    model,
                    (SdaiString) fileName
                );
}


//
//   Weak typing definition
//
void    __declspec(dllexport) __stdcall sdaiSaveModelAsXmlBN(
                                                int_t                   model,
                                                const char              * fileName
                                            );

static  inline  void    sdaiSaveModelAsXmlBN(
                                int_t                   model,
                                char                    * fileName
                            )
{
    return  sdaiSaveModelAsXmlBN(
                    model,
                    (const SdaiString) fileName
                );
}
    

Property model

Size: 32 bit / 4 byte (value)
The handle to the model. The model handle is static during its existance. Several models can be opened simultaniously within one session. Different models are always independent, threads are allowed to be running on different models simultaniously.

Property fileName

Size: 32 bit / 4 byte (reference)
The file name of the file as available in the file system in ASCII (char *). The given char array will not be adjusted, on each OS the size of a char element is 8 bit / 1 byte.

Example (based on pure API calls)

Here you can find code snippits that show how the API call sdaiSaveModelAsXmlBN can be used.

#include    "./include/ifcengine.h"
#include    <iostream>

void    OpenModel(
                const char  * fileNameIN,
                const char  * fileNameOUT
            )
{
    //
    //  The advised manner of opening an IFC (or ifcXML) file is by using embedded schema's that can be recognized automatically
    //

    SdaiModel   model = sdaiOpenModelBN(0, fileNameIN, "");

    if (model) {
        SdaiInteger entityCount = engiGetEntityCount(model), instanceCount = 0;

        for (SdaiInteger i = 0; i < entityCount; i++) {
            SdaiEntity  entity = engiGetEntityElement(model, i);

            SdaiAggr    ifcInstances   = sdaiGetEntityExtent(model, entity);
            SdaiInteger noIfcInstances = sdaiGetMemberCount(ifcInstances);
                
            instanceCount += noIfcInstances;
        }

        std::cout << "entity count (schema): " << entityCount << "\n";
        std::cout << "instance count (ifc file): " << instanceCount << "\n";

        //
        //  Independent from the extension the file will be saved as ifcXML
        //
        //  Note: that IFC has two types of XML serialization, i.e. basic XML and simplified XML
        //        basic XML is used for IFC 2x3 TC1 and all versions before
        //        simplified XML is used for IFC 4 and anything later 
        //
        char    * schema = nullptr;
        GetSPFFHeaderItem(model, 9, 0, sdaiSTRING, &schema);

        if (schema[0] == 'I' && schema[1] == 'F' && schema[2] == 'C' && schema[3] == '2') {
            sdaiSaveModelAsXmlBN(model, fileNameOUT);
        }
        else {
            sdaiSaveModelAsSimpleXmlBN(model, fileNameOUT);
        }

        sdaiCloseModel(model);
    }
}