AU Class
AU Class
class - AU

Programming the Work out of CAD Management

共享此课程
在视频、演示文稿幻灯片和讲义中搜索关键字:

说明

Some CAD managers are challenged with balancing their “real work” (as a billable employee) with their CAD management responsibilities (often considered nonbillable time). This can be a daunting and thankless assignment. Billable work and deadlines consume your workday, so CAD management gets squeezed in between projects, during lunches, or after hours. But it’s possible to use some simple (and a few not-so-simple) AutoLISP tricks to make AutoCAD software do some of the heavier or more tedious CAD management tasks, so you can get back to your work (and your life). Like many tools, AutoLISP can be intimidating, frustrating, dangerous, and powerful all at the same time. But as with any tool, understanding how it works and how to work it makes a huge difference. In this session, we’ll look at some real-world scenarios, a number of examples, and a variety of resources available to use back at your company.

主要学习内容

  • Learn how to use AutoLISP to help with AutoCAD configurations
  • Explore how standards can enable automation via AutoLISP
  • Learn how to use AutoLISP to check, apply, report, and maintain company standards
  • Learn how AutoLISP can also make allowances for project, client, and user variations or preferences while preserving company standards

讲师

  • Chris Lindner 的头像
    Chris Lindner
    Chris is an experienced user and AutoCAD Certified Professional. He has used AutoCAD in a wide range of industries and applications architectural, structural, post-frame, technical illustration, training, programming, etc. Chris is owner & consultant with onebutton cad solutions (www.onebuttoncad.com). He has consulted for notable companies such as Kroger, LBrands, Abbott Labs, and Huntington Bank. He has been a top-rated speaker at events like Autodesk University and Midwest University. Chris was an AutoCAD Mentor, aiding Autodesk users who submitted online help requests, and is currently a member of elite team of experts for providing online support for AutoCAD. He has served multiple terms as a board member for AUGI, the world's largest CAD & BIM User Group. Chris resides in central Ohio with his wife, Sonia, and while "off the clock", he enjoys reading, hiking, camping, gardening, and tinkering on the 1966 International Scout which he's owned since high school.
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
  • subtitles off, selected
      Transcript

      PRESENTER: All right. Well, we'll start a few seconds early, but we'll get it started. So welcome to AU-- hope it's been a good first day for you.

      Well, the nice thing about this class is as soon as we're done, we're heading straight back to the exhibit hall to get your AUGI beer glass, right? A lot of you call those collector's editions.

      Get your beer glass there at the AUGI booth, and just have whatever receptions or parties you're going to. And, hopefully, you can get some good stuff there in the exhibit hall.

      So welcome to Programming the Work out of CAD Management. You know, that four letter work-up there-- I debated on using a couple of other four letter words in that title that I thought might be appropriate, but I wasn't sure they would approve the class if I submitted it that way, so I just went with Programming the Work out of CAD. Now, you can replace that with whatever four letter word you want.

      So my name is Chris Lindner. I'm from Central Ohio, near the Columbus area. That's a picture of me and my first love-- oh, and my wife. Anybody know what kind of vehicle that is?

      AUDIENCE: Yeah.

      PRESENTER: Yeah, oh, my goodness-- that's awesome. I don't know how many people call that a Jeep and a Bronco and-- man, that hurts when you hit somebody, you know that?

      So I actually have had my truck longer than I have-- I don't want to say I've had my wife-- been married to my-- is probably a better way to-- but I've actually-- and had my truck longer than I've used AutoCAD. I've used AutoCAD since 1985, which is really interesting. AutoCAD 2.1-something was when I started.

      I'm on the board of directors for AUGI, the Autodesk User Group International. I'm the CAD manager for an architectural firm in Columbus. And AutoLISP "programmer." I put programmer there in quotes. Originally, it didn't have quotes on it, but as I went through this class, the more I learned, the more dumb I felt, and I was like, I'm not really a programmer.

      And, hopefully, you won't be agreeing with me by the end of the class. But it definitely-- this whole process is definitely proved the quote I heard the other day that said, education is the process of moving from an unawareness to an awareness of how little you know. So and you'll experience that, I'm sure, throughout this week as you learn some stuff.

      Let's talk a little bit about you guys. CAD managers-- who here is a CAD manager? OK, good. So that's probably about 80%.

      Full-time CAD manager-- let me see your hand. Wow, OK. More than I thought. And the rest of you are part-time, spare-time, anytime-I-can-fit-it-in type CAD managers, right?

      Let me ask you this-- who here is not a CAD manager but has a CAD manager in your company? Let me see your hand. You guys are the dangerous ones. You guys are the CAD-- you guys are the people that your CAD managers go, oh, I hope he doesn't take that class.

      [LAUGHTER]

      Right? I apologize to your CAD manager for the things that you're going to learn in this class. And you go back-- oh, I'm going to make his job so hard.

      Industries-- it really doesn't matter. I was going to go through all the different industries, but it really doesn't make that much difference.

      Who hasn't done any AutoLISP programming at all? I'm just curious, and that's OK. All right. So reach down beside your seat-- there's a seatbelt-- just grab that and buckle in because we're going to walk through the basics of this, but, hopefully, you can pick up enough that you can hit the ground running, stumbling, crawling-- whatever when you get back to the--

      I mentioned offices there, simply because I have the benefit-- our company is about 120 people maybe, so it's not huge compared to what some of you guys work with. And we have one office.

      So I work in a fairly small, little bubble compared to what some of you guys do. I talked to a guy earlier today-- he said, the last place I worked, there were 1,700. I said, oh, my goodness. You had 30 offices, it was like, how in the world do you wrestle and wrangle all that stuff in there?

      So how many of you do have multiple offices that you're responsible for? Wow. All right. Well, hopefully, we can help you out a little bit here.

      So a few months ago, I posted this question up on the CAD Managers Unite Facebook page. Anybody see this on that page? A couple people. Anybody comment on that? OK, a few people did.

      So those of you who hadn't seen this-- what's your thoughts? Should programming-- should that skill be something that's part of a CAD manager's job description?

      AUDIENCE: Yes.

      PRESENTER: Any nos? No. A couple nos. I think, if I remember right, there was one no on the Facebook page, and his answer was, no, because it will make my users-- what'd he say-- lazy and dependent or something like that, which I totally understand.

      I've run into people that I've worked with in the past, and they go, man, I really miss that command that you had. It's like, sorry. It's like, I'm not going to not create that function just so that you can learn how to do it the old-school way when I could create something that benefits everybody, but that's just me.

      So the responses seem to fall-- well, let me just-- kind of summarizing-- one, efficiency is critical for what we do. I would imagine most of us-- it's really important. We want to get that stuff done as quick as possible. And if there's any way that we can automate-- in fact, Andrew [? Anagnost, ?] the CEO, talked a lot about automation this morning. In between dozing off, I did catch that part. He talked a lot about automation.

      So if we can find ways to automate what we do to increase the efficiency-- that's a good thing. AutoCAD is generic-- your company's needs are not generic. And automation and programming is a way to tailor AutoCAD to specific needs.

      And it would be a shame to not take advantage of AutoCAD's openness-- it's just begging to be customized and programmed, and that's what we'll get into today.

      The responses seem to fall into these four categories-- configuration, automation, customization, and standardization. And those fairly closely align with our learning objectives because we do talk about the configuration on the first one. We talk about standards. We talk a little bit more about how to preserve standards while accommodating unique needs, and then, well, more standards. So there's definitely some alignment there.

      So let's get into configuration. How many of you downloaded and printed out the handout? A couple of you. I just uploaded a new one--

      [LAUGHTER]

      --sorry. I was working through the PowerPoint last night, obviously, just going through it, and it's like, oh, that's not exactly right. And then I was messing with it a little bit in between the last class that I went to. And this one is like, oh, you know what, I don't like the way that's-- so I updated another one-- apologies if you've already downloaded and printed it, but it won't be too far off.

      Anyway, so let's talk about configuration. Programming the Work out of Configurations-- AutoCAD's answer to that is to use profiles. And profiles worked fine. Profiles, basically, are a way for you to take a snapshot and save all those system AutoCAD configurations. And then if you want to, you can export them and give them to somebody else. They can import them and be put on the network, and they can be imported automatically.

      How many of you actually force profiles to be loaded when you start AutoCAD from the desktop? OK, so a number of you. And that's a great way to create a stable, predictable environment. I mean, it's terrible to walk up to somebody's desk that you need to support, and you go-- what did you-- oh, my goodness, what did you change here?

      But if you know that when they start AutoCAD, they're going to be starting with a consistent environment-- that's a good thing.

      But I have found some things that I don't like. It's hard to call them problems, but I'll just call them issues. One, I say they're fragile. So we had some issues a couple of years ago with our network-- it just wasn't stable, and so people would come into the computer-- logon in the morning, fire up AutoCAD first thing, and there would be network drives that had not reconciled, I guess, is the term.

      And so AutoCAD would start and look for a particular drive, and the drive's not there, and so AutoCAD says, well, guess you'll never need that one again. I'm going to remove it for you. You're welcome.

      And then we fix the network, and somebody goes-- restarts AutoCAD, and it's still not there. And it's like, what happened? Well, and it's just that-- so that was a hassle.

      The other thing about profiles is once you load a profile, it's locally stored. So the only way to kind of get around that would be if you had a profile file out on the network, and so that it would pull that every time. But once that loads, then it's loaded in your system-- your computer's registry.

      Inflexible-- now, I ran into a company the other day that does load their profile when they start AutoCAD. Now, what if the user wants to have a different color background than what you've assigned in the profile? Sorry, the profile is going to give you a black background and a white background or whatever color it might be. And so the user has to go in and change that if they really want that to be a different-- they have to change that every time they start AutoCAD because that profile is being loaded.

      So I really wish Autodesk would come up with a way that you can separate the corporate-- if you want to call-- enterprise settings of the configuration and the personal settings of the configuration-- it'd be really nice.

      And then the last one. The profile, as you know, users will get in there-- hmm, wonder what this does-- click. Tech support-- hey, I got a problem.

      So let's see if we can around some of these issues. So there's a few key files that you're going to use to get started with your customization. Two of them are files. One of them is a file type.

      The first two-- the ACAD.LISP, and the ACADDOC.LISP. I know I'm going to tongue tie that before the day's over.

      So the ACAD.LISP-- when you start AutoCAD, that file loads every time. So it's a great place to just throw some code in there, and you know it's going to be loaded every time.

      You could even path your AutoCAD so that it loads that file from a network somewhere. The ACADDOC.LISP loads every time a drawing is open.

      So you have the ability to fire up AutoCAD and control maybe settings that are session-wide-- color of the background, for example, or whether or not you want your xrefs to come in as an overlay by default-- that would be an AutoCAD-wide, session-wide setting.

      With your ACADDOC.LISP-- you can have it come in and maybe set Object Snap settings that are drawing-based. So you've got those two different options.

      If you want to simplify your life, you could say, you know what-- I don't want both. I'm just going to have one file, and it's going to load every time AutoCAD opens and every time a drawing opens. You could do that by setting a variable in AutoCAD called "ACADLISPASDOC"-- that variable-- if that's set to 1, then you only need the ACADLISP file-- you don't need ACADDOCLISP file. I use both. I don't know if there's a real benefit to having both of them, but I keep them separate.

      The third file here is a file type really. And any time you have a CUI file, that CUI file could have an MNL file, standing for Menu LISP file. The CUI file is sometimes called a "Menu file." And that file-- AutoCAD will automatically load whenever that CUI is loaded. So it could be the type of thing where you have functions in your CUI that you only need available while that CUI is loaded. So you put those functions in the MNL file. So when you load that CUI, those AutoLISP functions automatically get loaded with that CUI file-- just another option there.

      Now, with your ACADLISP and you're ACADDOC, I'm not really sure about the MNL file, but I know the ACAD-- really the ACADDOCLISP-- when LISP loads, it will read every line sequentially typically. As it's loading, it's going to read every line.

      Now, there are some functions that we'll create in a LISP file that we may not want to actually execute until the drawing is fully done opening-- if that's the right grammar-- fully opened.

      So AutoCAD has a function that we can use called "s::startup." And what that does is anything that's within that s::startup startup function doesn't get triggered-- doesn't execute until after that drawing is fully initialized-- that's why they call it "post-initialization execution--" a very, very important sounding function.

      So we will probably use that. Well, we will use that in some of the code that we do here so that we can define a bunch of stuff, but it doesn't have to execute until after the drawing's fully loaded.

      So system variables are a great kind of on-ramp to Programming the Work Out of Configuration.

      A lot of the settings that are in your profiles.youroptions dialog box can be accessed through a system variable. And there is a ton of them-- there's about 900-plus system variables in AutoCAD.

      You can-- there is an express tool called "SISVDLG." I think it's in your handout-- SISVDLG. It's basically like a system variable browser. You get a nice little dialog box-- has all the system variables in it. You scroll down through there. You can search for them. It tells you what the variable is for-- what the original default value is-- whether it's stored in the drawing-- whether it's stored in the registry. A lot of good information there.

      So the functions that we'll use-- in fact, in your Options dialog box, there is-- I got this nifty, little remote from the previous class speaker, I said, hey, can I use that later today? Because it does-- let's see if it does. Ooh. It does stuff like that.

      In your Options dialog box, sometimes it will-- the Tooltip-- if you have Tooltips turned on, it will pop up and show you this value is actually stored in this variable. In the case of the Log file-- that doesn't look like the right Tooltip for that dialog box, does it?

      So Autodesk does a better job of displaying the correct Tooltip. But, anyway, so it will tell you-- and, unfortunately, not every value in the Profiles dialog box is going to give you that option, which is really unfortunate, because it is helpful. It saves you a lot of, OK, how do I control that number?

      When you find out what the variable name is, the functions that you'll use are the "getvar" function or the "setvar" function.

      getvar, and then if you know that variable name, you'll put that variable name in quotes, or the setvar, you're going to put the variable name in quotes, and the value, whatever that value is that you want to assign.

      Let's look at some examples here of some of the ones that we use in our company. In our ACADLSP file, I set the file "dia" variable to 1-- that just assures that no one will hit the Control-0 for open and just see a prompt on the command line. You've had that happen before, right? You hit Control-Open, and you don't get a dialog box, you get a prompt on the command line. And people kind of fall apart when things like that happen.

      So I just make sure that when they start AutoCAD, that's already preset. And worst case, you just restart AutoCAD-- you'll be fine. Take a deep breath-- you'll be all right.

      Inferred constraints are a fun joke to play on somebody. If you don't use constraints, just go into their drawing, and turn on the Conferred Constraint Infer, and just wait for the phone call. It's a lot of fun.

      But we turn that off by default. I don't want that happening. Object Isolation mode-- that just means that if somebody has isolated objects in a drawing and saved it-- when they reopen that drawing, it's going to restore all those objects back-- nice thing to add there. And then we set our default over Xref Type to Overlays.

      And those are all in my ACAD.LISP because those are things that once I set it once, it's going to apply to every drawing that gets opened-- doesn't matter in that session of AutoCAD.

      The ones at the bottom in my ACADDOC.LISP because these are drawing-specific settings. The couple that we do there-- I want to make sure that the current entity color's by layer. I want to make sure the current line type is by layer.

      The last time this drawing was used, if somebody had put a hatch pattern and made it a certain layer-- the hatch pattern layer-- I'm just going to default that back to Current so that it's not putting it on a layer that I'm not aware of. Alternatively, if I know that I want all my hatching to go in on a certain layer, I could put that layer in there as well.

      And then, we do architectural stuff, so I set the architectural units, and I also set the precision and all this kind of stuff as well. Yes, sir.

      AUDIENCE: Setup for the xref type 1 drawing.

      PRESENTER: So xref type 1-- so Overlay and Overlaid xref versus an attached xref. Here's the way I differentiate an attached Overlay-- I'm sorry-- and attached xref is always going to be attached to whatever it's linked to. An Overlaid xref is only going to be visible while I'm in the drawing that it's directly connected to.

      Do some exploration on your own. As far as benefit-- there are sometimes xrefs that are deep down in a tree if you will, that don't pertain to the drawing that I'm in. They may have pertained when I was over here working in this drawing, but when I'm in this drawing, and I'm working-- I'm using this reference-- I don't need that other one.

      Now, in addition to system variables, we'll soon run into things that we can't control with a system variable. And we have to use what's called an "environment variable."

      Now, this environment variable, to me, I think it's kind of a misnomer because I think, originally, it was just for things that were operating system environment stuff, but it's really beyond that. In fact, I talked to one of the Autodesk programmers about this, and he goes, yeah, it's not really what it used to mean anymore-- it's a little more comprehensive than that.

      Again, a lot of the settings-- in fact, and I'll show you in a second. There are things that you can change via an environment variable that you can also change with a system variable. It's not going to matter one way or the other which one you do, but you may want to at least be aware of that.

      Similar process-- "getenv" or "setenv" for those functions. Now, environment variables typically apply to the AutoCAD session-- not to a draw-- in fact, I don't know of a single environment variable that is drawing-specific. You're welcome to correct me if not, but I'm pretty sure all your environment variables are AutoCAD program related.

      As a result of that, all my system-- well, I'm pretty sure, all my environment variables are placed in my ACADLISP, not my ACADDOC. Because if I put them in my ACADDOC, it's redundant. Every time I open up the drawing, it's going to do this when it doesn't need to.

      Anyway, here's a few that are in ours. We hide our system printers in AutoCAD. When I go, and I select my whatever local printer, and I look for paper sizes, I really don't care that there's a monarch envelope size or a Japanese J10-- I don't care. I'm not printing to that size anyway. So why give my users 30 different paper sizes to pick from? I'm going to create a PC3 file that has three paper sizes, or two 8 12 by 11-- 11 by 17-- that's it.

      So when they go into Plot, and they pick that printer, they're only getting two paper sizes. If they're using system printers, they're going to see every one of those paper sizes that that printer supports. That's just me, but I'm trying to streamline that and minimize things.

      We work with some clients who are not on the latest version of AutoCAD, so we have to make sure that all our drawings automatically save in 2013 file format. I have no idea what 60 has to do with that, but that's the number. You just roll with it.

      Show Tabs-- that's just a-- it could be a personal preference thing, but we make sure that all the Layout tabs on the bottom of the model and the Layout tabs are all always shown.

      So, again, you start AutoCAD-- how nice would this be, hey, I got a problem. Just restart AutoCAD, you'll be fine. Wouldn't that be a great response to every support call you ever got? Just restart it. I got it covered. Yes, sir.

      AUDIENCE: Is there a list of the floor plans that you save or a variable?

      PRESENTER: There are. You can google that that variable name-- Default Format Save. Yeah, I couldn't rattle them off of the top of my head, but they're out there.

      JTB World is a website that's a great resource for file format, variables, things like that. It'll probably show up when you do a Google search for that variable name-- it'll probably show up.

      So, anyway, those are some environment variables that we put in. Now, there's a few things that are unique about environment variables that make them different from system variables-- just kind of FYI for you to know. One is the variable name itself is case sensitive.

      So in the previous example, if I had spelled HIDE SYSTEM PRINTERS with all lowercase letters, that wouldn't have worked.

      So make sure that your system variables are spelled-- environment variables are spelled correctly with the proper case.

      The value that you pass to an environment variable can only be a string. Let me go back to here. Notice that that on the top option, while all of these, there's a mix. The top four are all integers-- they're all numbers. The three of them on the bottom are strings, and then the one is an integer.

      But environment variables are always-- that value that you're assigning is always a string. And so what you'll have to do is learn how to convert strings to the appropriate-- you'll have to-- if you want to assign that whatever-- if you're needing to take that value and convert it to a number or convert it to a real number or an integer or something else, you're going to have to learn how to convert strings to something else.

      There's a bunch of functions. There's a-- what is it-- A2i alphanumeric-- 2 integer is one. A2i will take an alphanumeric, which is a string-- alphanumeric value and convert it to an integer. And there's some other functions like that as well.

      You can't type an environment variable on the command line. You can do that with a system variable. So if I took the system variable CECOLOR-- if I want to make that-- in AutoCAD, I can type in CECOLOR, and it'll come up and say, what's that? What value do you want? What color do you want? I can't do that with an environment variable. I can't type those in.

      Typically, we place an ACADLISP, which you already said, and stored in the-- all those values are stored in the Registry. They can actually be accessed from the Registry as well, which we're not going to get into. But that would be something for you to explore on your own.

      Oh, yes, so these variables are stored in different places. You know what I'm missing here is-- yeah, when you're looking at that sysvdlg-- that System Variable Dialog box that I talked about-- when it shows you whether it's saved in the Drawing or the Registry or whatever-- that's basically what that means and how that corresponds to where that should go in your ACAD.LISP or you're ACADDOC.LISP.

      And, again, you can simplify your life to a certain degree just by saying-- just use the ACADLISP and be done with it, and don't worry about whether it's DOC or not-- that's completely up to you.

      This is kind of interesting. So some of your values can be assigned by either a system variable or an environment variable. Unfortunately, the variable name that's used may not be the same.

      The first one is a system variable. We're using the setvar function. Where's my nifty little pointer here? Oh, I didn't want to do that. Let's try-- yeah, so setvar, and the variable name is "Xloadpath."

      But when it's an environment variable, "setenv," it's Xrefloadpath-- go figure. So you got to keep that in check as well.

      Some of these variables are read-only. Some of your system variables are read-only, but if you use it as an environment variable, you can assign it. You can't assign it as a system variable, but that same value-- even though the variable name is different-- that same value can be assigned using an environment variable instead of a system variable.

      You like all these variables? No, I hate variables. I hate exceptions. My users will go, OK, let me get it straight. Does it always do that? Yeah, well, OK, all right.

      Oh, which type do you use? So that's a great question there. Which one do I use? Do I use a system variable, or do you use an environment variable? And I really don't know a good answer to tell you other than you're going to have to do some research.

      Generally, when I go looking for a value that I want to change in AutoCAD-- if I'm in the Options dialog box, I'll take whatever that value is referred to-- how it's referred to in the Options dialog box, basically, put that in my Google search, and I'll put it in quotes and then I'll add the word "AutoLISP" to that search string to filter.

      I don't want people telling me what that setting does-- I know what it does. I want to know how you control that in a program. So I'm going to help guide that search result so that it just gives me things that are programming related.

      So as you continue down this process of working with variables, you're inevitably going to hit some issues that you just can't control with system variables and environment variables.

      And we need to take a step deeper into the geek-dom and look under the hood a little bit deeper in AutoCAD and use something called "Visual LISP."

      Now, when you're in the LISP Editor in AutoCAD, which is actually called the "Visual LISP IDE," the Development Environment-- whatever it is-- so that Visual LISP Editor.

      Visual LISP basically gives you access to the AutoCAD Object Model. Sorry-- have no idea what that means. I can't explain it. I know it works, and it's cool, and I use it, but don't ask me to explain it.

      But in order for us to get access to that Visual LISP or that AutoCAD Object Model, we've got to basically turn it on, which is the-- let's see if I can get the-- whoa-- OK-- if I can-- there is a-- there we go.

      We're going to basically turn it on using this function here-- "vl-load-com." and I put that at the top of my ACADLISP file. I put it at the top of my ACADDOC. I don't know that it needs to be in both places. But I just put it in there just to cover my bases.

      And then we're going to reference the-- so think about it this way-- the AutoCAD application is your vl-acad object-- that's the application itself.

      The Options dialog box, which is the next step down-- the Options dialog box is your Preferences Object. Then on your Options dialog box, the Files tab on your Options dialog box-- that's the Files Object-- does that make sense?

      AutoCAD-- Options dialog box-- Files tab-- if you can think about-- you can remember what that Options dialog box looks like.

      So, basically, what we're doing is creating pointers in this code here. I'm creating pointers to each of these objects because I'm going to refer to them later. In fact, in this example here, I refer to the-- now, again, I'm not explaining how AutoLISP works. I'm assuming that some of this stuff makes sense to you.

      I'm setting a variable using this "setq" function. The variable name is *acad.* Now, I like to use that convention for any variables that I consider global, meaning I'm going to assign it, and it's always going to be available.

      Some variables, as you know, you can assign a variable that's just available within a certain function. And after that function's done, that variable disappears. It's called a "local variable."

      I'm assigning these as a global variable-- it means I can define it once I don't have to worry about it the rest of the time I'm in AutoCAD-- it'll be there anytime I need it.

      So I'm assigning it this name. You can name it whatever you want to. And I'm saying, grab the AutoCAD application object and put that reference in this variable.

      The next line-- I'm doing the preferences object. And I'm actually referring to that variable. So this vla-get-preferences is pointing to the AutoCAD Object Model, which is in this variable.

      And then taking it a step deeper when I go to the Files variable, I'm using the get-files function-- pointing to the Preferences Object, which I just assigned up here.

      Now, I don't always need this document object. But that document object is going to come into play when we start talking about standards because a lot of our standards are drawing-based-- things that are in the drawing.

      Now, we're running really fast here. How are we doing on time? We've got about 27 minutes left. Let me just stop and give myself a breather. See if you have-- are you still here everybody? It's a little-- huuuh? What is going on-- any questions? You don't even know what to ask, do you?

      [LAUGHTER]

      It's like, oh, my goodness. Hang on. You're the first.

      AUDIENCE: If we do the sets-- the environment variable or the system variable-- if you have both of them loaded-- does one override the other?

      PRESENTER: That's a good-- so the question is if you use both a system variable and an environment variable, which is going to-- I would imagine, sequentially-- the last one that loads is going to be the one that wins probably.

      In other words, when you set one of them-- when the code continues to execute-- if it finds another one, it's not going to say, oh, that's already been set and just skip it-- it's just going to overwrite the previous value. Yeah. Yes, sir.

      AUDIENCE: OK, my question is that it seems like AutoCAD-- [INAUDIBLE] were dying, they were going to Revit. Do you deal with Revit, or do you something similar?

      PRESENTER: I'm sorry, what's that word?

      [LAUGHTER]

      AUDIENCE: Do you do something similar things that you implement?

      PRESENTER: The question is, what do you think about Revit? And I don't think about Revit, actually. No, no, that's not true.

      Now, our company does use Revit. I've used Revit in the past and got away from it through three different jobs. And so now I can talk Revit, but I can't use Revit.

      And I don't know how that's-- I mean, we have enough AutoCAD users in our company and enough clients that need AutoCAD drawings that I don't really have a need to spend time-- or the opportunity to spend time on the Revit side, and they probably wouldn't want me on there anyway.

      But I'd be going, OK, where's the command line, right? That's the first thing I'm going to ask for. Any other questions? Yes.

      AUDIENCE: Let them decide the [INAUDIBLE] per minute.

      PRESENTER: [LAUGHS]

      AUDIENCE: Non-Revit, AutoCAD-based vertical products like Flynn 3D don't seem to be supporting access to their Object Model with LISP-- is that something that you've do you know AutoDesk's thoughts on that, or is that something [INAUDIBLE]?

      PRESENTER: Now, what other products you're referring to?

      AUDIENCE: Planet 3D.

      PRESENTER: Oh. Oh, yeah. I do not. It's a great question. Yeah, do you--

      AUDIENCE: Civil 3D's the same way. You can get into it. You can get into trouble with it.

      PRESENTER: [LAUGHS]

      AUDIENCE: Basically, there was something-- I don't know about Planet, but in Civil, you can access something-- you can't access most things, but you can access or [? experience-- ?] you can't access [INAUDIBLE].

      AUDIENCE: Like you said, they're environment [INAUDIBLE].

      PRESENTER: So the workaround there is .net?

      AUDIENCE: You got to work around .net.

      PRESENTER: On some of these other-- yeah.

      AUDIENCE: [INAUDIBLE]

      PRESENTER: And that's for other Autodesk products that maybe don't have that open API-- that application program interface.

      AUDIENCE: But, yeah, I CAD manage for Civil 3D. And I use LISP-- it runs great. But I'm not really controlling Civil-- it's just that Civil's built on an AutoCAD, so my back's against the wall in the AutoLISP Visual LISP.

      PRESENTER: Interesting, OK, cool. All right. Yes, sir, one more.

      AUDIENCE: [INAUDIBLE], and what's the way that AutoDesk has separated out what it's like. And then your advice when it comes [? to preservation ?] and CUI. So what problems through CUI-- basically, having to test CUI's enterprise-- CUI [INAUDIBLE] and they were kind of custom CUI--

      PRESENTER: Correct.

      AUDIENCE: [INAUDIBLE] to be implied the profile being set

      PRESENTER: OK, so that's an interesting thought. So you're saying that you use AutoCAD's profile settings as the corporate enterprise type settings, but you allow the customizability that users-- now, does the user have their own CUI file?

      AUDIENCE: They do.

      PRESENTER: So when they load-- so you've got-- when you're talking CUI files-- AutoCAD has an enterprise CUI and then a custom CUI. The enterprise one typically is locked down-- that's the one that everybody in the company uses, and then you've got this custom-- or could have multiple customs-- that is not necessarily locked down.

      And what this company does is they basically say, you know what? We're going to control the profile and do everything in that, but when the user has their custom CUI, which has a corresponding MNL file-- when that loads, if they want to assign their background color, which is not an easy task, by the way-- dealing with the application colors in LISP is tricky, and the best thing to do is google it. And there's plenty of code out there does some really cool stuff.

      So that's an interesting option that you could provide. And we'll talk about allowing user customization within the constraints of your environment there. Good thought.

      AUDIENCE: [INAUDIBLE] allow for that to happen, to say that. But you don't want a support [INAUDIBLE].

      PRESENTER: Absolutely, yeah, absolutely, yeah, excellent, excellent. All right. Let's keep moving. So we're going to talk about paths. We've talked about paths early on with just the fact that if AutoCAD starts, and there's a path missing, it disappears, and you never see it again until you actually reload your profile, which is the way a lot of companies do.

      But I tried to separate that. So we're going to use some of the Visual LISP Object Model stuff that we just talked about a second ago. We're going to use the Visual LISP stuff to-- Visual LISP functions to control some of our paths, or at least in this example, we are.

      So the function name is "vla-get," and then you've got to have some path object there that you know what that is. The example I've got here is vla-get PrinterConfigPath.

      So this function-- and there's my files that we were-- we talked about the file's object. AutoCAD Options dialog box-- Files tab-- on the Files tab, one of those nodes is your printer configuration path that's what this is referencing-- the printer configuration path where your PC3 files are-- that path in the file's object of your Options dialog box-- that make sense? Kind of cool stuff.

      And then we're using that same function, only this time we're saying, instead of getting what that value is, we're going to put what that value is-- say vla-put-- PrinterConfigPath-- this is where it's going-- this is what I want it to be.

      Now, this one's scary. So one of the things that we do, and this is in lieu of using a profile. So if you start AutoCAD with a specific profile every time, it's doing what I'm showing this code is going to do. But it's also overriding any custom settings that the user might have made unless you work for this gentleman over here.

      So I'll just kind of walk through this real quickly. It's really not that intimidating. It's a lot of code here, but it's really not that bad.

      First, what I'm doing is, I'm actually creating a function. I've got a defined function, and I'm giving it a name, SFSP stands-- for me, it stands for Support File Search Path-- Support File Search Path-- when you're in the Options dialog box on the Files tab, and you click that first node, it expands and you've got like 20 paths in there-- that's the Support File Search Path-- that's where AutoCAD is going to look first for stuff.

      So I'm calling this my SFSP fix. I could have picked an easier name to say. And I just put a comment here that says Set Standards Support File Search Paths, and then I'm saying vla-put Support Path. Where am I putting it? I'm putting it on the Files tab, basically, where the Files [? start, ?] and then I'm just concatenating all these individual paths.

      Now, I didn't need to concatenate them. Concatenate is a really cool programming word, by the way. If you want to impress your boss when you get back, I learned how to concatenate. Watch this.

      Concatenate just means take a bunch of strings and stick them all together and make one string out of it-- that's all that means.

      The reason I did this as a bunch of individual strings is it makes it easy for me to throw another line in there if I want to add another search path in that list.

      So it's taking everything between this strcat string concatenation-- taking all this stuff in between here and here-- making that one long string-- putting it in the File's object-- putting it in the Support File path in my File's object.

      So every time I start AutoCAD, I'm going to run this function SFSP fix. I'm not using that name next time. SFSP fix-- I'm going to use that name, or I'm going to call that "function."

      I also added down here at the bottom-- and what's interesting is, I could not for the life of me, I could not find a Visual LISP function that would control the trusted paths-- there may be one out there, but I couldn't find it.

      So I'm using a system variable. So you already see, we're using different techniques-- it's like welcome to AutoCAD, right? How many different ways is there to do stuff? It's not any different when you get into programming.

      And I'm using-- I'm setting my trusted paths. Why am I setting my trusted paths? Because I don't want AutoCAD dinging me every time I go to load something from this folder, and AutoCAD says, oh, is that a safe file? Are you sure you want to load that? I don't want it doing that. I'm telling it ahead of time-- anything coming from this folder is fine-- just relax.

      So that's a lot of code there, but, really, a fairly simple function. It's a function of two things. I'm putting this support file search path up here, and I'm putting the trusted paths here. It's doing two things.

      Now, this is stuff for you to work on on your own. I'm not going to go through this for the sake of time. But there's so many other things that we could get into. And, again, we're just scratching the surface, but, hopefully, it'll spark some things in your mind you can take back with you.

      Let's talk about-- or oh, that's not Customization-- it should be Standards. Yeah, that's the wrong title. Standards are fun. We love them. We hate them. We need them. We don't want them. Blah, blah, blah, so how do we work around them?

      They're just fun. So some of the things that I'd like us to look at is how do we push standards out? How do we create smart defaults for people, so they don't have to think about things? And how do we create code that's adaptable to accommodate users or conditions or whatever?

      And when I did consulting, I don't know how many times I told people this-- if there's a way that you can create something so that it's easier for the user to do it right than it is for them to do it wrong-- most of the time, they want to do what's easiest, and they'll do it right. But if your standards are so hard to execute or to adhere to-- you're going to get pushback.

      So it's kind of a win-- if you can make your standards easier for them to do it right than it is to do it wrong-- it's usually a win-win.

      We already talked about getting access to the document model because the drawing itself is where a lot of our standards type stuff goes. Let's keep moving.

      Here's a function that I use. When we start AutoCAD, I lock-- we do a lot-- our architectural firm-- there's certain things in our drawings that I don't want people to accidentally move or delete-- columns and column lines and grid lines is one of those things-- so when our AutoCAD drawings start, and this is in our ACADDOC.LISP because it's drawing-specific, we lock all the column layers automatically.

      Now, they can still unlock them, but it's just one less thing they have to worry about. And I won't go through all that code, but you can see there's a little bit of-- there's my list of layer names. It looks to see if the layer actually exists in the drawing.

      If this table object of this layer name exists, then I'm going to put a lock on that layer-- well, that's the-- setting it to true makes it locked. Setting it to false would make it unlock. But anyway you can explore that a little bit more in depth.

      I also lock all our viewports. Why run the risk of people changing viewport scales accidentally when they double-click inside of a viewport, I'm going to take that concern out of the picture.

      So when we start AutoCAD, I lock every viewport in the-- and I also set it to a layer-- 0VPORT is our standard layer. So every one of our viewports is on the right layer-- that layer is-- I don't see it in here, but I think it may be in the code. I'll give you access to all this code.

      I think it also makes sure that that layer-- oh, right here. I make sure that the layer is in the drawing. And I make sure that that layer-- that viewport layer is a nonplotting layer.

      And then I go through the process of putting all the viewports on that layer and making sure that every one of the viewports is display locked, so if they double-click inside of it and zoom, it doesn't mess up the viewport. It's just less stuff that the user has to worry about. Oops, I did that. Now, what do I do?

      This is all stuff that I'm pushing out, by the way. We were about pushing standard. I know pushing standards isn't fun, but there's stuff that is non-negotiable. So let's just push that out there if we can.

      What I do-- one of the modifications that I do-- now, we just defined this lock viewports function right here-- lock viewports.

      But when I'm executing my startup that we talked about earlier-- the s::startup after the drawing is completely opened, then it launches this-- what it does is-- here's where it actually executes that function-- the lock viewport. I put a little message in there, so the user knows what's going on.

      This phrase here-- getvar-titled-- if that is set to 1, then I know that that is not a new drawing. I don't need the locked viewports in a-- if I open up AutoCAD, and there's a drawing one1, I don't care about those reports.

      I really only care about drawings that are already established-- people have borders, and title blocks, and paper space, and all that kind of stuff-- those are the ones I care about. So I just I don't do it in every drawing. I just do it in the drawing. I just do it in actual drawings-- not empty drawings if that makes sense.

      Now, we were talking about Pushing Standards. The downside to Pushing Standards is that they're pushy, right? You're forcing those things on your users, which may not be a bad thing-- however, you may want to go, OK, you know what? I'm not going to push this, but I'll at least make it easier for you to adhere to that standard.

      So what if we were to take these functions that we did a second ago-- the LockViewports in the LockColumn and actually turn them into commands that we could put up on the ribbon, or that they could type in? And that's what we're showing here.

      Basically, I've created two functions. Let's see the LockColumns function. And all that LockColumns function does is execute that LockColumns Layer function that we just showed you a second ago-- that's all it does. So I can go put up a drawing at any time.

      Now, the other nice thing about these functions is that if I'm in the middle of a drawing, and I got layers that I've unlocked, and I want to relock them-- I just type in LockColumns, or you can make whatever shortcut-- two-letter, three-letter shortcut you want to in there. Just type it in-- boom-- all your column layers are locked. Same thing is true with the LockViewports.

      If I don't want to push that on people, but I want to let them be able to pull those standards whenever they want them by creating those two functions when AutoCAD starts up and just letting people know that-- these are functions that you might want to put in an Lfile if you have those buttons on the ribbon, so that anytime that ribbon shows up with those buttons, you know that code is available because it's in the MNL file which gets loaded when the CUI gets loaded.

      So here's something else that I do. We have a default dimension style called "Arch Tick Anno." And so when we open up our drawings, I automatically go ahead and set that as the default dimension style. They don't even know it. I'm going to set that. They may not think about it, but it's one less thing when they put a dimension-- oh, shoot. I got to change the dimension style-- dang it, right? I'll just go ahead and preset that-- one less thing they got to-- I'm nudging them along to adhere to the standards, right?

      Now, in the handout, I talk about adaptive code. The important thing-- the challenge with the previous command that we showed you here is-- what if I have a drawing that doesn't have that dimension style? It's trying to put an active dimension style in this drawing named this. If I open up a drawing that doesn't have that dimension style, AutoCAD's going to go-- eh, wrong answer. It's not going to let me set that, and then I'm going to get an error.

      So what I'm going to do is, I'm going to take that same code-- that's the same code from the previous screen-- I'm going to copy it over, and I'm going to add two lines to it. Same code-- I'm going to add a line at the beginning and a line at the end. And the line at the beginning says, you know what? Only do this if this dimension style exists in the drawing. That table search-- AutoCAD's table-- they call it a "table--" not like a table that you see in AutoCAD, but an AutoCAD table has your dimension styles and layers and things like that.

      So, basically, it's searching the Dimension Style Table to see if that dimension style even exists before it then goes and does the rest of this stuff.

      And all I did was modify that a little bit so that it doesn't cause errors when the scenario is not the same.

      Here's another thing. In fact, I think the quote right here-- when I was consulting, again, people would say, man, we would really like to be able to do this. Can we do this? Can we automate this? And my answer was always-- the foundation for automation is standardization. You want these automated things. You want this to automatically do this and automatically do this, and that's all great. But if you don't have standards-- I can't help you.

      Automation is built on the foundation of standards. So in this example here, I'm actually looking at the file name. We have seven minutes. I'm looking at the file name for a specific letter in a specific spot in that file name-- very simple example.

      But what I'm doing is, I'm saying, take the drawing name-- this function here, substring, basically, picks it apart and says, look at the eighth character in that file name. Only look at one of those characters. If that is an A, then I'm going to assign a global variable called "arch." I know that's an architectural drawing based on this letter A that's in the eighth character of my standard file name.

      We have a file naming standard in our company. Why? Not because we're trying to be hard-nosed about it, but because it allows us to do stuff like this-- same thing's true with the-- E is Electrical, M is mechanical.

      Now that I know what that drawing discipline is based on the file name of that-- now that I know that, I can do stuff like this.

      Whenever they open the drawing, I can go ahead and assign the current tool pallet that applies to that drawing, right? Boom. I love that, right?

      So now when I open up an architectural drawing-- why do I know it's architectural? Because there's a letter A in the eighth character of our standard file name, right?

      And when I open up the Tool Pallet-- guess where it defaults to? The Architectural Tool Pallet. Ah, it's a beautiful thing.

      Again, I'm not going to explain how that all works, but you get it. I'm using that variable. And, now, one thing interesting you may notice-- there's no architectural listed here.

      Basically, I'm saying if it's not mechanical, and it's not electrical-- just default to architectural-- I'm making that assumption. Now, that also means that-- let's go back-- that also means that any drawing that doesn't have a drawing discipline as a sign here is going to, by default, be considered architectural because if none of this-- if the drawing doesn't match any of these, it's not going to have a drawing discipline.

      And so when I get here, AutoCAD will say-- well, it's not mechanical. It's not electrical. It must be architectural. So that could come back to bite you. You have to play with that a little bit.

      Adaptive code for your users is similar to what the gentleman over there is doing with their MNL file-- we let all our users have a personal LSP file that gets loaded automatically whenever you open up AutoCAD. It's going to look for-- using the Find File, it's going to look for that file. If it exists, then it's going to load it down here-- pretty straightforward.

      For further exploration on your own-- Customization-- we're going to have to run through some of these, just creating simple commands. I have an xh and xv command for doing vertical XLINE and horizontal XLINES. It's nothing fancy, but, man, it's handy.

      I have a function called "B1" for Break at one point. It's so nice. I'm hitting Break, and then the F for the first point and pick another point. Forget that stuff.

      AUDIENCE: [INAUDIBLE].

      PRESENTER: Thank you. Here's a function I created to expand on an existing AutoCAD command. Shortcut-- the two-letter command BF, for me, says, Bring to Front.

      I type in BF, and one of two things is going to happen. If I already have Objects selected-- that's what this function right here-- if I already have Objects selected, think about when you pick a bunch of objects, and then you hit the Erase command-- it erases them, right? It doesn't prompt you to pick those objects again-- they're already selected.

      That's what that ss-get and when the quotes "i" does. So whether they're selected ahead of time or not, it's going to take all those objects and move them to the front. BF-- Bring to Front. And I have an SB for Send it Back-- same command pretty much.

      Now, this is really cool, and I do want to spend the last couple minutes on this. Man, we're running out of time. So reactors are-- the thing about the other functions-- they're good, but sometimes you want to have functions that the user can't navigate around. If I undefined an existing AutoCAD command, users can figure out a way to execute the original-- the actual AutoCAD command.

      Now, with reactors, what a reactor will do is you can tell AutoCAD to basically act a certain way when a certain scenario exists.

      In this example, and there's plenty of examples, but in this example, basically, what I'm telling AutoCAD to do is-- when a command starts, run my function. Before you do the AutoCAD command-- run my function first. Really cool stuff.

      In this example, what's going to happen is if I start a Dimension command, AutoCAD is going to-- and, again, I'm not going to explain how this works, but AutoCAD is going to look at the command list that's being run, and if the first part of that command name is Dem, then I'm going to grab the current layer and save it, and then I'm going to set the current layer to a Dimensions layer.

      So every time I draw a dimension-- guess what? It comes in on the Dimensions layer. It's awesome. And it makes sure that the layer color is right. And there's the active layer.

      So notice this function doesn't create my dimension. This function runs before AutoCAD creates the dimension. Now, the corresponding code to this is the one that happens after a function.

      So you've got the reactors that are triggered before a command starts, and ones that can trigger after a command ends, and that's what this does.

      Basically, what I'm doing here is I'm saying if the previous command that AutoCAD just ended-- if that command is a Dimension command, put the layer back to what it was before-- that "ol" variable that we restored to the previous code, that way, when the function is done, it puts the layer back to what it was before the person created the dimension.

      To create your own Dimension function-- to do that would be really painful but reactors will-- you do that, and then, how you assign those reactors is this here. And, again, we don't have time to get into all that. But, anyway, more stuff for you to explore.

      There is a link where I've got notes and other references, and I will make this code. All the code we've shown here available for you.

      You're going to break a lot of dishes as you start climbing this ladder to Programming the Work out of AutoCAD, or AutoCAD management, but you'll get there. Embrace the journey. Fail fast-- fail often, and make sure you do your survey. And have a great rest of the week. Thanks, everyone.

      [APPLAUSE]

      Downloads