Description
Key Learnings
- Discover the basics of Forge
- Learn how to create your first app based on Forge
- Learn how to use OAuth and Data Management
- Learn about Model Derivative and Viewer
Speakers
- Augusto GoncalvesAugusto Goncalves has been an API evangelist at Autodesk, Inc., since 2008. He works with all sorts of technologies, from classic desktop to modern mobile and web platforms, including .NET for AutoCAD software and Revit software, and JavaScript application programming interface for NodeJS.
- Adam NagyAdam Nagy joined Autodesk back in 2005, and he has been providing programming support, consulting, training, and evangelism to external developers. He started his career in Budapest working for a civil engineering CAD software company. He then worked for Autodesk in Prague for 3 years, and he now lives in South England, United Kingdom. Twitter: @AdamTheNagy
AUGUSTO GONCALVES: Using Forge technology to create applications. And this is a sequence of labs. As being a lab, we have a lot of coding to do. We're not going to write a lot of code, but do some coding. And I have very good lab assistants at the back of the room. So if you have any questions during the exercise, just raise your hand. One of the lab assistants or ourselves, we'll go to your desk and help you with your coding. Right?
Yeah. That's it. So as I said, a little bit about myself. I'm not going to read that again. It's a very nice picture of me. And also a very nice picture of Adam. And so the goal of today is to discover the basics of Forge, learn how to create your first Forge application, and learn how to use OAuth and Data Management to access that information. And to use Model Derivative in Viewer to view that model.
So that's actually the title of the class, how to view your models with Forge. And we need a few APIs to use it. So that's why we have these learning objectives for today.
By the end of this class, I want you guys to have something like this sample on the screen. Right? Something that you can go, create a bucket, which is essentially a folder, upload a file to that folder, translate, and view that file. So we are going to have something like this running on your machine by the end of this one hour.
There is also a way to upload this and run this live. Right? Because we are just running on our machine. This final process is about deployment. We're not going to touch this piece today. But you can do it. And I'm going to show you more resources to deploy that later.
Deployment is a way to make it live. And you need a host to deploy your application. And you can do that by the end, or after today. Right? So that's the goal of this class. Cool? It's a very basic sample. And it's very interesting. We've seen several developers using that as a starting point. So it's a very interesting idea.
So if you're very new to Forge, Forge is a platform used by Autodesk, customers, and partners to create applications. We use Forge to create BIM 360. We use Forge to create Fusion and Fusion Team. And we use Forge in the other internal service as well to create different services that we are offering to customers and to you. Right? And so that's the basic idea of collection of web services for integrations, which we call building blocks. Imagine that you have LEGO blocks that you're using all those blocks to create your application. In this case, we're using a few of those blocks to create this sample application.
If you don't have a Forge account yet-- who doesn't have a Forge? So if you don't have an account, go to accounts.autodesk.com to create that Autodesk account. Right? If you already have an Autodesk account, go to the second link, forge.autodesk.com, to create your Forge account. Go.
If you already have your Forge account, go to the forge.autodesk.com/myapps to see all your apps. As of this point, you probably don't have any app yet, because you just created your account. But make sure that you have all the three steps done here.
If you have any questions, raise your hand. We have to be a bit quick here because we just have one hour. So raise your hand if you have any questions. I'm going to give you all those slides later, including the recording of this class. These slides are already there. You don't have to worry about that. And yeah. That's it.
Anyone still missing this step? Raise your hand so I can help you.
All right. So I have a very good class. Everyone is--
ADAM NAGY: Well, I'm not sure. So is everyone finished creating the Forge account?
AUGUSTO GONCALVES: Anyone missing?
ADAM NAGY: You guys in the back as well? Still working on it. All right.
AUGUSTO GONCALVES: It's good?
AUDIENCE: [INAUDIBLE].
AUGUSTO GONCALVES: Yes.
So the Forge account is what we use to create our applications. And everything that you have on Forge is bounded. It's connected to that account. So that's very important to have a very good password for that account.
All right. All right.
ADAM NAGY: We have a new arrival. So [INAUDIBLE] a Forge account? Ah. Can you please go to-- do you already [INAUDIBLE]? OK. So in that case, you can just go to the second link. [INAUDIBLE] is the proper link. You can just log into your Autodesk account. And what's going on here? I'm not sure we have to go into frame. So you can just--
AUGUSTO GONCALVES: So if you've just come in, we are going to need your Autodesk account and Forge account. If you already have an Autodesk account, go to the second step and create your Forge account. And if you already have your Forge account, go to the third step and see all your apps. At this point, you probably don't have any app.
We have a lot of very good lab assistants. If you have any questions, please raise your hand. We can help you.
All right. So moving on. To create your Forge app, so assuming you have now your Autodesk account, and you have your Forge account, you go to your apps, and you can create a new app. Right?
For every app you have to give a name, a description, and a callback URL. Right. For this first class we are not using the callback URL. But on the second class that is happening after this one, we are going to use it. So that's why we need to use the localhost 3000 as shown here.
So that's it. Go. Create your applications. And [INAUDIBLE] the step to create the callback URL, please enter this text that is shown on the screen. I'm going to pause at that specific point so you can copy that.
So give it a name, any name. Give it a description, any description. And then enter that callback URL as shown on the screen. Localhost 3000 app API, Forge callback OAuth.
The next step, select all APIs.
OK. Anyone missing the Forge app? OK. Next step then. So that's the app we created. Let's move next.
OK. So for this lab, we have five steps to complete the code for this lab. We are going to start on the first one. Create a server. The server is the application that actually runs our code.
And to do that on this lab we are going to use node or .NET core. You may ask why not .NET framework? Because .NET framework, Microsoft is not evolving that anymore. So if you are going to start a new .NET application, please use .NET core.
And if you want to use a node, which is JavaScript based, it's also possible. Right? So we have the sample code for both approaches. If you have no idea which one to use, choose either. It doesn't really matter. If you want to do some desktop development later on, maybe .NET may be better, because it's also shared with desktop development. Node is more on a server application. Right? In most cases.
But Forge can be used with any language. So we have samples in Python, PHP, Java, and many other languages. Right? So for this lab, you're going to choose either of those two options.
So on your machine, you have installed Visual Studio Code for Node, or Visual Studio Community 2019 for .NET Core. So please, choose your language, and go to the application listed there.
If you're using .NET Core, Visual Community. If you're using Node, Visual Studio Code. Got it? Found it?
So now we're going to start our first step. We have five minutes to do this. So please, go. All the code for this tutorial is actually live. So go to this address, and click on that square box that you see there, which is create a server.
And then let's follow the steps there to create our code. So learnforge.autodesk.io. Click on that first link. Create a server. And there is a small piece of code there for you to copy and create your server, and some steps to follow to create a server. So go to learnforge.autodesk.io. Select a language, .NET Core or Node, and follow these steps.
ADAM NAGY: Augusto, so [? ESP ?] .NET Core 2.2 should be fine as well, right?
AUGUSTO GONCALVES: [INAUDIBLE].
ADAM NAGY: Because he doesn't have three on the computer. Yeah. Maybe you can just--
So there's another question. If they forgot to uncheck the configure for HTTP in the [? ESP ?] .NET Core creation, is that causing a problem?
AUGUSTO GONCALVES: Just uncheck it later.
ADAM NAGY: Ah. Uncheck it later. OK.
AUGUSTO GONCALVES: OK. If you're still working on this step, please keep following the instructions there. Let me just have your attention for a minute here so we can move to the next step, and then you can keep following. Right? So please, one minute here.
So once you are done with the create a server, the next step is to authenticate. So authentication is actually a way to use your Forge client ID and your Forge client's secret to get a token with Autodesk.
So everything you need to have on Autodesk is encrypted and protected through your account. Only your account can access that information. Right? But as a developer, you may decide to expose that as an application. But only your application is capable of doing that, of exposing that information. So that's why we need to be very careful about what kind of information we want to share. And that's why we have scopes.
The scopes are like for read, for write, or both. Right? So that's why we have different scopes. So on this step, we're going to use your client ID in secret to authenticate with Autodesk, and get a token with a specific scope to access the data. Your application will then use that token to get access to your models.
So to do that we are going to do a very similar thing we did on the other first step. But now we are going to authenticate. So we're seeing, right? Everything is on that website.
So go to the same website, and go to the next step. Authenticate. And again, follow these steps. This one should be way simpler because it's just a piece of code to copy and paste on your application. So if you've done the first one, create a server. Go to the next one. Authenticate. And start doing that.
If you're still having questions on the first one, or questions on this step, please, raise your hand. We can help you. So raise your hand. And then we can help you.
Please pay attention that all the names and all the variables should be the exact match. Right? In most cases, those programming languages are case sensitive, and sensitive to spaces as well. So use the exact same name as used in another tutorial.
So you can keep going on that step. Just so we can keep rolling. After that, please pay attention to this slide for just a minute. And then you can go back to the exercise. Just one minute, look here. Please, everyone, one minute.
So the next step is to upload your file to Forge. Right? So to upload the file, we have to select that file on a computer, of course. And we are going to upload that file to something called Forge OSS, Object Storage Service. That's where we keep your files on Forge.
To do that, we have to create the bucket, which is essentially a folder, and then upload our object, which is the files we have. And for this sample, we are using a very simple approach to upload in a single chunk. Right? We are not using resumable, which is a best practice. But we are not doing that best practice for now, just to keep it simple. Right?
So that's the step we're doing right now. So same tutorial. Just go to upload the file to OSS, and start the same deal. So copy and paste that code into your project.
All right. So just because we are running towards the end, let me have your attention again for a few minutes here. And, of course, everything is online. You can keep running this lab. Right? Don't worry. So the next step will be to translate the file.
Translation is about getting that original file, DWG, RVT, or any CAD file, and translate that to show in the viewer. So that step, we can do it with the Model Derivative API. It's essentially converting that file to a web friendly format that we can view on the browser.
That's the only piece of this entire lab, that's the only piece that actually costs you something to run with Forge. Right? So to translate, RVT and NWD files, you have to pay 1.5 cloud credits. And any other type of file is 0.2 cloud credits. So that's the only piece of the Forge API on this class that will cost you some cloud credits.
Of course, we have a trial here. You just created a Forge account. And you have 100 credits to try the Forge API. So to do that step, it's essentially the same idea. Go to that Learn Forge tutorial. And go to the section on the bottom, and click on the Translate file. That will give you the code to run this piece of the tutorial. OK?
Let me get your attention again for one minute just to explain you what's happening next so you can keep moving on. So our last step of this tutorial is to show on the Viewer. It's very much the same deal, except that we are going to use the Forge Viewer itself to show the application. Right?
And that's the piece of your code that we will run on the browser. To do that, we have to create three files, instead of just one as you did before. So for those three files, create the HTML, JavaScript, and CSS files. And that's the last step here.
Just because we are running a bit out of time, let me just show you how it works in the end so I can leave you a few extra minutes to complete it. Right? So please, just focus here on this screen for a moment. And then you can go back and continue working on your code.
OK. Let me finish this. So just so you are aware, we have five classes like that during the day. We are going to keep reusing this code. And that's just the first one. The next one will be how to use from BIM 360.
And so you know, you can always try the Forge APIs with us. We have several events across the globe where you can use, come, and practice with us. The next one will be in San Francisco happening in January. And it's one week that you can spend time with us working on your application, working on your code. It's not a class, but it's a one week long working together with us. Right?
So please, take a look at the Autodesk Cloud Accelerator for more information on how to submit your idea for this event. I will be there on this one, and a few of my colleagues. And we can work on code just like this.
The only requirement for the accelerator is to have a project. So you need to have an idea to implement during that week. Right?
AUDIENCE: [INAUDIBLE]
AUGUSTO GONCALVES: So you can post questions. Sorry.
AUDIENCE: [INAUDIBLE].
AUGUSTO GONCALVES: Yes. As I said, this presentation is available as part of your AU class. You can download the PowerPoint, these slides. And the code is also live.
We have a lot of samples and information about Forge on our Twitter. So Autodesk Forge, and our GitHub. GitHub.com/Autodesk/Forge.
And you can always ask questions to myself and my team using Stack Overflow. So that's the best way to get help on Forge. And if you have any other questions on this class after here, or any other time, you can always reach myself or Adam, or any other of the lab assistants. We can help you with that as well.
So with that, we have a few more minutes. So you can continue working on our code. I know we are on different paces. So yeah, let's keep on it. We have a few more minutes. And if you have questions, please raise your hand.