Controlling the autodesk-forge viewer with external buttons - autodesk-forge

Currently I am adding forge to an internal company website where we can view all of the machines we have built or are building. The website works like this: The user selects a machine number and all the information about the machine will pop up. This includes stations within the machine, as well as all the individual parts within each station. My task was to add autodesk-forge to the website. Currently I have successfully used the autodesk-forge viewer so that whenever a machine is picked, the user can press a button, and the model of the entire machine will pop up to be viewed. The next step is to have the viewer be controlled by external buttons on the website. We want it to work as such:
A machine is picked by the user. After this all the information such as stations, and parts within each station in the machine will pop up (this is completed).
The user clicks a "view model" button which will use the forge viewer to make the machine pop up on the website (This has been completed by me).
Once the forge viewer with the model is on the screen, we want the viewer to be able to be controlled by external buttons already on the site.
For example, if there is a machine with name MC-000, and in that machine there is a station named ST010, within that station there are many parts, for example a gear. When the machine MC-000 is being viewed by the user, we want to be able to click an external button which is already made (for example ST010) and the viewer will automatically zoom in and highlight that station within the machine. We also want the same for parts within the machine. When a machine is picked, its stations, as well as the parts within the stations are already printed out within our website. We now want to be able to click the stations, or parts and have the viewer automatically zoom into that part# or station#. I have found a similar code sample here. In this example, parts of the viewer are controlled by buttons not within the viewer. For example, when the 'engine' button is clicked, the viewer will automatically zoom into the engine. The problem with this example, is that all of the positions are hard-coded into the code, meaning that the position of the engine is already within the code. I cannot do this as we have many different machines with thousands of parts, so it would be impossible for me to hard-code them all in. Is something like this possible to do with autodesk-forge viewer. Any help or guidance would be greatly appreciated. Cheers!
EDIT**
Any guidance at all on how I can change where the viewer zooms into would be much appreciated and would help a lot. Currently, I have methods go get both the dbid, and the external objectId from the GET :urn/metadata/:guid http request. Thanks again!

It seems you do have the specified engine dbid and you have a way to link viewer functions with your outside code. The default doubleclick behaviour of the viewer is to select the item the mousepointer collides with. The camera then zooms in (or out) to that item to fit it into the view.
You can use:
select
And
fitToView
To achieve a simular interaction.
For example in Typescript:
// Your dbid is for example 1234
this.viewer.select(1234);
this.viewer.fitToView([1234]);

viewer.select(dbid);
viewer.utilities.fitToView();
Example: https://github.com/Autodesk-Forge/forge-extensions/tree/master/public/extensions/IconMarkupExtension

Related

How to get Chrome context menu not grouping profiles?

How ungroup the "Open as..." context menu entry?
If I am using only 2 Profiles, I'm good
Screen of only 2 profiles
As you can see in the screenshot, I have to do two clicks for opening an url link within the other profile.
Screen of 3 or more profiles
But if I have a third profile, the context menu changes, it creates an expandable item, grouping the other profiles. That is very annoying, because I have to navigate first to the "Open as" line and then after a short delay or an additional click the profile-list appeares where I need to select appropriate profile.
Can we revert the behaviour to list all available profiles within the root context menu?
May we create a keyboard-shortcut for every profile, so pressing the asssigned button while clicking on any links, will open the url in that profile.
Or is there an extension for doing the job? I couldn find any useful information to solve this...
Thanks in advance for any helpful advices :)
(sorry for the spellingmistakes)
Offtopic:
(migrating from ff to chromium. Everyday web-based apps for end-consumers getting more focus, which means in my eyes, programmatically design gets more limited due to the main concept behind our standardized world wide web. And additionally user control gets worse everyday because that's the new key to generate money no longer just for complex & highly specialized products. e.g. timeinvestigation is enormous to through out all the bugs and bullshit extensions to get a reasonably useful tool for accessing the world wide web.)

Chrome extension API and idle

Sorry for cumbersome title, couldn't come up with more descriptive one.
The problem is when opened tab is left without user activity, for example user switched to another screen, Chrome stops rendering changes on that tab. Looks like any background activity is put on hold which is great from perspective of saving power and resources. But if user still needs to see all live updates what is the way to prevent tab to go to 'idle' state despite of having no user activity?
I was looking into chrome.idle API but it doesn't say how to prevent, only how to check.

Game show buzzer screens

I'm doing a training class right now and one of the games I plan on doing is a Jeopardy style of Q & A. The problem I'm trying to figure out is the buzzer. My idea is to use the projector as the question board I control. The trainees would go to an HTML page with nothing more than a single button. They would turn their monitors around to face me up front. As soon as I read the question they would click the button and it would change their screens the color red.
The button and background color change is easy enough, I got that. There are two problems I'm facing: 1) I need it so that they can't click the button until I'm done reading the question - this one isn't as important, I can just make up a rule. 2) Only the fastest person will have a red screen. To show me who clicked first. The others' buttons will be disabled.
I just have no idea how to even Google these two things. Like: "Disable button for other users"...? Or maybe, "only one click"...?
Any direction to search is appreciated. Eventually, I'd like to add other aspects to like the presenter could click an "incorrect button" then it would clear the screen and enable all the buttons again, for the answer steal.
You can do it with modern WebSocket or applications interact via TCP. However, WebSocket may be overkill for the simple application with a few teams. I faced the same problem before and developed a simple solution with PHP using Flock to write into a shared file on disk. Only request from one team gets the chance to write into that file. Stick to not to use WebSocket, the web page on client site does some polling to receive the "restart" signal from the server for the new question/round. It can run in LAN, different team gets different site, i.e. http://[server-ip]/team1, http://[server-ip]/team2.
You can have control over the round: allow them to press button/ restart, start a new question in http://[server-ip]/admin.
Further improvement can be made in several ways to facilitate your needs (i.e. assign team name, register team, use database instead of a flock file). The code is available here : https://github.com/minhhn2910/buzzergameshow

Windows phone back button task preview

On the windows phone when you press and hold the back button a collection of tiles will appear that represent apps that were recently run or are running in the background. Generally the tiles will show a preview of the app in the visual state it was in when it last navigated away from. I have seen some apps however that will show their logo on this tile regardless of the state the app was in when navigated away from. I have been beating my head against the internet trying to find how this is done. Perhaps I am missing the proper terms to search for in order point myself in the correct direction. Does anyone know how to accomplish swapping the back button history preview image or perhaps help me find the correct search terms to locate help on this?

How to create links based on changing text on the screen

I am trying to figure out a way to create links to point to help files in my application based off the text on the screen.
Lets say my application reports the status of a car if it is running or not. If it is running everything is ok, but if it is not running it will display a reason such as:
In Park
Door is open.
Shut off.
Flat tire
When it displays the reason on the main page I want it to have a link pointing to the help file which will include a resolution to get the car back up and running.
The problem I am having is the the reasons change on the fly and update in real time. The resolutions for the problems are all different.
To give some background, the application is asp.net web application. I tried searching the web and I tried linking it to a simple page which had the links to the correct pages but that requires more user involvement. I want it to be click the problem and bring it right to the page.
Any information or suggestions would be great.
Thanks