Advanced Customization > Business Logic Customization > Data Exchange using Standards in Windchill > STEP Data Exchange using EXPRESS > Implementing Templates > Function Categories > Initialization
  
Initialization
Target Models
For target data models, which are implicitly opened for write, a simple call to initTemplateAPI is used for initialization. If the ‘with_rdl’ parameter is set to ‘FALSE’ no RDL is needed. This means that the converter is on its own with respect to correctness of the classifications it uses. If the ‘with_rdl’ parameter is set to ‘TRUE’, the templateAPI looks for an RDL with the name <target_model_name>_RDL or an RDL named plcsrdl as the default.
Source Models
Source models are implicitly opened for read. The initTemplateAPI function will generate template extension instances if that has been done already. Therefore, when the source model is a PLCS population, it must temporarily be opened for write during the initialization stage. Afterwards the model should be reopened for read only again, in order to prevent accidental (faulty) updates of the source model.
xpxChangeOpenMode(XPXSOURCEMODELID,xpxRW);

PLCSMODELID := XPXSOURCEMODELID;

initTemplateAPI(TRUE);

xpxChangeOpenMode(XPXSOURCEMODELID,xpxRO);
PLCSMODELID is the identifier of the model addressed by the templateAPI. By default PLCSMODELID is set to XPXTARGETMODELID. In case the source model is a PLCS population, the PLCSMODELID must be switched to XPXSOURCEMODELID during initialization. XPXSOURCEMODELID and XPXTARGETMODELID are EDMxpx built in variables.
Init Function
The init function does not only initialize the templateAPI itself, but also the model (PLCS population) on which the API operates. The representing_part instances are initialized with the following call:
somestuff := get_representing_part(?,?,?,?,?,?,?,?,?);

init_rep_part := TRUE;
This call will return an aggregate of all representing_part instances. The representing_part instances will be generated, if that has not been done before. Instances of other template extension entity types are initialized in a similar way. Since many templates are layered on top of other ones, some get_xxxxx functions may call other ‘get functions’. Due to these dependencies the order of the initialization calls is significant. For the same reason some of the templates have their own private initialization flag in addition to the global one (initialized).