iTwin / imodel-transformer

API for exporting an iModel's parts and also importing them into another iModel
MIT License
3 stars 2 forks source link

Error updating element when it gets remapped #28

Open simsta6 opened 1 year ago

simsta6 commented 1 year ago

Describe the bug error updating elements, missing id drawio

Source iModel changes, after first transformation, includes deleted DisplayStyle3D element and added DisplayStyle3D element with the same properties as the first one.

onExportElement function remaps target DisplayStyle3D element. So now it points to newly added DisplayStyle3D (Id: 2 in source iModel).

When transformer reaches point where it deletes elements it deletes DisplayStyle3D element in target.

Then transformer calls finalizeTransformation and tries to update DisplayStyle3D element in target, because it has pending references (excludedElements in jsonProperties). It fails to update that element because it is deleted in target element

To Reproduce

  1. Create empty iModel. Add DisplayStyle3d element that has excludedElements in jsonProperties.
  2. Run transformation
  3. Delete DisplayStyle3d element and add new DisplayStyle3d element with the same properties as first one (I think same code should be enough) in source iModel
  4. Run transformation to trigger processChanges
  5. Transformer crashes with 'error updating element: missing id'

Expected behavior

Desktop (please complete the applicable information):

OS: Windows @itwin/imodel-transformer 0.1.2 iTwin.js Version 3.6.1