iTwin / itwinjs-core

Monorepo for iTwin.js Library
https://www.itwinjs.org
MIT License
606 stars 210 forks source link

Using the Presentation API with a Sample iModel #1360

Closed RubberDuckDestroyer closed 3 years ago

RubberDuckDestroyer commented 3 years ago

Hi, I'm trying to use the frontend presentation API with a sample iModel from the website. I want to get the Element ID of an element selected by the user.

Here's a screenshot of the handler I'm trying to use:

Screen Shot 2021-05-10 at 11 45 24 AM

And here is the configuration of the IModelApp.startup. (required before initialising Presentation)

Screen Shot 2021-05-10 at 1 17 30 PM

I'm getting the following error: iModels.connectionError iModels.synchronizerLink

Can someone help me out with this?

pmconne commented 3 years ago

What operating system and browser are you using?

aruniverse commented 3 years ago

Would you be able to post a larger screenshot with the rest of the code in that file? Looks like you're importing and using the Viewer component from itwin-viewer-react. That component will actually call IModelApp.startup as well as Presentation.Initialize so you don't have to, so I'm curious how that CustomIModel.startup is being used.

The error you are seeing might also be a bit misleading. Could you look at your network tab and share what the response for the openForRead call is?

RubberDuckDestroyer commented 3 years ago

Hi, @pmconne OS- macOS BigSur 11.2.3. Browser: Safari & Chrome

@aruniverse That makes sense. I have attached screenshots for the full code for CustomImodel.

Screen Shot 2021-05-13 at 9 42 50 AM Screen Shot 2021-05-13 at 9 43 26 AM Screen Shot 2021-05-13 at 9 43 38 AM

I could not find the openForRead call in the network tab, I've attached a screenshot of what I'm seeing on the network tab as well.

Screen Shot 2021-05-13 at 9 50 08 AM

aruniverse commented 3 years ago

@aruniverse That makes sense. I have attached screenshots for the full code for CustomImodel.

In your componentDidMount you call your startup which tries to do IModelApp.startup and Presentation.initialize which is unneeded, because like mentioned before, the Viewer component will do this for you; you just need to initOidc.

The Viewer component takes optional props for onIModelAppInit and onIModelConnected which you can use to register your Presentation handlers. See docs for more.

I could not find the openForRead call in the network tab, I've attached a screenshot of what I'm seeing on the network tab as well.

Are there any other requests in your network tab failing? Looks like it doesn't even get far enough to open the imodel. If so, take a look at the response and let us know what's failing and why.

aruniverse commented 3 years ago

Been over a month with no update, the steps defined above should resolve the issue. Closing issue for now, if issue persists we can reopen this.