Inventor API and iLogic Tips & Tricks | Autodesk Virtual Academy

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
all right all right good morning everyone welcome to Autodesk virtual academy this is your voice in the sky Nigel and byuk here customer success manager and your host for today and just about every other day today I'm joined by Matt bussy how's it going Matt well I'm awake that's half the battle there you go um Matt's one of our senior solution architects on the team meaning that Matt puts together a lot of the project planning for some really large automation projects right whether they be design automation or process automation right Matt that's really a go-to guy to answer a lot of those questions which is coincidentally why Matt decided that we're gonna go ahead and go ahead and show you guys some of these inventor API logic tips and tricks things that I think Matt's learned over the course of his learning experience through a lot of this automation things that might not be you know obvious and things that save a lot of time so I'm really glad Matt you're here I'm gonna learn a lot I'm sure anything else to add besides that Matt no I mean the whole impetus behind this is I'm an engineer so by definition I'm lazy so all this is to support me being lazy sounds good yeah I just find the most efficient way to finish things with awesome I'm sure a lot of us can relate to that if anyone has any questions go ahead and type them into your respective chat panels wherever you are I'll go ahead and monitor those and make sure those get answered and we're in for a really great session Matt take it away all right so let's talk let's do a quick overview of what when I'm house into you all the day so first thing is that we'll look at I'll object and actually we'll look at using the inventor API inside of by logic to enhance the capabilities of biologics so well look at specifically using visual basic.net everything out I do that's a database will be in the Beebe language but it's all translatable into c-sharp as well so look at using vb.net any inventor API inside a biologic to copy design proof your eye logic you use a logic and vault together you know that they don't necessarily play well together so look at ways of helping that problem we'll also look at using it to overcome some limitations so the example I'll show you is how to make a quote/unquote associative user coordinate system in an assembly after that we'll actually go into looking at directly at using the inventor API through Visual Basic button and in Visual Studio and look at some ways if you're going to that level of automation in your in your day to day work how to make your life easier so we'll look at something called extension methods this is something that's been around for not net program for a long time but most people who pick up dotnet programming kind of casually don't really know what they are but we'll look at them and how we can use them to extend the inventor API to make your life easier in terms of using the objects if you get out of the inventor API and then we'll take what we learn there and we'll look at solving some problems that typically come up with drawings we'll also look at a tool that was built by a colleague of mine called attribute helper that can help you put attributes on things in inventor those are very useful in terms of doing automation and in terms of especially automating for drawings we'll look at how to create what we learned in terms of extension methods to find the curves that we want to mention for a drawing and we'll look at reducing de missioning headaches specifically something that tends to come up quite often that most people don't really understand let me first get into trying to write and gives the inventor API to automate drawings and then finally I'll go over some useful references just in sure just in general some general programming references that you might find useful if you're looking to level up your skills okay so first of all let's talk about I like and using the adventure API with my logic now that old copy design problem if you in if you have used I logic with bulks one of the things that you know is that when you do a copy of sign in Vault it can't break your i longitude okay eyelashes freight it's a powerful way to automate your designs but all copies I can break it and why is that well it's because of file names typically there could be other reasons but this is the most this is the most common one so in an example this is an eye logic command parameter this is you typically used like say in an assembly the passive value to a parameter in a child so in this particular case I have a child came sliding door frame I want to pass it over the pass to its parameter name height my own parameter name honey this is a typical way of copying parameters down from one level to the next level in a hierarchical assembly now why does this break well it's because when you come in and do a copy design what happens typically well typically the file name of the child changes but this is if this is hard-coded into your eye logic this name Balt doesn't have that capability of going in and understanding that this is supposed to be a file name one and two knowing what it should change it to and to be honest even if it did have that capability you probably wouldn't want it to do it on any large complex type of eye logic I don't know about any of you but if you ever use things try to automate fixing your code yeah sometimes they work a lot of times they dump so how do we overcome this problem then because we would like to use I logic and use it a lot we also would like to use vault and use it a lot we also like to reuse our designs and reuse them a lot so how do we fix this problem well we use a little inventor API and vb.net instead of our write logic and so let's start off and I will show you that so here's an example of a component that I created this is going to be a library component I'm gonna reuse in my automation or in my designs they gonna be out this is just a simple sliding door okay it's a two-part assembly and the participate up up our this frame that you can see it has a stationary pane of glass has some grooves in there for the sliding board and then the actual panel itself okay now in here I've already got some my logic set up for each of the individual parts and they use some kind of Mickey things so for example if my sliding door is supposed to be on the in chair or the exterior it'll change which side the handle is on you know if I come in here and I change the height that may change the height etcetera so you know specifically typically expect with using parameters and using some high logic the high logic coating here is pretty simple it's saying hey I slide board position is interior then then set that's feet I'm sorry suppresses feature or active or activate that feature etc same thing with the sliding door frame it's also got some parameters select any cleaning parameters and actually spur like the width - paying back the sliding door in the in the closed position so and if I have a closed side that's the side that the non-moving glass is on and change and whether its interior or exterior it might be hard to see there if you notice it's slopping the glass paint back and forth of where it's supposed to be okay so what I want to do is I want to come in on my sliding door and I want to have this be able to update itself with all of that okay so typically what we would do is in this I also have the basically exact same parameters what the exception of one of them that I can pass down okay now typically the way I would pass those down in a logic is do the command like this parameters sliding door frame one I equals five okay so that's the only one I've got setup right now so if I come in here and I change this to 90 right now it's only sending it to the sliding door frame it's not setting it to the other panel that you see how it's passing it down okay now oops now if I went into my I logic and I again Hartford all these things in that would all work until I do with Poppy design so how am I going to fix this how am I going to not have the name the hard-coded name of the file or the occurrence the effector in there well this is where I can come in acting again I can use a little bit of vb.net and a little bit of inventor API so first things first I'm going to do is I need to come in first of all I need to change my constraints so one of the things that I have in here is I have constraints for this sliding panel to change which side is its it is attached to okay so I come in here and I change in you know I go to interior you notice that it's moving things around in terms of it's actually suppressing an unsuppressed and constraints to move the door when I'm okay that's all basic by lumpy none of that is eventer api okay these are all i logic commands pretty much now it's for passing the parameters down that's where i want to get something that's a bit more robust so this is what I can do I can come in and I can write code like this one of the great things about I lodged original I logic you couldn't do this but the current moderate my logic you can actually write really botnet commands in the eye logic code and it will execute them and you can execute them against inventor API so this the this declaration of the myth of dimension and assembly block as an assembly document that's all inventor API okay oh it's simply this doc doc document guess what that comes from I logic same thing in here creating a component definition a psionic component definition again the Oh Assembly doc that's I logic okay so we're coming in here or actually I'm sorry that when they actually is emitter API so then when I want to set the parameters this is what I can do I can create a vb.net for each loop so basically when you have a component definition of an assembly you can get something called occurrences off of it then they're a little bit occurrences basically is collection of all the child occurrences so inside of this assembly and so I can go in and loop so for each loop I can create I can get each occurrence one at a time once I have that component occurrence I can then use the I'll object parameter okay but I could pass it the name from the inventor API object and that name is actually the file name okay this is the human readable name of the component occurrence in fact by doing this and setting this up this way this now passes all those parameters to each component one at a time without having to know that the components name or occurrence name up front okay so I'll save and run this so now that I have that set would I come in here and I again I'm change my hike it's passing everything down ain't my whip massive everything down coming in and doing my interior side notice how swap the blast swap the door it's a latch swap the blast off the bar alright all that is well a good now here's the real test I got a light bulbs well of course you can actually log into my vault I'll go in and log into my vault right and let me go up here and find this in my vault from their assets right now see everything's checked out it's waiting to be checked in so I will come in I will check this in alright I've done that we're gonna check everything in now that everything's checked in what we're gonna do is we're gonna do a copy of something on this okay pop your sign alright we're gonna come in here and we're gonna copy these two folder come in dude I guess the naming here let's do a find and replace we'll know in a quick game on underscore I saw those that's good run this alright come over here to output here's my a-v a demo so I'm gonna go ahead and I'm gonna hit that and check them all out and them down okay so now I come in here I could have opened it from bolts but a little old-school sometimes open up hopefully like this open this up now I'm sure we could all agree the names have all changed okay but why I logic code did not break about that so that's a great way to write robust by logic code now one things I will tell you is that when you write it like this one of the downsides to what I have here is that you have to have the same parameter that you're passing in every single component rights okay now that can be problematic because if you see here for the door I don't actually need close sight it's not used inside of here but I had to create it as just an empty parameter just so that I didn't have any problems now if I didn't want to do that to save myself some time what I could do instead is this I could write something a little more sophisticated than this I have right here I'm just going to comment this out for the moment and then I could write it's a little like I said a little more sophisticated that looks something a little more like this instead of my for each loop so this looks this is a little more complicated but basically what I can come in here and do is come into each occurrence it it's crammed her list and I have to know whether it's a part document or an assembly document in order to get the parameters protecting this is the way that these things work in the inventory API welcome to depth why it works that way but this is it also don't worry about if you want to get this code we will provide a way for you to get this source code at the end and then you come in and you do what's called a try/catch basically what this does in Visual Basic is it's hey try to do this and if you can't then do this if you catch an error okay so in this particular case we know that close side is no longer in my door panel in here okay but if I come in here and I run something let me say just like interior okay notice we don't have a problem reason we don't have a problem is that it just ignores that with a try-catch okay all right so now we have a little bit of an idea of how we might be able to use use inventor api with aia logic to overcome some problems let's look at something let's look at another way of being able to utilize this now one of the things that for us here at kateed when we're doing large sophisticated automation projects it's very common to need a common way of taking piece parts or sub assemblies and inserting them into larger assemblies using a known coordinate system okay it's also very common for us to have customers but when they created their parts that we're trying to reuse that they created it off of an origin that doesn't really work for how we need a position so in this particular case this this door assembly it was cream with the origin point back here okay but the truth the matter is is that that's not the insertion point that we need to use for our automation we actually need an insertion point it's on the opposite side but the problem with that in the case of an assembly is that since since the part itself is origin here whenever it changes sizes this point on this side is always moving back and forth so if I want to use a UCS at the assembly level I can't anchor it there and have it move there okay but what I can do is this I can come in at part level and I can create a UCS here that will live with that that's an associative UCS is actually associated with this vertex right here around the corner so when so when this change is with the way that UCS will move around okay so in here this person might be so everything's all this I haven't fixed this one yet sorry the executive here forgot the copy of basis into everything there we go yes it's up there let me we don't need to see that every time it runs all right there we go so this UCS that you see here that's on the frame this UCS that you see here this is in the assembly so what I can do is this again it's a little bit of a mix of I logic and the inventor API but I'll come in here and I will like this so again I'm getting the assembly document in the component definition and then I'm saying hey I want to find it I want to find the assembly UCS okay and then I need to create sub what's called a matrix use okay missus second oh yeah so what this is gonna do is is this is gonna look at this is called come in here and answer the look for a possible UCS okay inside the assembly where its use their coordinate system okay so basically saying hey it might have more than one UCS in my assembly but this is the one they've been searching use yes that's the one I actually want to move around okay just say that those that commit so I need to rename this to insertion UCS okay so this would come in and it'll find my assembly UCS okay out of all the possible use yeses now this a little bit of code here what's going on is now I I'm gonna go in and look up all my occurrences all my children okay and if they're if any of them in our Park look at sub assemblies children I'm gonna I'm gonna common grab if it's a if it happens me apart then I go look instead of it and say hey do you have any user coordinate systems so if the count is greater than 0 then the answer is yes then again I'm going to look for a UCS a child also name insertion when I find the two then what I'm gonna do is this I'm gonna get the transformation matrix this is the location and rotation okay of the occurrence where I find that where I find this UCS n I'm then going to set up the transformation of my assembly UCS to be the same as the child UCS I'm going to transform it and then apply it to the assembly UCS a lot of work but the end result is this don't blink cuz if you blink you'll miss it now if I come into the frame hi disucss and make it invisible that Uranus yes there that is the assembly yes so now and that changes assembly UCS whoops there we go mr. trigger on there I'll have to go back to double-check that I may have a trigger that's not triggering right now or maybe just an impression yeah I've got trigger about triggers for the holidays it back anyways so Nigel do we have any questions on that in terms of using the inventor API with eye logic to help get you some things done yeah there's a couple here there's one from a good friend here Andy I guess he's referencing when you use the the for each loops won't the for each loop interfere if you add a new part that has the height parameter but is not related to the height of said frame yeah you have to be careful with things like that to make sure that um you've got your your your names well defined and delineated between different things so yes you do have to take that into consideration that's part of what you have to fit basically you've got to plan that out before you start using it one way long story short make sense makes sense right now yeah all right so let's talk about some inventor API specific stuff okay let's see oh we thought I have been make the show I forgot to go back to my presentation so yeah whoa whoops no right way so yeah obviously a use with the UCS we've just talked about that so a bonus tip here if every once awhile we have some hardcore programmers slip in most of our customers tend to be you know mechanical engineers mechanical designers that have picked up programming along the way but every one slot will have customers whether it's the opposite they're hardcore programmers that a little bit of Marylyn life so are you hardcore developers just sue know you can write linked queries in the high logic code for those of you who don't understand what that sentence means don't worry about it you don't Lea I'll explain what they are just so you know for each loops one of the things that when you're doing a lot of development one of the problems with especially large for each loops is that it can be hard to understand what's going on in terms of what's the logic that's being done so kata neck gives you the ability to write something called a link query which is almost like watching a sequel query and basically the reason the developers didn't like it is that they call it self documenting so if you took a quick glance at this for each loop could you tell me what the purpose of it is maybe but with this basically what this is telling the developer is hey from the possible uses that are in this user coordinate system collection where I have one that has a name of insertion UCS then select that and select that and give me the first one of everything you can find that's what a link for you basically does for me so just so if you're hot if you happen to be a hardcore programmer you know link queries yes you can do link Larry's inside of hide logic it will work all right so let's talk about a bitter let's talk about using dotnet and the inventor API or talk about using dotnet utilities to make using the event repeat API easier for you so I actually tend to spend my day writing a whole lot of code directly in c-sharp or B be done yeah I do also write things in logic but we tend to in our larger projects use them with each other and so one of the things that we like to do is try to make repetitive tasks or things that the inventor API doesn't necessarily make easy a little bit easier for us one of the ways we do that is we create things called extension methods now I'm not gonna go into detail but extension methods truly are your interest in that I'll give you some references for some books begin big where you can go digging in this basically an extension method it's a compiler trick basically allows you to add functionality to the stuff you didn't create okay so let me give you an example I'm gonna show you how to add rounding to a number of objects in dotnet to give you a simple idea of what make a fiction method is I'm going to show you how to create that now but we'll come back to actually using it later okay so I'm gonna come in too I've created a simple project here right now I've got some code in here that I'm gonna renate here in a minute but the first thing I'm gonna do is this I have some extension methods I've already created me here but I'm gonna create a new one just to show you from scratch to get that stuff out of licensing so first of all if you're in a dotnet program you've set something up you have to if you're in Visual Basic this is the syntax check to import the system not run time but compiler services this is required to create what's called an extension method so create an extension method you can do is do this you basically start a less than sign and automatic greater than sign here extension all right and then after this you start writing a standard function or subroutine as normal okay I'll call this one round say egg number as double okay and it's gonna return as double so this is this is gonna create a basic function okay and you notice that function I'm passing in one argument it's a tight double all right so what I want to do is I'm gonna Rios pass in a second argument here digits all right now so far this looks like a normal function you would write in any kind of visual basic code and you kind of see sharp cut all right and I don't want to try to remember this office off my head so I'm gonna actually refine this for myself so I'm actually doing it correctly go so basically what I want to do is I want to round this but I want to round it to number significant significant digits and there's several different ways you can do this but this is the basic function called you hit once you would you take a math function in this case let's talk around that's the ceiling I grabbed the wrong one give me a second round there we go now here's the the oven return a number rather than ever sink that begins now you can't say well Matt this is a pretty simple that's a pretty simple line why wouldn't you just write that directly no reason I wouldn't I'm just using this as an example to show you how to create an extension method and what it does for them so now let me go back into my my main module here for a second now I'm gonna dimension a number as a double and I'm going to set it equal to Wanda before I'm just and I give it some very good and I'll do a console.writeline this is a console application which means it'll bring up a Windows command prompt and I'm just right to that number is plus a now if I wanted to get this round it's a five significant digits yes I could just write this line but because I've now added this round function as an extension the extension method extends the object that's the type the first argument what is so what does all that garbage good mean it means acting like this a number is plus a number ba round see this will be back up per second if I came in here and I commented this out and went back here any number you see round and list no you don't an extension method actually adds what you're creating to that objects what's available to reuse as part of the object so one of the real advantages to doing this is that if you have to right kind of complicate things that you're doing over and over again but are you always doing the same type of object you can create those extension method then you never have to remember or what was the name of that how do I get access to it what arguments do I have to pass to it again come to strength so when I run this looks like for paws in there you gotta actually have it stop so you can see it bar closes there you go okay so that's the Lunik station that it is that's what it can do for you alright so now what this has to do with the inventor API well I will show you quite often there can be really tedious tasks that you have to do over and over again and the inventor API that you go oh why can't there just be a shortcut to this and so I'm gonna show you one of those right now one of the more common things that that we have to do is we have to get the filename of an assembly occurrence getting the filename of the of the document that created the assembly occurrence you actually have to go through a lot of Hoops to get to that and having to remember those hoops can be kind of a pain to be honest so what I would love to be able to do is I would love to be able to write code that looks basically like this so if I wanted to get so but let me come into you know looking at this simple assembly there's only two parts in here okay imagine if there were like 50 parts or 100 parts I wanted to get the filename for each one of those and I usually limped through the loop through them and what I would so I love to write is something that basically looks like this the active document and I would love you know if it's an assembly document then I would love to come in and I would like to find his child occurrence and just for that child assurance just get the document bombing this function doesn't exist can't get the document file name directly for the child matter of fact if I come in here is her forgot this is I get I was testing it I forgot behind it let me hide this not there there we go so see that stuff doesn't yes my pocket doesn't exist a matter of fact this stuff right here doesn't exist either so I can write extension methods on inventor only inventor objects and I have a few of them that I've written here so the first one is this is if I want the document name of the file that created this occurrence I can write an extension method that's basically returns a string and what does this extension method do it comes in here and says okay first of all is this occurrence is it a document or an assembly document and if it's one of those documents then give me the definition the document so usually what you have to do is you have to go into the appearance get the component definition if the document the created component definition doing what's called a cast that's what this seat like this you have to cast it into a part document and they get the full bombing but what if it's an assembly document because I don't know if an occurrence is assembly apart when I first get it well then I have to start doing a select so this encapsulates all of it in the case it's not a partner assembly it returns nothing okay so now that I have that as an extension method when I come in here click on the right tab I can do my doc filing okay now I have a couple of other extension methods in here as well and I'm using a two assembly component definition so one of the things that drives me nuts in particular is that when I actually get when I actually get a incurrence for a truck usually it's more like a component definition I usually pick the generic component definition which means I then have to say are you in part and assembly then I have to cast it again then I can get its occurrences so this is to assembly component definition again it takes an unknown about inefficient a generic one and if it happens to be an assembly component definition they don't read it cast it and returns it for me if it doesn't then it returns nothing I can do error checking on that so when this is all said and done I come in here and run this so right now it has this act of inventor session that has this if I get the child document names we can see it returns each one for me if I come back and I change this to a part it says that this is a part file with no children okay but this is the power of the extension methods is that you know basically is we're looking at this this is a bunch of lines of code that have been simplified down so I already only really had to write two lines of them any questions up at this point I saw a couple potential questions pop up they go yeah there's a couple let's see here first one is there a way to change parameters from files inventor file it closed inventor files using like VBA or vb.net this person said they heard it was possible with apprentice not sure what that is so inventor apprentice is a very stripped-down version of inventor that can only grab a subset of the inventor file database and Prentiss I believe you can only change hi properties you cannot change parameters the reason for that is Apprentice was designed for data management type of operations where they were worrying about file references and file properties which is the stuff you do from vault so it does saw if I remember right it does not have direct access to parameters you have to have the full inventor API to get access to the parameters and that's because the parameters can change the recipe ie the dimensions and things like that that create the geometry then update the geometry then update the graphics etc etc inventor apprentice has no access to the recipe segment which is basically the database that creates the browser tree it has no access to the geometry or the graphics segment so I hope that answered the question so you need full-blown adventure in order to do that hole puncher API which means are using the adventure bot application object not an inventor bot for the server object cool see what else we got what if it's connected with Excel to change the parameter so if it's connected with Excel to change the parameters would probably write VB code this manipulating Excel directly rather than the inventor parameter it did I would have to see how things are set up to really guide you me better than that but in general if you've got Excel in the mix and you want to automate the package as a whole you're typically writing to the Excel API and the inventor API and which one you're writing to Wayne kind depends on how things are set up I remember right the inventor API can can't does have access to it I know it has access to read the parameters I can talk my head remember if it has access to write them but in general I would be writing directly to the excel just to keep things simpler and easier but again it kind of it does depend how things are set up what kind of performance you're looking for the other thing is that in general we only do that if we absolutely have to because that's a customer requirement in general and you get a lot more performance if you're dealing with the inventor parameters directly and don't have Excel in the mix when you're talking about like large-scale performance types of automations cool cool I think we can move on alright so one last one last set of things that I would like to show you oh actually this was the this was it so yeah what example I just showed you is getting at the file name and yes sometimes I don't just use file name when I'm talking about it but one of my pet peeves is trying to get the file name and some obscure otic now drawings making your life easier easier you're automating drawings now some of this if you play around with you mentor API you know about but I run into all the time you don't know about attributes they're fundamental part of doing inventor API work on top of the idea behind an afternoon it's basically a tag it gets put on basically anything that can be done inside of an Bedford you use that tag to go back and find it later when you need it now one of the one of the things that causes a lot of people heartburn especially when they're starting out learning the inventor API is how do I get the attribute on the object to begin with because attributes are not exposed to user interface at all they are 100% completely hidden from the day-to-day user they are only meant to be used by programmers using the API so attributes though make Molly objects and finding them for things like mentioning a lot it makes your life a lot easier a matter of fact it's the way you'd want to go for most of setting up for dimensioning automation but getting the attributes on the best thing I can recommend an old colleague of mine from Autodesk Brian Deakins wrote something he called attribute helper it is available on his website you can see Lucius calm slash afternoon helper I will show you that real quick here so equal solutions is after new helper you can download it from here it installs as an inventor add-in now when you first install it inventor when you start up will probably completely that saying it hasn't been built for this version inventor just telling to ignore that to be a necessity that's basically what you do so after you install it you go into the add-ins manager typically nowadays a more modern inventor will beat and plug them up it's blocked so just turn block off tell it to load automatically and if you click on load and unload it'll it'll load it bright thin in there attribute manager is a godsend and what it does is this is when you when you put on after you turn on after you help her first of all it shows you all the attributes that are already inside of this so look at all this stuff that you probably did we even new ones they're all the I logic rules hey they're there and there's attributes okay there's a bunch of parameter values and things like that that are all in there as after buttes okay so let me show you something let me pull up a couple of components I've already got set up they demonstrate using attributes and doing them so right here here I have a windowpane now I went in here ahead of time and I went ahead and I click after buttes in on four different phases okay so basically the top bottom left and right face attributes have three pieces to them there's something called an attribute set name okay then there's the attribute name and the attribute value so if I look at this right here I know it's probably hard to see for the fonts really small there we go that's the back to have to be helper all right so what as I saying you can you can add an attribute to basically any any geometry and Adams parameters you can have properties you can have documents but for dimensioning which is the which is the example I'm going to show you here you typically are adding in two interfaces or edges now I prefer faces the reason being if you try to do this yourself you may say well Matt why not edge is because edges is what's creates the curves and the drawing true but engines also tend to be the most fragile they're the ones long on an update of model geometry can be destroyed and created faster which means that if they get destroyed and credit your attribute goes away so I I tend to acne faces and then go find the edges of that face so in this particular case on this one I got on this window I've got a white base set to lower which would be the lower face a wife a set the upper and I've also got an X Z face because it's a Z Direction lower and z face upper so this allows me to understand you know go grab an upper or lower faces when I'm dimensioning okay I also happen to have the same thing in a wall so they come in here an attribute helper right now I've only got one in here I have my Y origin because I want to use the wall as like local origin for the missioning now all I'm missing is a Z so let me let me add a Z in here so you could show a little bit so you can see a little bit about attribute your afternoon helper and help you what is activated you can come in and select a piece of geometry right click on it and add an attribute set and this particular case they have to be set name that I want to create this always dim set okay that's my name that I'm using to make sure that my attributes from conflict with any other programs once I've created that then I can add an attribute and again I'm going to call this from the origin and I can set its value to Z so basically this is an origin face Z is the Z origin that I want to use for the mission okay all right so that's edit that actuate into this ball big questions on any of that real quick before the lon so show you how to use the attributes a minute but using after view helper that Brian created you don't have to write code to add attributes thing to just try to debug and test them you can use his tool to add your attributes right away okay all right now that we have that now let's go in it let's let's do a little bit of drawing automation here now I already have a drawing setup for this because basically these pieces that you're seeing I am creating to use as part of an automation for a company that basically built clean rooms from piece parts from basically off-the-shelf kind of Lego blocks so in this particular case I have actually started the wall of a room and I put two windows in it I did this mostly for testing so we'll go look at this is something so this part is based at this window is basically constrained to two to two openings now the openings just to just see no there's no magic up my sleeve here in a minute I want you to see this these are set so that basically these are these lines are collinear with each other okay they're all set at the same height okay they'll be important in a minute just keep that in mind that I'm not cheating here these windows are the exact same instance of the exact same part they're constrained directly to the Box to the bottom of those window openings okay now what I want to do is this I basically have two curves here I wanted to admit I want to show you how high the bottom of the window is that's what my first the first day of my automation wants to do and I want to show it off of this line okay like origin now depending on which slide I put the dimension on whether it's a left of the right if I do this manually as a lot of you know if I was gonna put the Domitian live right or less on the left I wouldn't grab the one on the right would I that's really not the dimensioning practice typically typically what you want to do is you want to grab that line and that line that's where you want to have your dimension off of like typical or things like down but the best practice is you really don't the extension line running through something - something next to it if he's truly are at the exact same level which they should be so here's one of the problems that you run into with drawing automation computers are dumb it's basically what it comes down to so let me show you a little bit now there's gonna be a few things I'm going to do in here I'm gonna copy and paste a whole bunch of stuff and then I'm gonna then I'm gonna copy paste a whole bunch of extensions that I pre-written especially given them we're almost out of time basically I've created a whole bunch of extension methods that allow me to do a whole bunch of things for my programming very simply and help me debug by drawing hood give me just a second I'm going to actually wipe this out all right so what am i what if I created so first of all I make it the active document and see this drawing type we need to get the drawing document the sheet and the view that's on there and then I want to find any of the drawing curves that relate to those attributes I showed you so them set origin Y and the Dipset white face lower okay so I wrote the spine curves by attribute that it basically I give it takes the view and I give it the actions I want to do and it does a whole bunch of magic to go in find everything that has that attribute and hand me back the drawing curve don't have time to go through the code now but you will be getting access to it at the end of this now one of the things that so this is great this allows me to come in and find all the drawing curves that have that specific attribute and let me sort through them after I've found them because remember each window is gonna have a white face lower so I got a thick between the two I also want to know what it picked to begin with one of the things I always hate and drawings when I'm debugging him is I don't know what curve I picked this doesn't tell me anything so I wrote a little a little code here I called debate debug fake highlight it uses Scala compiler directives the basic says if I'm in debug mode go in and do this if I'm not in debug mode I change to release here you'll see it Gray's those out it means it won't operate those lines on a release so I can use it for debugging but not for release which helps white which makes my life a lot easier and then the next thing I'm gonna do is I'm gonna check and see as I know we'll find those two lower edges question is are those two lower edges exactly actually the same height anyone want to bet if they are they aren't first of all make sure the back is in there simple ball I'm going to run this dimensions so first of all you see it came in and selected that line look bottom from its attributes those two lines my fake highlight is what highlighted them for me change their color temporarily but she will notice that says curves are not at the same height well why not by coming here I look at this oh I'll do what's called a watch first they're coming to look at this you'll see why yes I've seen we rerun this hold on a second yes I'm gonna actually actually still rerun it I'm gonna stop it do it again now let's look at this this if swing well 698 is the last four digits on there of one curve the other one is six nine two four well we have rounding lovely computer rounding errors so remember when I say we would come back to our little rounding routine why did I bother writing that in the first place is so I could remember to do this when I'm in drawings so one of the things just to keep in mind is that when you're trying to find curves decide which one to use and you're kind of comparing them by their start points or their in points just remember that almost always in drawings because of rounding errors from the burning from the model space to the view to the sheet coordinates you're gonna get rounding errors round up to something that's a few less digits and that way when you do your comparisons are they really at the same height so they're really at the same position they will be at the same height because you're getting rid of the rounding errors by taking them up that does it that's everything I wanted to show you dig also if you want to learn more about some of these more advanced programming things like extension methods and stuff like that I recommend a few books visual basic.net c-sharp 7 for dummies I love for dummies books if you're learning the program first fine for more advanced programming Visual Basic 2015 unleashed or professional c-sharp 7 and got neck or - not oh those are great references as well and yes you can by the way you don't have to worry about writing all these down because if you go to this URL in J bussy team a ba blah blah blah I've already uploaded all the source code that I've shown you today including the Metro models but they're illogic code if you have trouble remembering that URL all you have to do is this just get hub and just do a search a stretch for fatigue a v8 and you'll find it right there you get all the first code that I just showed you inside here you also have all of these petrol files with the I logic in them and the attributes of them yet attribute helper just go to branch comes next morning thanks again Matt for joining us we'll see you here in the office in a couple of weeks and for those of you who aren't you know employees of Qatif we'll see you next week at 10 a.m. for a VA again thanks everybody talk to you soon
Info
Channel: KETIV Technologies
Views: 6,377
Rating: undefined out of 5
Keywords: autodesk, akn_include, autodesk virtual academy, manufacturing, cam, designs, cad, autodesk inventor, inventor ilogic, autodesk ilogic, inventor api, api code, ketiv ava, ketiv academy, ketiv autodesk academy, autodesk academy, ava academy, autocad, Autodesk Software, Manufacturing, CAD, CAM, Engineering
Id: DK2tF5mGyXc
Channel Id: undefined
Length: 55min 30sec (3330 seconds)
Published: Mon Nov 18 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.