Category Archives: Autocad .Net API

This documents the work I’ve done on the Autocad API.

I will be posting code and helpful methods which you might find of use.

Thank you!

Ferrule Comparison – How to check for clashes in the starter bars for two adjacent panels (Demo Video)

How are you going to ensure that the starter bars do not clash? You’ve got 1000s of panels to detail and a dozen detailers working on different projects. How are you going to manage this?


What is the problem?

Consider this situation – you’re got a marking plan in front of  you. You want to make sure that the ferrules in corner panels do not clash. How are you going to do that?

How would you solve the problem?

You’d have to find the corner panels, and then go to the appropriate drawing – both of them mind you – and you’d have to make sure that they are at different heights. That can get very tedious and it’s very time consuming, and more than likely, you’ll make some mistakes – because the panel elevations might not be adjacent to each other.

It’s not the easiest thing to see and compare in AutoCAD.

What is a better way to solve the problem?

But now you have a tool which allows you to easily compare the heights of the ferrules in two panels, straight from the marking plan.

There’s a lot of code and logic which goes with this. Perhaps I will outline it in another blog post.

Code Synopsis

For a very, very brief description of the overall route used, you can check out the code synopsis from my sister blog here. There I post the base class and interfaces used to derive the result – but have excluded all the implementation details.

Video Demonstration

Here is the video demonstration – and yet another example of the type of technologies and innovations you will have at your disposal if you work with us:

Checking for Clashes in Starter Bars between different panels from Tek1 on Vimeo.

We’re always pushing for better, faster and more efficient.

Where did the AutoCAD File Dialog User Interface Go – How to Return it back to normal after using AcCoreConsole? (AutoCAD)

What Happened? No Dialog Box UI in AutoCAD?

Revert AutoCAD FileDia
If you’ve run AcCoreConsole and can’t bring back the normal user interface, just remember this trick.

So I’ve just managed to run AcCoreConsole – some script. And it’s changed some settings. And now when I open regular AutoCAD, when I type in netload – it seems that I’ve lost the ability to open/select things using the user interface. Now I have to manually type out long file names into the command line which is the height of tedium.

Why did it happen?

It happened because we were not meticulous in the running of our AcCoreConsole scripts. We should be sure to ensure that we save settings properly so that when users use the regular AutoCAD program, they don’t have to reconfigure the entire environment away from what works well for AcCoreConsole, back to what they are normally used to.

How to fix the problem immediately

You can file the problem by typing in:

That should change those settings back to normal.

How to avoid the problem in your script file

Don’t forget to return it to the original settings: anything beginning in a semi-colon is a comment and will not be executed.

You can see a gif of it in action above.

How to load lisp files in AcCoreConsole

A commenter had some trouble loading the files. So perhaps the AcCoreConsole is confusing people.  So here is a post which will hopefully clarify how to do it.

It’s quite simple:

  1. Have the LISP file ready.
  2. Load the lisp file
  3. Call the command.

It works exactly the same as in AutoCAD – the UI version. But remember you cannot call any commands which make use of Windows forms or WPF. It is strictly command line only. So things like APPLOAD are not going to be very effective in the AcCoreConsole.

1. Have the Lisp File Ready

Here is an example that you can download.

The same is pasted below if you feel uncomfortable in downloading it:

;; Comments can go after the semi colon


(princ “\nNow we define a lisp-defined AutoCAD-Command called ‘HELLOWORLD'”)

(princ “\nAutocad-command HELLOWORLD is defined NOW”)

(princ “\n HelloWorld loaded, start HELLOWORLD with command: HELLOWORLD or with (c:HELLOWORLD)”)



(defun c:HELLOWORLD nil


(princ “\n Hello World!”)



I modified it from a file kindly posted by someone in the AutoCad forum. Remember to save it with a .lsp extension!

2. Then Load the Lisp File

Type in the following in AcCoreConsole:

(load “C:\\Users\\Koshy\\Downloads\\DownloadedCode\\HelloWorld.lsp”)

Of course – you will substitute the path to the file as it appears in your computer.


3. Then Call the function:


In AcCoreConsole type in:


or alternatively:


The Result


Lisp Function output
Shows the output of a lisp command executed in AcCoreConsole.

Returning Inside Using Statements (AutoCAD .net API)

WPF Databinding operations in the AutoCAD .NET API
A demonstration of using a WPF User control to display information pertaining to missing and/or extra items within a panel, using the ComparePanels Command.


While writing the above AutoCAD plug-in, I faced a small conundrum in the below code:

  • The question for you is: will the transaction be disposed of, and committed given I have returned the bool before it reaches the end of the using statement?

Will it be disposed?

The short answer is yes. The transaction object implements IDisposable. So, finally you can trust that the transaction will be disposed, and that any objects that it opens will also be similarly disposed.

Will the transaction be committed?

I had a peak into the Dispose methods using Reflector. I didn’t see any automatic committing of any transactions – so I am venturing to say that no, the transaction will not be committed. In other words, we’ll have to restructure the above code to ensure that the transaction is committed before we issue the returning statement. Perhaps the AutoDesk team should abort a transaction if it is not committed before a transaction is disposed?


So the lesson is: (i) always be sure your transaction is being committed, and (ii) a using statement obviates the need to ensure that your transaction is actually being disposed of.

Finding Blocks “Colliding” with Shear Lig Points (AutoCAD)

Showing Blocks Close To Shear Lig Points

It’s a common problem apparently. There are far too many block references placed a little too close to those pesky shear lig points. It takes discipline, but when you have 5-10 people all working on the same drawing, with different practices, it’s something that’s really easy to miss, but really expensive to discover.

So I developed a tool to take care of it.

Here is the video demo:

Checks for Clashes against Shear Lig Points from Tek1 on Vimeo.

Thanks for stopping by!

How Tek1 solves the problem of Ordering Items in Precast Panel Detailing Projects

Demonstrates the output of Tek1 Order forms – in precast projects.
Counting Items is difficult

Ordering parts in precast panel projects is tricky. You need a BOM (Bill of Materials). You need to know what you need and how much. When there are thousands upon thousands of parts – that can be a very tricky endeavour.

 Why should you bother counting inventory?

It all comes down to money. And how much of it you tie up in your inventory. And how quickly you’re gonna use it. Financial liquidity is like blood and oxygen. Without it, no organisation can survive. And you can maximise your liquidity (and profits too) if you manage your inventory well. You should be able to answer these questions:

  • How much inventory did you pay for?
  • How much inventory is in your shop?
  • How much did you use up in your projects?
How Tek1 solves inventory problems: Demo Video

We give you accurate numbers about what you’ve ordered. And what you need to order. This is how we come up with a Bill of Materials:




Demo: Select (Panel) Lines which are Open or Closed

Demo of tool which selects closed lines.
Demo of tool which selects closed lines.

Sometimes we have a need to identify – and quickly – lines which are open and lines which are closed – especially prior to running any operations on those lines involving regions.

Here is a demo of a little plugin I wrote.

It goes through the modelspace and finds all the line segments which are connected to each other. It further goes on to query which line segments are closed and which are open.

Getting AutoCAD to do this quickly was quite a task. But am very pleased with the speed – only 1-2 seconds when you’re iterating through a few thousand lines. Not bad.

Enough talk, here is the demo:


Select Open and/or Closed Panel Lines from Tek1 on Vimeo.


How to Easily Compare Precast Panels in AutoCAD

Panel Comparison Demo
This tool compares panels and imports differences. Yet another reason why Tek1 is leading the world in precast panel drafting.
Shop drawing / Layout panel discrepancies are a thing of the past.


Suppose someone makes a change in the layout but forgets to do so in the shop drawing (and vice versa). If you move a cast in plate, and if it’s actually produced and taken to site, then you have a big problem, and a big cost. How are you going to identify the differences which exist in the thousands of panels that you make? What if you had a tool which allowed you to easily identify differences between the two drawings?

This is what this Panel Comparison tool does. It gives you confidence that somebody hasn’t made a boo-boo. And moreover, if somebody has made one, then this tool identifies sloppy shop drawing practices.

Here is the demo. I hope you enjoy it!

Compare Panels Demo – Import Panel Difference from the Shop Drawing to the Layout from Tek1 on Vimeo.


  • It can work for all clients with only very minor modifications. Very well abstracted out in the code.
  • It is super fast. Comparing the thousands of elements in each drawing takes a bit of computing power – but with smart algorithms, you can cut down the time.
  • It works for all sorts of edge cases – what if the panel was made up of arcs, polylines and straight lines – this plugin can handle all sorts of things. It can also handle voids in the panel?
  • What if an item is on the edge of a panel line – it can handle that was well.

Every single panel that we draw will go through the above practices. It should give you a lot of confidence that we’ll get the drawings right. Yet another tool in the Tek1 arsenal that allows this firm to lead the industry in Precast Panel drafting.


Comparing Lines – IEqualityComparer

It’s not very often that I write something on the Autocad .net API, so here’s something which you, I suppose, will need one day:


If you want to compare two lines, with a tolerance, in a collection then you’d need a LineComparer. The MSDN guide says that one should inherit from EqualityComparer, so unquestioningly, I did their bidding. The results are as below.

Take careful note of the Hashcode. You want lines that are similar – and are within the tolerance to return the same hashcode. If they are outside the tolerance then the chances of two different lines returning the same hashcode is minimal.

Lines are equal if their start and ends points are equal (or vice versa). They are also more or less equal if they return the same hash code. In such cases, then the equals method is run.