0

If it were a PC, I could press Ctrl to enter multiple selection mode, but on an iPad, there is no Ctrl, so I don't know how to enter multiple selection mode. It may not be possible.

------------------- 3/29 Added ------------------

I am wondering about this issue...on a PC, if you hold down Ctrl, you can select a rectangular area.

I would like to be able to do this on the iPad as well, so that when the user presses a button for a custom extension, they can press and hold Ctrl as they do on the PC, or tap and hold it for a long time.

------------------- 4/7 Added ------------------

        Autodesk.Viewing.Initializer(options, () => {
            const config3d = {
                extensions: [
                    "Autodesk.DocumentBrowser",
                    "Autodesk.BoxSelection", // I added here too
                ],
            };
            const viewer = new Autodesk.Viewing.GuiViewer3D(
                document.getElementById("forgeViewer"),
                config3d
            );

            // I Added here
            if (Autodesk.Viewing.isMobileDevice()) {
                viewer.addEventListener(
                    Autodesk.Viewing.EXTENSION_LOADED_EVENT,
                    (event) => {
                        if (event.extensionId === "Autodesk.BoxSelection") {
                            let ext = viewer.getExtension(event.extensionId);
                            ext.addToolbarButton(true);
                        }
                    }
                );
            }

            viewer.start();
            this.viewer = viewer;
            const documentId = "urn:" + urn;
            Autodesk.Viewing.Document.load(
                documentId,
                this.onDocumentLoadSuccess.bind(this),
                this.onDocumentLoadFailure.bind(this)
            );
        });
    }

Hiroshi Nishio
  • 222
  • 4
  • 11
  • 1
    Have a look at this answer: https://stackoverflow.com/questions/63921150/autodesk-forge-mobile-app-multiselection-by-user – Adam Nagy Mar 27 '23 at 09:38
  • I am also wondering about this issue...on a PC, if you hold down Ctrl, you can select a rectangular area. I would like to be able to do this on the iPad as well, so that when the user presses a button for a custom extension, they can press and hold Ctrl as they do on the PC, or tap and hold it for a long time. – Hiroshi Nishio Mar 29 '23 at 07:56
  • Regarding Autodesk's viewer API, on a PC, I press Ctrl to enter range selection mode, but I would like to achieve that on an iPad, specifically by holding down the iPad screen for a few seconds to enter that range selection mode. – Hiroshi Nishio Apr 05 '23 at 05:59
  • Anybody can help me out? – Hiroshi Nishio Apr 07 '23 at 01:13

1 Answers1

1

RE: 03/29's question

Mobile devices have no Ctrl button, so we cannot do a similar thing there.

But to activate the box selection on mobile, we could add its button to the viewer toolbar instead. Clicking the button like the snapshot below will do the same thing as you see when holding the Ctrl on PC.

if( Autodesk.Viewing.isMobileDevice() ) {
    viewer.addEventListener(Autodesk.Viewing.EXTENSION_LOADED_EVENT, event => {
        if (event.extensionId === 'Autodesk.BoxSelection') {
            let ext = viewer.getExtension(event.extensionId);
            ext.addToolbarButton(true)
        }
    });
}

enter image description here

BTW, Changing handleSingleTap to support activating the box selection would case some problem. The box selection will always be activated when clicking on either object in the viewer.

Eason Kang
  • 6,155
  • 1
  • 7
  • 24
  • I see! If possible, could you give me some more full source code? I've only made a couple of extensions... – Hiroshi Nishio Apr 07 '23 at 03:28
  • No need to make an extension. We can add the above code snippet to the position above of calling `viewer.start()`. If you're referring to the [old tutorial code](https://github.com/Autodesk-Forge/forge-viewmodels/blob/master/forgeSample/wwwroot/js/ForgeViewer.js#L47). It should be added before line [#47](https://github.com/Autodesk-Forge/forge-viewmodels/blob/master/forgeSample/wwwroot/js/ForgeViewer.js#L47) – Eason Kang Apr 07 '23 at 03:37
  • Woohoo, I was already using other extensions, so I added them to it and successfully got the range selection tool button to appear on the screen only on the iPad! But when I pressed that button, I couldn't select the range... Pasted my latest code for your reference – Hiroshi Nishio Apr 07 '23 at 03:46
  • Oh, it was displayed for a moment, but the button is no longer displayed in the first place. I didn't change anything from the code I posted above... Autodesk.Viewing.EXTENSION_LOADED_EVENT is not triggered. – Hiroshi Nishio Apr 07 '23 at 05:49