COD Script Extension for VS Code

If you write COD Scripts for Autodesk Fabrication, take note. There’s now an Extension for Microsoft Visual Studio Code (VS Code) which is Microsoft’s free code editor. If you use Notepad or Notepad++ to edit your code today you may want to consider switching. The COD Extension has some really nice features. Color coding of your code is the most obvious as shown below. However, there’s a lot more than just color coding. Features like Auto-Complete, Folding Sections and Dimension/Option Picker are nice additions in addition to a lot more robust documentation.

Installing The Fabrication COD Extension

If you don’t already have it, you can download and install VS Code here…https://code.visualstudio.com/. Once installed, go to the Extension section, type FABCOD and click the Install button.

Extension Summary

Once you’ve installed the Extension, you can review a summary of extension details here…

From here, you can review a couple of the key features and their keyboard shortcuts….

VS Code Feature – Mini-Map

Not a feature of the extension, but one reason VS Code is a nice editor is the Mini-Map which helps you visualize where you are your code.

FABCOD Extension Feature – Folding

One of the features the FABCOD extension exposes in VS Code is the ability to collapse/expand sections of code for Looping and Conditional function and other areas. When you move your cursor to the left margin, you see symbols that activate this functionality called Folding.

In addition to Folding sections of code, you can create your own areas of code to collapse/expand. These are Folding Regions and can be inserted (or typed manually using the proper syntax) by highlighting the code and pressing CTRL+SHIFT+/.

FABCOD Extension Feature – AutoComplete

Auto-Complete is another core feature of any code editor. VS Code’s Auto-Complete features is leveraged by the FABCOD extension. You’ll need to be editing a saved file with a COD file extension so the VS Code extension knows which code extension to use.

ABCOD Extension Feature – Hover Tips

If you hover over known functions/properties and their context can be determined, VS Code will display a tooltip for the function you’re hovering over. This can be a great way to learn coding as it’ll help you with the syntax.

FABCOD Extension Feature – DIM / OPTION Picker

One of the best features of the FABCOD extension is the ability to get suggestions for the Dimension (DIM) and Options. You can activate the DIM picker with SHIFT+F1 and the OPTION picker using SHIFT+F2 keyboard shortcuts. When using these features, you are presented with an edit box. You type the CID/Pattern Number you’re interested in and press Enter. You are then given a list of Dimensions or Options you’re interested in. It’s not fool proof because some patterns have variable DIM/OPTION values but it seriously helps none the less. Take a look here…

FABCOD Extension Feature – Additional Help

Sometimes you need added help for a function. The FABCOD extension is an open source project on GitHub (https://github.com/AgileBIM/FabCOD). This project contains added help for every function and property and is Auto-Generated and updated as the extension is developed. You can access this help from any of the popup ToolTips by clicking on the BLUE hyperlinked text.

FABCOD Extension Feature – AutoCAD Launcher

One of the other neat features of the FABCOD extension is the AutoCAD Launcher. Pressing F5 in the editor will initiate the script in CADmep. Simply Alt-Tab to AutoCAD and press enter. AutoCAD and CADmep must be loaded at the time for this to work. Due to Autodesk’s limitations in their API’s, this functionality does not work with ESTmep or CAMduct.

VC Code FABCOD Extension – Wrapup

There’s a lot more to VS Code that I won’t get into here. I’ve only covered the highlights of how it and the FABCOD extension can be used to help edit COD file in Autodesk Fabrication. As it’s an open source project, there’s instructions on how to become involved if you have the coding skills. You can also just head over and log issues or suggestions. (https://github.com/AgileBIM/FabCOD)

Move Your AutoCAD Workflow to BIM360

If you’d like to move you AutoCAD workflow to BIM360, you can now easily accomplish this. It’s really quite simple and requires a couple things….

First, you nee to install the Autodesk Desktop Connector. This adds a BIM360 Drive” to your computer much like OneDrive, Google Drive, Dropbox, etc. This BIM360 drive provides access to your BIM360 Projects that you’ve been granted access to from your BIM360 Administrator.

Once the Autodesk Desktop Connector is installed, you can access your BIM360 projects from this drive. You may need to login first to see your projects. You can do this by right-clicking on icon in the System Tray.

You can get the Autodesk Desktop Connector using this link.

Second, there’s a new utility called File Locking for Autodesk BIM360. This utility allows AutoCAD to “lock” the drawings you open on BIM360 so that no others can edit them at the same time.

You can download and install the File Locking for Autodesk BIM360 from the Autodesk App Store using this link.

When you now open a DWG from the BIM360 drive, BIM360 will lock the DWG and prevent others from editing it at the same time.

A final word….Once the File Locking utility is loaded, you can use the CloudCollabModifiedOption system variable to control how file locking is handled when you close the DWG in AutoCAD. Details here…

Autodesk Product Install Order

Back in the day, I briefly worked for an Autodesk reseller. This particular reseller was classified as an “Education Reseller”. In short, this meant they were one of a few resellers that sold Autodesk products into the educational market (high schools, universities etc.).

As you can imagine, a school would likely have most of not all the products. Back then, Autodesk provided a complete list of all the products and their recommended install order. Fast forward to today, they’ve either gotten incredibly lazy or in all their massive layoffs over the years, the domain knowledge is gone. I suspect both.

Autodesk’s Recommendation

Take a look at Autodesk’s current recommended install order from this link. which was last updated 6/6/2018 at the time of this writing. In the event the link changes, here’s what they say…

What’s wrong is that they tell you within the same product year, the install order doesn’t matter. This is outright false for many reasons. They try to note a couple “exceptions” stating that if there’s any add-ins, the base product should be installed first. But which products have add-ins to what other products?

CADmep is obviously running on top of AutoCAD so AutoCAD should be installed first. That seems obvious. But Navis also installs Exporters depending which products it finds and it doesn’t always show up in an Add-ins tab. So this is less obvious. Buy there’s also other dependencies that are even more obscure. Should you install Revit or Inventor? Should either go before or after 3ds Max? This is less obvious to most users.

This is really why someone would ask that question. It’s a real dis-service then to start out telling them it doesn’t matter. In fact, it matters most of the time, and it doesn’t matter as the “Special consideration”.

Determining The Real Install Order

There’s a few ways to handle this. If you’ve been around a while and had one of the old “Design Suites”, install in the same order as the Design Suite did. But note that this did change between product years and types of Suites. Plant Deign Suite 2013 for instance installed Autodesk before Revit where as Building Design Suite 2016 installed Revit before AutoCAD.

One of the other ways is to look at the install media folders to see if you can find any dependencies. Take for example 3ds Max. Look in the x86 or x64 folders and you’ll see references to Revit and Inventor.

This means we should install Revit and Inventor before installing 3ds Max. But what if we’re using both Inventor and Revit? Which of those goes first?

You’ll see the RXI folder in the install files. Hard to tell what it is. When you drill into the folder, there’s just a single MSI. If you right-click on it and select Properties and do to the Details tab, you can see it’s Revit Interoperability for Revit. Other folders deeper in the structure also confirm this by their naming,

Based on this findings, it suggests installing Revit first so Inventor can see it and install the Interoperability tools.

Here’s My Order

So, if you’re an Autodesk Fabrication user, here’s what I typically do (and why)….

  1. Revit (doesn’t seem to depend on anything else)
  2. AutoCAD (I can’t find a dependency for AutoCAD. But anything with an Object Enabler will want it here and it’s a core product so as a matter of safety, I install it early just in case)
  3. AutoCAD based Verticals like MEP, Arch, etc. (These use AutoCAD as its core. I’ve not checked dependencies between verticals but it’s likely safe to install them in any order. I usually do Arch first if I’m going to include it as MEP is built on top of Arch but it’s really not needed as MEP installs what it needs)
  4. Inventor (because of the Revit dependency covered earlier)
  5. 3ds Max (because of the Revit/Inventor dependencies)
  6. Navis – Freedom/Simulate/Manage (Navis exporters only install for products already installed so we install this toward the end)
  7. Fabrication CADmep (allows CADmep Object Enablers to install for Acad, Navis, etc.)
  8. Fabrication – EST/CAM/etc. (order doesn’t matter)

If there’s anything on the list you don’t use, just skip it. If you happen to install Navis before some of the dependent products, just use “Add/Remove Programs” in Windows Control Panel to modify the install to include new exporters or download the Exporter installs separately from Autodesk’s web site.

Inserting List of Points into AutoCAD

Have you ever received a list of coordinates in a CSV file and wanted to place those in AutoCAD? Were you aware this can take as little as 2 minutes?

For a very long time, AutoCAD has supported SCRIPT files. A script file is nothing more than a text file (using only Notepad) that lists the everything that you’d typically type to AutoCAD’s command line.

Take for example the following CSV file. How would we get this into AutoCAD?

Points List in CSV Format Opened in Excel

To figure out what we need to type in AutoCAD, let’s first start by making sure our Point style is something other than a single dot so it’s more easily visible on your screen. To do this, type “PTYPE” at AutoCAD’s command line. If you don’t get the following dialog, Escape out of the command and type “DDPTYPE” and try again. Select a point style that suites you.

Point Style Dialog

Now that you have a point style that’s more visible on the screen, lets type the Point command and see what input it takes.

You can see from the below image of the command line that once we type “POINT” and press ENTER or SPACEBAR, there’s a little text that displays the current point style and size. You’re then prompted for the coordinates. The points in this example were entered by typing X,Y,Z coordinates for one point and X,Y coordinates for the other. After typing the coordinates and pressing ENTER, the command completes.

X,Y or X,Y,Z Formats Can Be Used For Points

To test this theory, we can use Notepad to manually create a Script file. Type the contents you in the below image and name your file with an “SCR” File extension. You’ll want to make sure Notepad’s “Save as type” drop down list is set to “All Files (*.*)” or else Notepad will append a TXT to the end of the file.

One other thing to also note is that the cursor is after the last line, just below it. This is because there’s an “Enter” after the last point…this is just like hitting Enter on the keyboard to complete a command in AutoCAD.

Use Notepad to Create a Script File

After you’ve created your text file, type the “SCRIPT” command at AutoCAD’s command line and select the Script file you just created. When complete, AutoCAD should have added 2 more points to the drawing.

The Script File’s Input Looks The Same As Manually Typing.

So, now you know how the basis for a script file (same as you’d type manually) and how to create one (using Notepad), the next thing you need to do is convert the CSV file in Excel to a Script file. That’s actually quite simple.

You’ll use Excel’s “CONCATENATE” function which takes several pieces of text and puts them together. In this example, this is the formula we’re using…

=CONCATENATE("Point ",B2,",",C2)

The first piece of text is the Point command. Remember, we can use the SPACEBAR after a command and it’s the same as if we’re pressing the ENTER key. That’s why you see the space after the “POINT“. Each piece of typed text is also contained in double quotes. 

=CONCATENATE("Point "

Each piece of text that is concatenated is separated by a comma. After the command, you start typing the X-Coordinate which is the Easting column in the CSV file. Because we’re not explicitly typing text, we can simply use a cell reference like so…

=CONCATENATE("Point ",B2

When typing coordinates in AutoCAD, we separate them with a comma, so we use another comma for Excel’s Concatenate function, then a comma explicitly typed in double quotes.

=CONCATENATE("Point ",B2,","

Finally, we add the Y-Coordinate which is in the Northing column using a cell reference, again, remembering to separate all the pieces of data with a comma and close the Excel function with a closing parenthesis.

=CONCATENATE("Point ",B2,",",C2)

When you’re done, copy the formula to the other cells. You can see in the image, that we have a line of text similar to what we typed in Notepad manually the first time. The below image, I’ve used the F2 key to edit the first cell so you can see the formula and the cell references.

Excel Used to Build a Script File

Now that you’re text in Excel is in a Script File format, you can guess the next step. Copy/Paste the text into Notepad, Save with a TXT extension on the file name.

Make Sure the Cursor is on the Last/Empty Line

The last step is to run the script file in AutoCAD using the Script command. Zoom Extents in AutoCAD to see your points. The CVS file, Excel File and Script files can be downloaded for examination from this link.

Here’s a screen recording of making and running the script file. As you can see, it takes a CSV file, gets converted into a Script file and places the points in AutoCAD in less than 2 minutes.

CSV Points List to AutoCAD Points in Less Than 2 Minutes

Script files are quite easy. You could easily add more text, and use different commands to do the same thing like Insert an attributed block into the drawing and use the point number as the attribute value. You just need to make sure all your system variables are set to prompt you upon insertion for the attribute value.

The only real downside to Script files is they’re not intelligent. They don’t like extra characters or spaces, the don’t work well with commands that prompt for user input or display dialog boxes and they don’t perform conditional logic to do different things depending what they find. They will however call AutoLISP routines so when I have more advanced work I want to do in a script file, I just have the Script call and run my Lisp as well. 

AutoCAD 2018.1.2 Update

In case you missed it, Autodesk released update 2018.1.2 for AutoCAD a couple weeks ago. Click here to see a listing of the issues fixed in this and previous updates for AutoCAD 2018,

To download and install the update, refresh your Autodesk Desktop App and updates should appear if you have an active subscription (maintenance plan or annual subscription). The Autodesk Desktop App icon is located in your Windows System Tray if it was installed.

You can also access them from the Product Downloads section of the Autodesk Accounts portal if you are a contract manager or software coordinator in your account.


AutoCAD Selection Modes

AutoCAD does a lot of things for you automatically. Unless you’re an old timer from back in the DOS days, you may not be familiar with all the options you can choose from when presented with the “Select Objects:” prompt in AutoCAD, In days of old, AutoCAD displayed all of the options on the command line when going into selection mode. There were less options back then and a lot of what happens automatically now, you had to type the options for,

Today, there’s a lot more options so AutoCAD no longer displays them unless you type an invalid entry. Even then not all the options are displayed. Many of the options now are default behavior making the options less critical in operating AutoCAD efficiently. None the less, they are often helpful. Here’s a chart of the options available. A description of each option follows. For more detailed information, you can refer to AutoCAD’s Online Help using the following link.

AliasOptionModal / Single Use
AAddModal
ALLEverythingSingle Use
AUAutoModal
CCrossingSingle Use
CPCrossing PolygonSingle Use
GGroupSingle Use
LLastSingle Use
MMultipleModal
OObjectModal
PPreviousSingle Use
RRemoveModal
SiSingleModal
SUSub-ObjectModal
UUndoSingle Use
WWindowSingle Use
WPWindow PolygonSingle Use

  • Add (A) – Default mode for selection in AutoCAD. As you repeatedly pick items, they are ADDED to the selection set you are building. Stays in effect until switching to REMOVE mode.
  • All (AL) – Single use option that selects ALL objects in your AutoCAD drawing even if not displayed outside the current drawing area. Object on layers that are OFF and/or LOCKED will still be selected. Objects on layers that are FROZEN will not be selected.
  • Auto (AU) – Default mode for selection in AutoCAD. It’s combination of two other AutoCAD selection modes combined. SINGLE if you pick on an object, it will be selected. If you don’t pick on an object, BOX selection mode will be a CROSSING if the second point is to the left of the first selected point or a WINDOW selection  if the second point is to the right.
  • Crossing (C) – Single use selection mode where you pick two points to form a rectangle. Anything completely within or crossing the rectangle, regardless of the order or direction the points are picked is selected.
  • Crossing Polygon (CP) – Single use selection mode where you picks a series of points to form a polygon. Any object completely within or crossing the polygon will be selected.
  • Group (G) – Single use selection mode that allows you to type the name of a group to add the objects in that group to your selection. When specifying the names of unnamed groups, you must include the asterisk (*) prefix in the automatically assigned anonymous name AutoCAD gives it.
  • Last (L) – Single use selection mode that allows you to select the most recently added object in the drawing that’s visible, in the current drawing space and who’s layer is not off or frozen.
  • Multiple (M) – Modal selection mode used to selects objects individually without highlighting them for performance when selecting complex objects. When finished selecting objects you don’t want to highlight, press Enter and you’ll be returned to the default AutoCAD selection mode and still in the select objects prompt.
  • Object (O) – Default selection mode in AutoCAD where you select objects. Use this option to exit the SUBOBJECT selection mode.
  • Previous (P) – Single use selection that selects everything that was in the previous selection set (assuming the previous selection set wasn’t erased).
  • Remove (R) – Modal selection mode that cancels the default ADD mode to remove objects from your selection set. Most useful when it’s faster to select everything (ALL) and remove what you don’t want selected than it is to select everything you do want selected.
  • Single (Si) – In addition to being a single use selection modem, you can only select one object and the select objects prompt is terminated. If you fail to select an object in SINGLE mode, you are switched to BOX mode.
  • SubObject (SO) –  Model selection that allows you to select edges, faces, etc of complex objects. When in SubObject mode, you can no longer select Objects without using the OBJECT option to return to that selection mode.
  • Undo (U) – Single selection mode that removes the most recently added object (or objects if they were selected as a group) from the selection you’re building. Can be used repeatedly to keep removing object(s) in the reverse order they were added.
  • Window (W) – Single use selection mode where you pick two points to form a rectangle. Anything completely within the rectangle, regardless of the order or direction the points are picked is selected. Unlike CROSSING, anything that crosses the window will not be selected.
  • Window Polygon (WP) – Single use selection mode where you picks a series of points to form a polygon. Any object completely within the polygon will be selected. Unlike CROSSING POLYGON, anything that crosses the polygon will not be selected.

AutoCAD Performance & RegApps

Slow Drawings?

One of the powerful features of AutoCAD is the ability for applications to built on top of it. Unfortunately,  these applications can often leave remnants of themselves inside your drawings and cause performance issues. One such side effect is the buildup of Registered Applications or RegApps for short. These RegApps are left in the drawing’s Symbol table after entities that contained the XDATA (Extended Entity Data) they used are deleted.

While this can affect any user, this can be very common in the AEC industry as collaboration with external parties and trade partners means you’re typically referencing a lot of files from many sources. I’ve seen cases where a drawing with 50,000 RegApps can take 10 minutes to load and after clearing RegApps, takes merely seconds.

What most people don’t realize is that even though “RegApp” is an option with the PURGE command, using PURGE ALL will NOT remove them. You need to call PURGE separately, with only the REGAPP option.  Click the following ScreenCast recording link to see a demonstration of this…

Example: How to Purge RegApps

  The video shows PURGE ALL and doesn’t list that any RegApps were removed. Purge is then called again, and only the REGAPP option is used which then removes several RegApps. Try it yourself, the drawing used was in the Sample Civil Sheet Set drawings that shipped with AutoCAD 2018.

Problem Keeps Returning?

External References (XREFS) and/or blocks can make the problem difficult to eliminate. You may need to process all Xrefs and block libraries to verify these RegApps aren’t being introduced from those sources. If you’ve used WBLOCK to save a block to disk from a RegApp corrupt drawing, that DWG file also has the issue.

Luckily, Autodesk has a batch utility (free) that will process multiple file/folders, automatically look in sub-folders as well as automatically load any referenced drawings as well.

Click the following ScreenCast link to see the process in action…

Example: CleanupRegApp Utility

Depending on your version of AutoCAD, you can get this utility from the following links..

201832-Bit Program64-Bit ProgramKnowledge Base ArticleRead Me
201732-Bit Program64-Bit ProgramKnowledge Base ArticleRead Me
2015-201632-Bit Program64-Bit ProgramKnowledge Base ArticleRead Me
2013-201432-Bit Program64-Bit ProgramKnowledge Base ArticleRead Me
2010-201232-Bit Program64-Bit ProgramKnowledge Base ArticleRead Me
2008-200932-Bit Program64-Bit ProgramKnowledge Base ArticleRead Me

Schedule Cleanup After Hours

One last benefit if this utility is that it can be called from a DOS window with command like syntax. In a collaborative environment where Xrefs are being updated frequently by others, RegApps can keep getting reintroduced requiring this process to be run frequently. Because you can call this process completely automated from the a DOS prompt, this means you can create a batch file that’s scheduled to be run on a regular basis, even nightly on your drawing library. The following Screen Cast link shows how to call the utility from a DOS command prompt…

Example: DOS Command line