AU Class
AU Class
class - AU

Bridging the Gap Between iLogic Automation and Inventor Add-Ins

Share this class

Description

You've seen how iLogic automation can tame tedious and error-prone tasks and make you and your fellow Inventor users more efficient. But have you also run up against the limitations present within the automation tools offered with iLogic? Have you struggled to take things to the next level and create Inventor add-ins? Are you concerned about having to start over? You're not alone. Making the transition from iLogic is a difficult transition for many busy professionals who want to take their automation further but find themselves sticking with what is known, what is familiar, and what is already in place. Join this session and other Inventor automation-focused users like yourself, and you'll discover a path forward that allows you to capitalize on the familiarity of your existing automation, while learning the landscape of the Inventor add-in.

Key Learnings

  • Learn how to create simple add-ins using your existing iLogic rules.
  • Discover the "how to get started” process of Inventor automation add-ins.
  • Learn to create a richer user interface for your automation tools.
  • Better understand the Inventor add-in tools, templates, and techniques.

Speaker

  • Avatar for Curtis Waguespack
    Curtis Waguespack
    Curtis has used Autodesk Inventor and AutoCAD for over two decades to design a wide range of manufactured products. In addition to his design experience, Curtis has authored and co-authored multiple editions of the Mastering Autodesk Inventor book and has taught Inventor to professionals in the classroom. Currently, Curtis works as an Automation Solutions Consultant, where his focus is on automation within Autodesk Inventor and helping others in the Inventor community understand and utilize iLogic and Inventor API automation. Curtis creates Inventor automation tools that help companies become more efficient with their design efforts, and he teaches iLogic classes as well.
Video Player is loading.
Current Time 0:00
Duration 0:00
Loaded: 0%
Stream Type LIVE
Remaining Time 0:00
 
1x
  • Chapters
  • descriptions off, selected
  • captions off, selected
      Transcript

      CURTIS WAGUESPACK: Welcome, everybody. This is Bridging the Gap Between iLogic Automation and Inventor Add-Ins. So let's do some introductions. My name's Curtis Waguespack. I've been a part of the Autodesk Inventor community for a long time, specializing in Inventor and iLogic. I'm going to breeze through this slide here and, just for time's sake, talk about you-- the intended audience.

      So this presentation is aimed at anyone who has a lot of existing iLogic rules in place but has run up against the limitations of iLogic. And maybe you're struggling to take things to the next level, but you don't really want to start over, so that's kind of who I've tailored this towards, really with the new user's point of view in mind. So let's talk about that bridge and why we have trouble getting started with Inventor add-ins sometimes.

      So to start with, the Inventor add-in templates that we get from Autodesk are not great, right? And so sometimes we're trying to bridge this gap, and we're like this guy here, where we're looking at this bridge and the information that's out there and the Getting Started information, and it's not great. So oftentimes, the Getting Started information has some gaps in it. We may find that we just don't even know how to find the Getting Started information-- even if we do, we start using the add-in templates, and they're a little rocky sometimes, and they're really pretty much empty.

      And so they'll get us out to here, and we're standing over this cliff, and we have to build our own bridge to get our first add-in created, and because of that, it causes a lot of people not to get very far. So what we're going to do today is, we're going to start off with some clear and concise Getting Started information, and then we're going to use an improved add-in template to get us all the way over to a completed add-in, and then you can take that very simple little add-in and then start modifying it. But you'll be able to get there very quickly.

      So our goal is to be able to spin up an add-in in just minutes, and I feel very strongly that anyone who can create some iLogic automation and it kind of feels comfortable with going to the next step ought to be able to do this in minutes, and right now, with the templates that Autodesk provides, that's just not possible. So let's get started with this-- let's start talking about some motivations and some challenges first, though.

      So these are some common motivations to do this. We want a better debugging environment, right? The Inventor-- or, I'm sorry, the iLogic debugging environment is not great and it has some limitations. Maybe we want to offer our users a more consistent interface-- a better ribbon interface-- and that kind of thing. So again, that's one of the common motivations. The event triggers, so maybe I want to double-click a parts list and have some code run then. If we're using iLogic automation, we can't really do that right now. It's just not possible.

      And then, of course, this one-- we want to use C#. This is a really common one as well. All of our iLogic stuff is done in VB.NET, and so often, people just really don't want to go there, and so that's a motivation as well. Let's talk about some challenges. So we often feel like we have to start over when we move everything over to add-ins, and so with the template I'm going to show you, I'm going to show you how you can leverage your existing iLogic automation from an add-in and tie it all together without having to start over.

      Falling back on what we've been doing-- that's something that's really common. So we try to create an add-in, we say, oh, this is kind of-- I'm not sure what's going on here-- I'll just spin up a little iLogic rule, and we just stay over there in the iLogic rule. So that's a challenge as well. Again, we're going to use a modified template that makes it almost as easy to spin up an add-in as creating a iLogic rule.

      We don't understand how to get started. So again, we're going to walk through all of the Getting Started stuff from the very beginning with installing Visual Studio, and just make sure we haven't skipped any steps or move past that stuff before you even got started. So can't get the add-ins templates to load-- this, I think, is not a problem anymore. This is something I've run into in the past and I've seen other users run into, but I kind of dug around with Inventor 2024 and Visual Studio 2022 and I couldn't replicate that problem anymore, so I think that's maybe not an issue anymore.

      How do we use the add-in templates? So again, we'll talk about how we use a modified template versus the ones that Autodesk provides. So before we get too much further, let's understand what an add-in is. So an add-in is often called a plug-in-- those two names can be used interchangeably. Add-ins are written and debugged in Visual Studio. So Visual Studio is just a standalone application. If you've not used it before, just something you download, write all your code over there, do all your debugging, that kind of thing, in Visual Studio.

      The add-in is compiled to a DLL file that Inventor picks up when it loads. Add-ins are integrated into Inventor's native interface, so we can create buttons that behave just like a standard Inventor ribbon button to run our custom code. Add-ins are integrated with the Inventor's events, so I kind of mentioned that earlier. Maybe we want to run some code when we edit a parts list, so, again, we can use that event to catch that.

      And then add-ins are typically written in VB.NET or C#. You can use C++ and other languages as well, but those are the two most common ones. So that's a brief overview of what an add-in is. Some add-ins that you might be familiar with are Frame Generator, Cable and Harness, Tube and Pipe. So these are some of the Inventor Professional modules that were originally add-ins. I think Frame Generator wasn't so much a Professional module, but all three of those were add-ins that are kind of bolted on the top of standard Inventor.

      The same is true of our iLogic tools. So iLogic was written as an add-in and initially released as a, I think, subscription bonus pack or something, and then it became part of, just, our standard Inventor tools, but it's an add-in as well. If we go to the Autodesk App Store, we can find add-ins to download, and you may have done that in the past, right? So again, those were all examples of add-ins that you might be familiar with.

      And, of course, we're going to talk about creating a custom add-in. So with our custom add-in, we're going to create a little enterprise tab. So maybe you want to have a tab for your company tools, so rather than having to put the tools on one of these existing tabs, we'll create one for just your company. And you can create buttons and tools and organize them there so that your users know where to go look for those custom tools.

      So we'll create a couple of different kind of buttons, and so one of them will just be on this general tools, and with that, when you click the button, it will run code that exists within the add-in. The other will be some buttons that actually run your existing external iLogic rules. So again, this is how we can leverage the work we've done in the past with our Inventor automation through iLogic.

      So let's jump into topic of, how do we create an add-in? So here's a very high-level overview of how we do this. So we fire up the Visual Studio, we come in here, and we write the code, we debug the code, and then we compile the code. When that happens, a file is written out, and then when we start Inventor, Inventor picks up those files, and then we just use the add-in. So then we just come along and use that add-in as if it's a standard Inventor tool.

      So let's drill down a little further and talk about this process. So we mentioned that we write and we debug our add-ins in Visual Studio-- when we've got it where we want it, we click Build, and it compiles the code and writes out two files. Actually, I think I said a file earlier, but it writes out two files-- a DLL file and an add-in file. And those files land out here in this standard plugins folder, and we'll talk about where that is. But once we open Inventor, Inventor reaches out, grabs those files, and loads those up.

      So that's the kind of general, overall process of how we get from Visual Studio and get our add-in into Inventor. So let's look at this Getting Started information. So we want to look at how we install Visual Studio and how we unpack the tools from the SDK-- the Software Development Kit that comes with Inventor.

      So there's these three steps here that we're going to walk through, and the first would be to install Visual Studio. We'll install the Inventor SDK, and then, of course, we'll go back to Visual Studio, and we'll make sure that our add-in templates are loaded, so let's get started with that. Before we do, let's answer this question-- so do we have to do it in this order? And the answer is actually yes. So we can't install the SDK if Visual Studio isn't available. If you try, you'll get this message, and then you'll have to go install Visual Studio.

      So let's talk about installing Visual Studio. So to do that, we just go out there to the Microsoft site-- this link will be provided in the class download information, but you can just Google it, however you find this link-- but you go out here, you install Visual Studio, you download it, and install it. And then I want to point out there's a lot of really good information out here on the Microsoft site, so if you've never used Visual Studio at all, this is a great place to look and take the tour for the Visual Studio IDE. You can tour the features.

      So anyway, spend a little time on here if this is all brand new to you, but that would be the first step-- install Visual Studio. Now, there are three versions of Visual Studio, and we can narrow that down to two right away because Visual Studio Express is just not appropriate for working with Inventor add-ins, so you can get rid of that one. That leaves us a choice between these two, so we have Visual Studio Professional and Visual Studio Community.

      So these are both full versions-- there's no limited features or anything like that. The big difference is Professional is something you have to purchase, and Community is free. With that purchase, you get full-use license. If you're using the Community version, you have a limited-use license, so that comes down to whether you're available to sell your add-ins and that kind of thing like that. So for more information on that, again, you can just do a Google search, and you'll come up with all the information you need to know which one of these is appropriate for you. If you're just getting started and trying to learn, can pull down Visual Studio Community and get started that way.

      So once we have Visual Studio installed on our machine, then it's time to extract the Inventor SDK. So first, let's ask the question, what is the Inventor SDK? So it's the Software Development Kit, and it installs with Inventor. So the SDK includes some samples and tools that demonstrate and describe the functionality that is available in the Inventor API. So what is an API? Let's take a little detour and do a quick survey of what the API is-- what do we mean by API?

      So using just a standard example, we might have something like a web server. So we have a user interface, an API, and the server, and the API is just kind of the middleman. So when we send a request from our user interface, it goes through the API to communicate with the server, and, of course, when we get a response back, it goes through the API as well.

      So with our Inventor add-ins, it's much the same. So we have our Inventor add-in that we're creating over here with Visual Studio, and we send the request, and we use our Inventor API to communicate with the Inventor application. So we send a request and responses back and forth using the Inventor API. So let's take a look at this API object model and understand the API just a little bit more.

      So this little chart is out there as part of the SDK documentation-- we'll talk about how to find that-- but it's a bunch of kind of drilldown menus, and it looks like a lot, and it is, but all you really need to know to get started here is that it's a bunch of collections and objects in collections. And, as an example, let's take a look at if we were going to want to do something with an extrusion in a part file.

      So our drilldown would be something like this, so we would start with the Inventor application, we'd have a collection of documents, we would have a part document within that collection, we'd have the part component definition-- I'll talk about what this is here in just a bit-- and then within this part component definition, we'd look at a collection of features, and then a collection of extrude features. And then, finally, we could get down here and deal with a single extrude feature.

      So let's use that example with, and compare it to, something that we're familiar with. So here we have an IPT file-- a part file-- and this bracket IPT has all of these features, and this should be something we're all familiar with. So this is everything that makes up the part document, and here's that component definition that I said would explain. So the component definition is just what makes bracket IPT different than any other IPT file, so all the things that are unique and add up to make this specific part file.

      Then we have the part features collection, so all of these features are in this collection, and then we have a collection of just extrude features. And then, finally, we can work with just this one extrusion feature. So maybe programmatically, we want to change the name of this extrusion feature-- this is how we would access this through code. So with that in mind, let's compare this to an iLogic rule. So here's a simple iLogic rule-- there's a one-to-one translation to this object model drilldown, if you want to call it that.

      So here we get the Inventor application. From the application, we get to collection of documents. From the collection of documents, we get one of those documents-- here we're getting just the first visible document. Then we grab the ComponentDefinition from that document, and then we get the collection of features from that component definition. And then, from that collection of features, we get the collection of extrude features, and then, finally, from the collection of extrude features, we grab Extrusion1. So again, then we can do something with that.

      So this is kind of that mapping of all of those things as we would go down and drill through that using that code example, but what if we had a line of code like this? So as we type this out, you can notice we're really just doing the same thing. It's all just kind of a one, single-line representation of this drilldown. And, in fact, we could flatten it out and look at it like this, and you can see, again, we just go down through that hierarchy to get the object that we're looking to work with.

      So that's a quick little detour into what the API is. Let's jump back into this explanation of what our SDK is. So we said that this is a bunch of samples and tools and that kind of thing, so let's have a look at that. First, I'll mention that the SDK installs with Inventor, so you don't have to go download anything else. It's just there, sitting on your machine, if you have Inventor installed. But we do need to unpack it, and once we unpack it, it will include two sets of tools-- these user tools and developer's tools.

      We don't have to worry about the user tools for this conversation, but we want to look at these developer tools. Within the developer tools, there are some documentation. One of them was the object model we were just talking about-- this is a PDF where you can go in here and look at the object model. There are some samples, so we can go into this SDK samples folder and load up one of these samples, maybe this SimpleAddin sample, and it will create a little button on a ribbon, and then we can use that button, and it'll say, hello, world, or something like that.

      And then we can load that code in Visual Studio and see how that was accomplished, and that's true of all of these samples that are provided in this SDK developer tools. There are also some tools to help us with our development of add-ins, and one of those is this Event Watcher. So I use this a lot when I'm working on things, and you just open up Inventor, and then you open up this Event Watcher, and you turn on some of these events. And then when you encounter one of those events, the Event Watcher captures the code that you would need to do something with that event.

      So the example I was using earlier was maybe double-clicking on a parts list, and so I want to catch that event and know what that looks like so I can put that code into my add-in and then have some code run whenever a parts list is edited, for instance. So again, there's some tools out here in this tools folder that we can use to help with our development. But primarily, what we want to talk about here today are these add-in templates, so this is also something that we find when we unzip the SDK folder.

      So let's have a look at these templates. To do that, we would first come in here and we would go to this path, so it'd be this SDK path or this SDK folder in our Inventor folder for whatever version we have, and we would find this developers.msi file, and you simply double-click that, and then it's just a bunch of prompts to click Next, Next, Next, and then finally, Finish, and you install it. So when we do that, what happens is we get all of this stuff here in this green box, and it gets installed right there in that same folder-- the SDK folder.

      So it creates a DeveloperTools subfolder, puts all of this stuff in it, and then also, there are these two templates. So these are our add-in templates-- they're little zip files-- and then these go to a different place. So these go to this Visual Studio Templates ProjectTemplates folder, and so once we've unpacked this developertools.msi file, all that stuff is put in place. So we want to take a look at this Visual Studio ProjectTemplates location and see what's going on, so again, once we run that MSI file, we would see those two files land right out here like this.

      So that was our extraction of the SDK files. And let's look at our last step here, and that will be to ensure that the template files actually show up in Visual Studio. So what we'll do is we'll open up Visual Studio, so you just go to your Visual Studio shortcut button once you have it installed, and then you'll be greeted with something like this. And there's a little link or button down here that says, "Continue without code," so we would click that, and that would open up the Visual Studio console, like is shown here, and then we would just go to Tools and Options.

      So from Tools and Options, then we would see this options dialog, and then we would go to this Projects and Solutions area and expand that, and we'd find this Locations button, I guess you'd call it. So once we click that, we would see what we're looking at right now. So from here, you could change the user project template location, or you can just leave it as is-- I typically leave it as is-- but this is the path that we want to be aware of and we want to have a look at.

      So as a tip, even if you are going to leave the path the same, it's a good idea to click this OK button. So if you've never used Visual Studio before and you've just installed it, when you come in here and you look at this and you click the OK button, what it will do is it'll build out some standard folders-- so it would create all of these folders here. So these are our templates that came from the SDK file. These are these new folders that happen when we click this OK button. So just a good idea to do that so we have those in place.

      So once we have those in place, we can take these Inventor add-in templates and move them to the appropriate file. We don't have to do this, but just kind of good practice. So there's a C# template we can move over to the C# folder and a Visual Basic template that we can move to that one as well. We don't need to unzip these files-- we can just leave them in the zip file and just move them to the appropriate folders.

      So once we've done that, we've checked that they are in the correct path, we can go out here to File, New, and Project, and that will pull up that same dialog we saw when we first opened Visual Studio. This time, what we would do is we would choose the Create a New Project button, and when we click that, we would see a bunch of templates here. And we could just type in Autodesk here, and it would filter for just the Autodesk Inventor templates, or any Autodesk templates we might have, but in most cases, we would just have the Autodesk Inventor templates.

      So for our needs, that would be all we would need to do as far as checking that the templates show up. So we've done these three steps, and we would think that we're ready to create an add-in now, right? Yeah, we're not. The problem is that the templates that come with the SDK are-- there's just not much to them. They're kind of just empty template files, so in order to use them, you kind of got to know what you're doing to begin with.

      So as new users, that's not real helpful. It's kind of like that guy that was trying to cross the bridge-- so he has the template loaded, and that gets him halfway across the bridge, but now he's left to build the rest of his bridge before he can actually get to the other side. So what we're going to do is create our add-in using a custom template, but before we do that, let's do a little review of some of this stuff we just blew through here quickly.

      So our Getting Started steps were these-- so we had these three steps-- this Inventor, Visual Studio install, and then we had this install of the SDK, or the unpacking of that user-- those development tool MSI files, and then we went into Visual Studio and we ensured that the templates were loaded. So that was our basic steps there. We did a quick look at the process of creating an add-in, working with the API and how it communicates with the application, and then we did a little detour and looked at the API and how we work with the API, how it relates to a part file, and how it relates to our code.

      Then we looked at what was in the SDK file, right? I mentioned there was some documentation, some samples, some tools, and, of course, those add-in templates. So that was a quick rundown of all of the stuff we've covered up until now. Let's talk about this improved add-in template. So to access this, you will come out here to the Autodesk University site, where you are watching this video, and you just click the Downloads-- and it might look a little different than this in the future, but it should look close to this-- and you will be able to get this template and some other files to do these next steps.

      So what you'll do, or what you'll see when you do this, is something that looks like this. This file name might change a little bit, but it'll be something similar. It'll say Class Material, have this class number, and probably my last name, and it'll be a zip file. And within there, there's going to be some other files, but specifically, these two files. And we're going to mostly be concerned with this Template Basic for what we're going to do here today, but you would just put these in place.

      So to do that, again, we would come back to our Visual Studio Templates ProjectTemplates folder-- the same one we were talking about earlier-- and you would just bring those from your Downloads folder and drop them into this Visual Basic folder here, and then they would be available. So let's talk about creating an add-in from these improved template files. So this should look familiar. So we would open up Visual Studio, we would click the Create New Project button, and then, again, we can come up here and type in Inventor, and it would filter for these files.

      Now, you should see a couple new templates here, and they'll have the name of this Autodesk University session right here, or that class number. It'll also have a filter here. So I put my name in a filter, so if you have a lot of Inventor add-in templates, you could come in here and just type in my name-- or, actually, you don't have to type it in. It'll just be in a list, and it will filter for just the ones from this class.

      So to get started for this example, what we do is we use this add-in basic template, and we would select it from a list, click Next, and then when we do that, we would come up, we would be presented with this "Configure your new project" dialog here, so we would give it a project name and a path where we want these project files to land. There's this check box here, which I typically check. It just flattens out the folder structure a little bit.

      One thing we want to note is we don't want to use any spaces or dashes here that can cause the add-in not to load into Inventor, so keep this all as one word. You can use underscores-- that works fine-- but here we're going to call it "My_New_Addin" in with some underscores instead of spaces, and then we would just click the Create button. So once we do that, we would see everything loaded into our Solution Explorer.

      So within Visual Studio, we see a pane like this that's called the Solution Explorer. If you don't see it, you'd come up here to the View tab, click Solution Explorer, and this will pop up. Sometimes we accidentally close it by clicking this little X or something like that, but that's how we would get that back. So when we create our new add-in, we would see all of these files loaded over here, or something like this-- look very similar to this-- and then what we can do is, from this Solution Explorer, click on the solution and choose Open File in File Explorer. So when we do that, it allows us to see the files that got created when we created our project from that template.

      So you can see there's a lot of subfolders and a lot of files out here that get created when we create an add-in, and right now, this doesn't mean a lot to us, but we just want to know those are out there. So back in Visual Studio, at this point, we've spun up a new add-in. We haven't done anything with it, but we're going to go ahead and choose Build Solution, and what that will do is that will compile the code and it'll write out a little output window down here like this.

      And in this output window, we should see that it's created a DLL file and a dot addin file, and then we'll see a little message here that tells us that the build succeeded, and that tells us that our add-in was created successfully. If you don't see this output window, note that you can come up here to View and Output and bring that back.

      So again, just as a review, what we've done here is we've come into Visual Studio-- we didn't really write or debug anything because we're just using the template just out-of-the-box sort of thing. We would hit Build-- or we did hit Build-- and then Visual Studio compiled the code and wrote these two files out here. So the next thing we want to do is this step-- we want to open up Inventor and see that the add-in gets loaded.

      So just to know where these files got created, it's at this path here, so it would be C Users. This would be your user profile name, and then it would be down to this path in this ApplicationPlugins, and it will create this folder with your add-in name here, and there will be these two files that are dropped off here, and that's where Inventor will come along and pick those up.

      So let's talk about loading an add-in. So we're going to open Inventor, and when we open Inventor, it's going to look in that folder we were just talking about, and it's going to pick up those add-in files. So it's going to block them initially, and it'll tell you that here, and you can just click this Launch Add-in Manager to go unblock that, or if you accidentally close this or just click the OK button, we can always access the Add-ins Manager by going to the Tools tab and Add-in Manager.

      So once we have the Add-in Manager open, we can find our add-in in the list, and we would just uncheck the block check box here, and then we would click the Loaded and Unloaded and Load Automatically boxes, and that will keep the add-in loaded for every Inventor session. And then next, we want to talk about using the add-in. So working with Inventor, the next thing we would do to test our little add-in here is we'd start a new drawing file.

      So just from a template, spin up a new drawing file, and when we do that, we'll look along the ribbon tabs here and we'll see this ACME Drawing Tools tab, and we'll see a couple little buttons here as well. So out of the box, this is what this custom template does-- it creates some enterprises tabs and a couple of buttons here. So the first one-- just to test that this works-- if we click this API Help button, it just opens up the application programming interface help files as a separate window.

      Typically, when we open these up by going through the Help button here, it ties it to our Inventor session. This little add-in button just brings up as a separate window. I find that helpful. Oftentimes, when I'm developing something, I'm closing Inventor, I'm crashing Inventor sometimes, and I prefer to keep my API Help open separately. So really, though, this is just a little, simple example for how our add-in can create some buttons to do something.

      You can close this window if you like, but, again, that's what this button does. The next button is this Detect Theme button, and you'll notice this is on this External Rules button panel. So what this button does is, when you click it, it tries to run an external rule. Now, at this point, if you're following along, you probably don't have that external rule in place, so let's talk about the steps to do that.

      So what we would do is, we'd go to Tools, come down here to the Options button, we click that Options button-- you'll get a little dropdown like this-- and then we would just click this iLogic Configuration button, and that would bring up this dialog that looks like this. We would just click the plus sign to add a path. Now, if you already have a iLogic external rule directory in here, you can just use it. You don't need to use it to-- you don't need to add another path. But if you don't have one, we would click this button, and then we'd create a path, and then it would be listed right here.

      We're done. We click the OK button. And then what we'd want to do is go over here to the Manage tab, go to the iLogic Browser button, and that will pull up this iLogic browser, which you may or may not be familiar with, and then we would go to the External Rules tab, and there we should see the path that we had in our external rules configuration. From there, we can right-click on this new folder, or this new path, and choose Create New External Rule. So when we do that, it'll pull up a new rule. We can name it, and that gives us a place that we can add some code.

      Now, I'm going to provide this rule, this code here, in our download materials from this Autodesk University class, so you can just open that up and copy that code and paste it into this rule, or you can type this out as you see it on screen if you want to pause the video and do that. But however you get this code in here, that will create this rule called Detect Dark or Light theme. And so what our add-in button will do-- it will look in our external rules directory, and then it will-- if it finds this rule-- run it.

      So with that in mind, here's our rule in place now. We can come over here and click this button, and what this does is, the add-in then just looks over here and runs this rule. So this button actually ran some code that was embedded within the add-in. These external iLogic rule buttons actually just run these rules from our iLogic external rule directory, and really, it's just providing a button up here to do that. So in this case, it's just to tell me if I'm using the dark theme or light theme. I typically use a light theme anytime I'm presenting, so it's telling me that I'm rocking the light theme here.

      Last little bit to check out our add-in and see what it does is to open an assembly file and a part file, and you can see that we have a couple more tabs in those environments that have this ACME Tools tab for both of those individual environments. But you can see that the tools are contextual, so for our Drawing environment we have two buttons, but the way the add-in template was set up is that it only puts one button in these two.

      So that kind of demonstrates how we can show only the assembly tools in the assembly environment. Maybe we want some specific part tools-- maybe there's some tools we want for parts and assemblies, but not for drawings, and so on. So we'll talk about how we do that as we get into modifying this little add-in. So let's take a bit to understand the add-in template structure. So we're going to go back to Visual Studio, and we're going to look at our Solution Explorer, and we're just going to expand these folders and take a look at some of these things.

      So there's four main areas we want to talk about. So starting at the top, we've got these Command Tool modules, so these are buttons. So when we were looking at our add-in in Inventor, we saw an API Help button, and that's what-- here's where the code for that button is, and the same with our Detect Dark, Light Theme button. So these are Command Tools, and when we get into this, you'll see that we have one module for each button. That's just how I set this little custom template up.

      So one module for each command, and then it's broken into two sections. So the first section is a function to define the button. The second one is a sub, and that sub just runs the code. This is what actually does the work of the function, or the button. So next, what we want to look at is if we were to open one of these modules-- so let's say we open this API Help module-- we'll see that this is the whole module, and then this is the function that defines the button. We'll take a little bit of a dive into this and see how things are being done.

      So these first lines here are how we're specifying the icons. So we've got this little orange cat button, or picture, out there that we're using for our icon, and that's where they're specified, right at the top of this function that defines the button for this particular module. Down here is where we specify the name to display, so there's API Help-- you can see it right here-- we've got a VB line feed, is what this is. It just means that we're pushing the word "help" down to the second line. And so that's how we specify the name.

      And then we've got some areas down here for defining the tooltips. So there's a progressive tooltip that does this little flyout thing where we can show images and even videos to help our users understand what the tool does, or we can have this simple line here. So this is how we define our tooltip inside of our Create Button function. And then the last part of this is just where we pass all of this information to a utility module.

      This utility module is called Create Button Definition, and we don't have to dig around in there or do anything with that. We're just letting this module pass information down there to create the button. The second part of this Command module is where we actually do the work, so the code that actually runs when we click the button in Inventor. So, in this example, this was the code that opens up that help file, that dot chm file, and opens as a separate window, so that's just the code that runs when the button's clicked.

      So here's a visual representation of that. So here we have this StandardAddinServer-- we haven't talked about that, but that's kind of the main piece of our add-in-- and then here's our little function-- I'm sorry, our module-- that runs our button. And so we have that top part that defines the button where we have our button name, and our tooltip information, and our icon, and, again, we hand that over to some utility function, and it does all that work for us. And then there's a little picture converter that takes those icons and it does that utility for us.

      And then later in the add-in server, we have a button click event, and that's wired up to run our command code-- that code that actually fires the code that we want when we click the button. So for using this template, though, we really don't have to worry about all that stuff. All we need to do is worry about creating our module, and we're just going to copy and paste to do that, and then we define those things-- the button name, the icons to use, the tooltip information, and then the code to run.

      So we just need to be concerned about these two things in each module, and then in our StandardAddinServer, there's just a couple of things we need to add to wire it up to our module. So we'll refer back to this diagram throughout this-- it'll make a little more sense as we go-- but that's a visual representation of what we're doing through code.

      So let's jump back over to our Solution Explorer, and we're going to look at this Resources area. So this is where our buttons, or our, I should say, pictures that we use for our buttons, are stored, and it's just a folder that gets created in our project called Resources. And again, those are what we use once the buttons are loaded in Inventor. So again, you can see that we were specifying that orange cat icon for a button before, and, again, we're pulling from our resources, our project resources, or our add-in resources.

      To do this, we would just go up to the Project tab, go down here to this properties for this add-in, and then it would pop up this Properties file. And then we would drill down to the resources, we would change this to images, and then when we do that, we'd see this big pane here. And all we have to do is, we go out to somewhere on our computer and we drag these files in, and we drag and drop these files-- maybe these little elephant icons-- and it will just add them to our resources, and that's it. All we have to do then is close this file and save it, and then our resources are added.

      So the next part of our Solution Explorer are these utility tools. These are just tools that our other code uses. We don't have to go in here and modify these-- they're just sitting there, ready to be used. So some examples are the CreateButtonDefinition, the PictureConverter that turns our little images into icons, and then we've even got this utility function to run our external rules. That's how we pull that magic off where our add-in is tied to our external rules.

      And then probably the biggest part of this is this StandardAddinServer. So it's listed down here at the bottom, but this is the primary file that defines the add-in. This is the file that Inventor calls when it loads the add-in, and this is what connects our modules to Inventor. And then, finally, this is the file that handles all of our events, so things like the OnOpen, or the OnSave, or the OnExecute when we click a button-- those type of things. Again, all of this is handled in this AddinServer file down here.

      So that's a quick rundown of what our project looks like in here. I did skip a few things that aren't really important to us as new users. But if we were to open this folder-- remember, we can right-click on the solution up here and choose Open in File Explorer-- if we do that, we can see that-- what we see over here is pretty much a one-to-one, right? So we see this folder here, and out there on our C drive or wherever this is, we would see a Command Tools folder as well-- Resources, Utilities, and so on. And then, of course, here is our StandardAddinServer.

      So to take a high-level view of our template structure, again, we've got our add-in server here, we have these little tool modules that we create here. Again, we have these two parts, the Create button and then the actual code. And then there's just a couple places in our add-in server that we will modify, and this is all just tied to Inventor. So if we want to create a new button, we just copy and paste our module and then we go in and we add a couple more lines or a couple more blocks of code to our add-in server, and we just do this over and over and create as many buttons and tools as we want to.

      So let's talk about doing what we just described, and let's modify this add-in and add a button. So what we'll do is, we'll double-click that StandardAddinServer file, and that will open it up. And when we do that, there's a region in here called Setup Information-- we'll just click that little plus sign here-- plus or minus sign-- and it will expand the region, and we can see the code within there.

      So the first thing we want to point out is, there's an EnvironmentList. If we want this add-in to deal with drawings, assemblies, and part files, we would leave this list as is. Maybe, though, we only want this add-in to look at just model files-- just assembly and part files-- then maybe we could just take out this drawing from the list here. If you're using this template, you can kind of forget about this and just leave it like that and just handle where the buttons show up, but we could also do it here if we wanted to.

      The next thing is, right down here, this is how we change the name of our ribbon tab. So if we want this to say something other than ACME-- maybe we work for a company called Vandelay-- we would want to change that here. And when we change it here and we compiled our add-in and load it to Inventor, these tabs that we were talking about earlier would show up like this. So again, that's the way we would create our enterprise tabs to match our company name, or something like that.

      So the next thing we want to do in our StandardAddinServer is we want to come up to the top and we want to look at where we have this Private WithEvents, and we're going to add a new button. So we're going to add a new line here, and we're just going to copy one of these lines and change the name here, and we'll call it "Toggle_Sheet_Color_Button" with some underscores, and that'll just create a new ButtonDefinition name.

      So using our little map here, we're over here-- we're in our StandardAddinServer file, and then we just do a little copy and paste and change it, and so we're creating this button definition. So the next thing we want to do is-- so we were right up here-- we'll go down a little bit and we'll find this Create Button definitions. Again, click the little plus or minus sign here, and that will expand it so we can see what's going on. And here we'll see that this is where the buttons that we did see when we look at the add-in. This is where they're located. And you notice that we saw this API help button-- we saw that on three different tabs, and that's because we had it listed out here to add it to all three tabs.

      This button down here, this Dark, Light Theme button, it was only added to the drawing tab. That's why we saw it only show up there, so that's how we pull off that magic. But what we want to do is we want to create a new tool, so we want to know that when we have something listed here in this create buttons area, that this part that we're calling right here relates directly to our Command module over here, right? So what this is doing is saying that this button that we defined up here equals, and then it creates this button. And we're just passing in what tab we want it to be on, and so on.

      So again, a direct correlation between this Command Tools module and how we're calling it in the StandardAddinServer. So what we're going to do to create a new button is we'll go over here-- and I've got, just, a little blowup of the Solutions Explorer-- but we're going to take this API_Help.vb, and we'll right-click on it and choose Copy. And then we'll just one level up, so we go to the Command Tools folder, and we right-click, and we choose Paste.

      When we do this, it's going to create a new module called API_Help - Copy, and we'll simply rename that to Toggle_Sheet_Colors. Again, we'll just leave some underscores in there for spaces, and we'll just rename it as such. So where are we, using our little map here? So we're right here. So we copied an existing one, and we created our new module file, so let's jump into that module file.

      So once we have this module renamed, we can just double-click it, it'll open it up over here, and then the first thing we want to do is change his name. So when we copy that file, it left this name in here, and so we'll change that from API_Help to Toggle_Sheet_Color. So the next thing we're going to do is modify this Create Button function, so let's do that. So the Create Button function is the first thing up here, and the first thing we want to do is add the button.

      So again, we go up here to Project and Properties, and you'll just go out there and grab these three images. So these will be available in the download materials with this class, so you can just use them. In real life, you'd use your own custom files. But we would just drag those in and drop them into this white space, this pane here, and then once we've done that, we can simply click this X button here. And when that happens, it'll prompt you to save your resources, and then that will return us back to our Toggle_Sheet_Color module here.

      And so we'll find these lines where we're calling out the icon. Instead of Cat_32 here, we can just backspace over that, and when we get to the resource, we just type the letter E, and then now we'll see those elephant icons show up there. So we can just use Elephant_32 to replace the Cat_32 and Elephant_16 to replace Cat_16, and that will plug in those images to use as our buttons.

      We'll come down a little bit and we'll see that the area where we define the name of the function, so we'll change that from API_Help and we'll change it to Toggle_Sheet_Color. And we'll do the same thing for the simple tooltip, so we'll just put in "Toggle the drawing sheet color" or something like that for our tooltip. Next, we would find this Progressive Tooltip region-- we'd expand it, and you can see this is the area where all of the Progressive Tooltip information is stored, and we would just change that.

      So the first thing we would do is tell it to use this Sheet_Color_Tooltip image file, and then we would just change the tooltip lines to read something like this. So just as a sneak peek of what we're doing when we are changing that expanded tooltip, we're just changing what happens when we hover over our new icon. It will pop up something like this. So here's the image that we told it to use, and then here's the verbiage that we plugged in for that expanded tooltip.

      So we created our button function, now we're going to come down here and create the code that actually runs when the button is clicked. So to do that, we'd come down a little further-- so we were up here in this function-- we're still in this Toggle_Sheet_Color color module-- but we'd come down to the bottom and we'll find this RunCommandCode function. So we'll just get rid of all this code that was in the module that we copied, and we're going to put our own code in there. So you just copy all-- or select all-- that and delete it, and then you can paste all this in or type it in.

      Again, out there in the example materials for this class, you can find this example and paste it right in here. So once we've done that, we've provided the code that will run when the button is clicked. Now, as an alternative workflow, maybe we didn't want the code inside of this add-in-- we wanted to run from an external iLogic rule. We would just change a couple of things here. Instead of pasting in that code, we would change this to run external rule instead of RunCommandCode, and then we would just type in this to use this utility function.

      So we just type in Run_External_iLogic_Rule dot, and then when we type dot, we would see this, and we'd select it. And then we just plug in the name of the external rule that we would want to run. So we're not doing that for this example, but if we were wanting to tie this to an external rule, that's how we'd do it. So when we're done doing all that, we can just click this little X up here. It'll prompt us to save our file, and we would want to do that. So that would save all of our changes to our new Command button module.

      So we did all this, we copied and created this new button module, we modified our CreateButton function with the name and the icons and all that kind of thing, and then we provided the code that runs when the button is clicked. So the next thing we would need to do is wire up the button definition to the CreateButton function, and we'll do this in the StandardAddinServer.

      So back in the StandardAddinServer file-- so if you close it, you would just come over here to the Solution Explorer and double-click that, and then we'd come down a little bit to this region that's called Create Buttons, and there we would just-- we can copy and paste one of the other lines or just type all this out, but we're just going to add a line like this that creates-- that calls-- I should say calls-- this Toggle_Sheet_Color module, so that's what we're doing. We're just wiring this up to use this module over here. We're telling it to be on the drawing-- the GeneralTools of our CustomDrawingTab.

      And we can see that we created this line up here that creates the button name, and that's what we're doing-- we're just saying, take this button name and make it equal to running this code here in this module. So again, if we wanted to use an external iLogic rule, we would make a small change here-- we would just tell this to be on that external iLogic rule panel. So we did that, and the next thing we're going to do is wire up our button clicks.

      So what happens when we click the button? Well, we want it to run this code, so we're going to go into our StandardAddinServer and we're going to add a line. So down towards the bottom is this Button 'on click' Events region, so we would click and expand that, and it would look something like this. So we're just going to add a line. So you can copy and paste one of these, so we could copy and paste this API_Help, or you can type it all in from scratch, but it would look like this.

      So we would just add it to the bottom, and then we would just tell it to run that button name-- so that's our button name from the top-- and then we're telling it to run this module. So this is the module that we created, and then there's that RunCommandCode sub. So this is all we need-- just those three lines-- and that will wire up our button so that we catch this OnExecute button click event.

      Again, alternatively, if we were trying to use an external iLogic rule, we would just use this Run_ExternalRule, so we would change this line here. So this template has these two examples, so you really could just copy these two and change out the names-- or copy one of these two, I should say, and change out the names. A quick overview of this process-- so what we did was we copied all of our modules and wired that all up, and so the next thing we want to do then is click Build, and that will compile the code and write out these files so the Inventor can grab those, so let's do that.

      So we would come over here, right-click on the function-- I mean, on the Solution-- and choose Build Solution. When we do that, again, we get an output window, and it's going to tell us that it wrote these two files out, and it should show us that we succeeded. If we made a mistake in the code or something, this is where it would catch it, and it'll show us exactly where that mistake is-- what line that error happened on.

      Remember, if you lose your output window, you can go in here to View and turn it back on. So let's test the add-in in. So we made some changes here-- we clicked Build and compiled the code-- so we're going to open up Inventor and-- we shouldn't see this. Now, if we're creating a brand new add-in, we'd see this, but since we're modifying an add-in, we shouldn't see this window again. But just in case, remember, we would just go in and unblock the add-in.

      So again, to test it, we come up here, we start a new drawing from the template, and then what we will do is go to our new tab, or, really, we change the name of the tab, so now instead of ACME, we see this say Vandelay up here. So we would activate that tab, and then we'll see our new button show up over here. So if we click that button, all it's really doing is changing the sheet color. So it'll toggle it from this default tan color to white, and if we click it again, it'll toggle it back.

      So just a simple, little example of executing some code with a new button. Doesn't do anything too fancy. You'll come up with all kinds of useful tools and that kind of thing when you're creating your real add-ins, but for our simple example, that's what this does. And then finally, we want to hover over this little icon to make sure that our extended tooltip works. So when we do that, we should see this pop up. It'll use that little picture that we provided, and, again, it'll show all the text that we typed out that's going to help our user understand how to use our add-in, or what this button does.

      So that's it-- we did it. We created our basic add-in by copying, or by using, an improved template, and then really all we did is we copied some modules that were already in there. So it really is just that easy to use this template, right? We started off with some clear and concise Getting Started information, and then we used this template, and we're able to create a new button in just a matter of minutes. So it shouldn't be much more difficult than creating an iLogic rule, and I think you'll be successful with this template in doing that.

      There's going to be some more advanced things you're going to want to do, and some of the handout information that'll come with this class will help explain some of that stuff, but let's do a quick review. So what we did was we created an existing-- or we copied an existing-- command module to create a new one, then we went in there, we changed the name, and then we went in there and changed the information about that button-- so what icons to use, the label name, the tooltip information, and so on.

      And then we went in and we pasted in some code to actually run when the button was clicked. Then we returned to the StandardAddinServer, we went to the top line, and added a line for our button name. We went down to the Create Button regions and we wired up that button to run that module, and then we went down to the Button 'on click' Events and we wired up that event to run that module when it was clicked.

      So really, just three things in the Inventor add-in server, and just about-- maybe just four things to do over here when we copy and pasted the module. So our visual representation of that goes something like this. So we copied and paste our module, and then we came in there and we looked at that Create Button function, and we changed the button name, and the icons, and the tooltips, and then we went down to the bottom and we pasted in that command code. So this is the code, again, that's going to be executed when our button is clicked.

      Then we returned to our StandardAddinServer server, and we wired up that button definition to create the button so when Inventor loads and [INAUDIBLE] want to create that button. So we wired those two things up together, and then finally, we went down to the button click event, and we wired that up to call this Command Code sub so that it would call this and actually execute the code that we pasted in, or that we typed in, or however we created that code.

      So again, if we wanted to create multiple tools, we could just start, and we could copy and paste those. And we just change these two things in the module and just add those blocks of code in the StandardAddinServer server, and it is just that easy to keep adding on these tools into our add-in. Thank you very much. That concludes this video. I think if you use our simplified template here to create some basic add-ins, I would encourage you to spin up some little throwaway add-ins, create some buttons, make it do something. It doesn't really matter. It doesn't have to be real sophisticated.

      If you do this a few times, you'll get this process, and you'll be creating add-ins very quickly and easily, and then you can move on to creating more advanced tools. I think what I've seen from people in industry is, it's just this beginning process that kind of gets in our way of learning to be comfortable with add-ins, and so I hope that we provided something here for you today that you can use to build all the sophisticated and interesting tools that you'll build in the future. And so I wish you lots of luck with that, and, again, thank you for watching.