The EDMexpressX declaration COPY_MODEL is a concept for converting data between schemata with similar/equal data models. The IFC2X3 and IFC4 are two such schemata. Hence I have used this concept to convert some IFC2X3 models to IFC4 models. The COPY_MODEL concept copies all instances of equal entities in source model to the target model and report all instance types/attributes that must be additionally handled (mapped/converted) after the COPY_MODEL declaration. The STATEMENTS, MAP, FUNCTION and PROCEDURE declarations are available for “programming” conversion that cannot be handled by the COPY_MODEL concept.
The steps to build such a converter can be:
DO UNTIL NO_MORE_ERRORS_IN_COPY_MODEL_REPORT
1. Run a conversion on a source model (IFC2X3 model) with only the COPY_MODEL concept and the option COPY_MODEL_REPORT_ONLY. This conversion will convert one instance of all instance types in the source model to an temporarily target model and produce a report.
SCHEMA_MAP ifc2x3_TO_ifc4; GLOBAL DECLARE src INSTANCE OF SOURCE_SCHEMA ifc2x3; DECLARE trg INSTANCE OF TARGET_SCHEMA ifc4; END_GLOBAL; COPY_MODEL END_COPY_MODEL; END_SCHEMA_MAP;
Remember to specify a logFile and FULL_LOG when running this conversion. Target repository and/or target model can be omitted when the option COPY_MODEL_REPORT_ONLY is activated
2. Based on the report from 1), the mapping schema can be developed with concepts like RENAME_ENITY, RENAME_ENUMERATION,FUNCTION, PROCEDURE, MAP, ..? declarations.
SCHEMA_MAP ifc2x3_TO_ifc4; GLOBAL DECLARE src INSTANCE OF SOURCE_SCHEMA ifc2x3; DECLARE trg INSTANCE OF TARGET_SCHEMA ifc4; END_GLOBAL; COPY_MODEL RENAME_ENUMERATION Ifcelementcompositionenum AS Ifcbuildingelementproxytypeenum; (* enumeration elemets list *) COMPLEX AS COMPLEX; ELEMENT AS ELEMENT; PARTIAL AS PARTIAL; END_RENAME_ENUMERATION; RENAME_ENTITY ifcPerson AS ifcPerson; -- same entity names but uses this declaration for renaming attributes id AS Identification; -- renamed attributes END_RENAME_ENTITY; RENAME_ENTITY IFCORGANIZATION AS IFCORGANIZATION; id AS Identification; END_RENAME_ENTITY; RENAME_ENTITY IFCBUILDINGELEMENTPROXY AS IFCBUILDINGELEMENTPROXY; COMPOSITIONTYPE AS PredefinedType; END_RENAME_ENTITY; RENAME_ENTITY IFCCLASSIFICATIONREFERENCE AS IFCCLASSIFICATIONREFERENCE; ITEMREFERENCE AS identification; END_RENAME_ENTITY; END_COPY_MODEL; STATEMENTS complete_mapping; LOCAL targetInstance : GENERIC; END_LOCAL; ON_ERROR_DO xpxTerminate(0); END_ON_ERROR_DO; (* Complete mapping of all IFCCLASSIFICATION instances *) FROM (classification:src::ifcClassification) WHEN TRUE; BEGIN --xpfGetCopyModelTargetInstance(classification).editionDate := getEditionDateFromCalenderDate(classification.editionDate); -- AET: Why compiler error targetInstance := xpfGetCopyModelTargetInstance(classification); targetInstance.editionDate := getEditionDateFromCalenderDate(classification.editionDate); END; END_STATEMENTS; FUNCTION getEditionDateFromCalenderDate(calenderDate : GENERIC) : STRING; LOCAL editionDate : STRING := '21.02.2017'; END_LOCAL; (* TO be completed *) RETURN(editionDate); END_FUNCTION; END_SCHEMA_MAP;
3. Run the conversion without the option COPY_MODEL_REPORT_ONLY and a resulting target model (IFC4) will be created. During this operation more “errors” may be reported due to some properties in source instances that could not be detected in the option “COPY_MODEL_REPORT_ONLY” run. Hence further development of the mapping schema may be required
SCHEMA_MAP ifc2x3_TO_ifc4; GLOBAL DECLARE src INSTANCE OF SOURCE_SCHEMA ifc2x3; DECLARE trg INSTANCE OF TARGET_SCHEMA ifc4; END_GLOBAL; COPY_MODEL RENAME_ENUMERATION Ifcelementcompositionenum AS Ifcbuildingelementproxytypeenum; COMPLEX AS COMPLEX; ELEMENT AS ELEMENT; PARTIAL AS PARTIAL; END_RENAME_ENUMERATION; RENAME_ENTITY ifcPerson AS ifcPerson; id AS Identification; END_RENAME_ENTITY; RENAME_ENTITY IFCORGANIZATION AS IFCORGANIZATION; id AS Identification; END_RENAME_ENTITY; RENAME_ENTITY IFCBUILDINGELEMENTPROXY AS IFCBUILDINGELEMENTPROXY; COMPOSITIONTYPE AS PredefinedType; END_RENAME_ENTITY; RENAME_ENTITY IFCCLASSIFICATIONREFERENCE AS IFCCLASSIFICATIONREFERENCE; ITEMREFERENCE AS identification; END_RENAME_ENTITY; END_COPY_MODEL; (* STATEMENTS complete_mapping; LOCAL targetInstance : GENERIC; END_LOCAL; (* ON_ERROR_DO xpxTerminate(0); END_ON_ERROR_DO; *) (* Complete mapping of all IFCCLASSIFICATION instances *) FROM (classification:src::ifcClassification) WHEN TRUE; BEGIN --xpfGetCopyModelTargetInstance(classification).editionDate := getEditionDateFromCalenderDate(classification.editionDate); -- AET: Why compiler error targetInstance := xpfGetCopyModelTargetInstance(classification); targetInstance.editionDate := getEditionDateFromCalenderDate(classification.editionDate); END; END_STATEMENTS; FUNCTION getEditionDateFromCalenderDate(calenderDate : GENERIC) : STRING; LOCAL editionDate : STRING := '21.02.2017'; END_LOCAL; (* TO be completed *) RETURN(editionDate); END_FUNCTION; *) END_SCHEMA_MAP;
Run full validation of source model and target model to see if you have error free models or models with “accepted errors”
The COPY_MODE_REPORT_ONLY option was introduced yesterday. A fatal error in the RENAME_ENUMERATION handling was also corrected yesterday. I will most probably check in an updated EDMcore version with these enhancements/corrections today.