From 4e8a6015cb9cfa85a943cf35727ddb7606bef463 Mon Sep 17 00:00:00 2001 From: Connor Ivy Date: Sat, 21 Jan 2023 20:08:14 -0600 Subject: [PATCH] missing with binding to events --- src/components/StreamCard.vue | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/components/StreamCard.vue b/src/components/StreamCard.vue index 9f1ae55..b7ad155 100644 --- a/src/components/StreamCard.vue +++ b/src/components/StreamCard.vue @@ -343,7 +343,7 @@ import streamQuery from '../graphql/stream.gql' import { send, receiveLatest } from '../plugins/excel' import gql from 'graphql-tag' import { createClient } from '../vue-apollo' -import { Viewer } from '@speckle/viewer' +import { Viewer, ViewerEvent } from '@speckle/viewer' let ac = new AbortController() // let viewer = new Viewer() @@ -536,12 +536,45 @@ export default { var v = new Viewer(container) await v.init() + // highlight selected objects + v.on(ViewerEvent.ObjectClicked, async (data) => { + console.log(data?.hits[0]?.object.id) + var speckleId = data?.hits[0]?.object.id + if (speckleId == undefined) v.resetSelection() + else { + v.selectObjects(new Array(data?.hits[0]?.object.id)) + await window.Excel.run(async (context) => { + var sheet = context.workbook.worksheets.getActiveWorksheet() + sheet.onSelectionChanged.add(this.checkModelForSelection) + var range = sheet.getRange() + var found = range.findOrNullObject(speckleId, { + completeMatch: true, // Match the whole cell value. + matchCase: false, // Don't match case. + searchDirection: window.Excel.SearchDirection.forward // Start search at the beginning of the range. + }) + + found.load('address') + // Update the fill color + if (found) { + // var extendedRange = found.get + found.getExtendedRange(window.Excel.KeyboardDirection.right, found).select() + } + await context.sync() + + console.log(found?.address) + }) + } + }) + // v.loadObject( // 'https://latest.speckle.dev/streams/96765a5c41/objects/b5fd92623334e74a1fa2230b065ffe4d' // ) // console.log('loaded') this.viewer = v }, + checkModelForSelection(args) { + console.log('shut up, prettier', args) + }, swapReceiver() { let s = { ...this.savedStream } s.isReceiver = !s.isReceiver