Search code examples
autodesk-forgeautodesk-viewer

Unable to access getFragmentList()


I am trying to access getFragmentList() in a Model object, and I keep getting this error:

TypeError: Cannot read private member #O from an object whose class did not declare it

After experimenting, my best guess on what could be causing this issue is the private #frags properties in model. I'm not sure why the member is called #0 in the error as well?

Does someone have any ideas about this? Is there any way around this? Any help would be appreciated.

I am using the latest version of Autodesk Forge Viewer (v7).


Solution

  • Thanks to the working example provided by @varunpatil, I was able to figure out why I couldn't use getFragmentList(). I am trying to build a Vue 3 component with Autodesk Forge Viewer, and I had the viewer saved as a reactive ref. According to this post, Vue proxies these private fields, which means I could never access methods that use private fields.

    To resolve the issue, I just didn't use a reactive ref and used a simple global variable.