-1

In my viewer I want to be able to select multiple dbids and save to database, but with control-shift I am able to do selection, but later when retrieving I may be able to show using select([dbid array]), should work fine. But again If I want to select a new dbid, it's pain to use control to select new dbids every time and another thing is my event handler(AGGREGATE_SELECTION_CHANGED_EVENT) I need to write extra code to identify which is the latest dbid I selected and all? Any suggestion on this for an easy solution to manage this?

A DEv
  • 255
  • 1
  • 19

1 Answers1

1

If you'd like to preserver the current selection while selecting extra nodes programmatically try concatenate the current selected dbids with new ones:

const currentSelection = NOP_VIEWER.getSelection()
currentSelection.push(dbid)
NOP_VIEWER.select(currentSelection)

I need to write extra code to identify which is the latest dbid I selected and all?

Yes Viewer does not keep track of the order/timestamps of your selection so you will need to manage this yourself.

control-shift I am able to do selection

You might also want to find out about the click behavior settings to change default behavior of clicks on objects:

const config = {
        "click": {
            "onObject": ["selectOnly"],
            "offObject": ["deselectAll"]
        },
        "clickAlt": {
            "onObject": ["setCOI"],
            "offObject": ["setCOI"]
        },
        "clickCtrl": {
            "onObject": ["selectToggle"]
            // don't deselect if user has control key down https://jira.autodesk.com/browse/LMV-1852
            //"offObject": ["deselectAll"]
        },
        "clickShift": {
            "onObject": ["selectToggle"]
            // don't deselect if user has shift key down https://jira.autodesk.com/browse/LMV-1852
            //"offObject": ["deselectAll"]
        },
}

NOP_VIEWER.setCanvasClickBehavior(config)
Bryan Huang
  • 5,247
  • 2
  • 15
  • 20
  • okay this is great. I liked the idea in this example https://forge-digital-twin.autodesk.io/#, here we are not "select/highlight" the saved dbids rather we give arrows with some label. Also here I observed you cannot do multi select objects as it looks like they have disabled it. Hope its the way you explained above. Is it true? If then how? – A DEv Feb 27 '20 at 09:32
  • "you cannot do multi select objects as it looks like they have disabled it" by user or programmatically? both is possible ... from the user end see the selection window example [here](https://forge-rcdb.autodesk.io/configurator?id=5990d33af8b8e42bc975450e) – Bryan Huang Feb 28 '20 at 05:40
  • @BryanHuang how can we selection dbIds from multiple models programmatically? – shivaramanaiyer Dec 04 '20 at 08:09