diff --git a/src/graphics/slope/SlopeAssistant.ts b/src/graphics/slope/SlopeAssistant.ts index 95427f6..98b220e 100644 --- a/src/graphics/slope/SlopeAssistant.ts +++ b/src/graphics/slope/SlopeAssistant.ts @@ -65,11 +65,17 @@ export class SlopeDraw extends GraphicDrawAssistant { const slopes = this.app.queryStore .queryByType(Slope.Type) .filter((g) => { - const refSlopeKiloMarker = this.app.queryStore.queryById( - g.datas.refDeviceId[0] - ) as SlopeKiloMarker; + let refSlopeKiloMarker; + try { + refSlopeKiloMarker = this.app.queryStore.queryById( + g.datas.refDeviceId[0] + ) as SlopeKiloMarker; + } catch (error) { + this.app.deleteGraphics(g); + } + return ( - refSlopeKiloMarker.datas.kilometerSystem[0].direction == dirSlop + refSlopeKiloMarker?.datas.kilometerSystem[0].direction == dirSlop ); }); const slopeKiloMarkers = this.app.queryStore