Through the Interface: Adding a new annotation scale in AutoCAD using .NET

May 2015

Sun Mon Tue Wed Thu Fri Sat
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30


« Loading the right version of an ObjectARX module into 32- or 64-bit AutoCAD | Main | Making AutoCAD objects annotative using .NET »

April 25, 2007

Adding a new annotation scale in AutoCAD using .NET

Thanks to Nikolay Poleshchuk and Roland Feletic for suggesting this topic, and to Wayne Brill, from DevTech Americas, for providing the code.

In this post we're going to look at some functionality that's specific to AutoCAD 2008 - adding a new annotative scale to a drawing. The next post (assuming I can work out how to do it :-) will cover how you can attach a scale programmatically to make an entity annotative.

Firstly, I should cover what the annotation scaling feature is all about...

Here's a quick overview from the AutoCAD 2008 online help:

Objects that are commonly used to annotate drawings have a property called Annotative. This property allows you to automate the process of scaling annotations so that they plot or display at the correct size on the paper.

Instead of creating multiple annotations at different sizes and on separate layers, you can turn on the annotative property by object or by style, and set the annotation scale for layout or model viewports. The annotation scale controls the size of the annotative objects relative to the model geometry in the drawing.

The following objects are commonly used to annotate drawings and contain an annotative property:

  • Text
  • Dimensions
  • Hatches
  • Tolerances
  • Multileaders
  • Blocks
  • Attributes

When the Annotative property for these objects is turned on (set to Yes), these objects are called annotative objects.

Here's some code in C# that creates a new annotation scale and adds it to the active drawing in AutoCAD:

using Autodesk.AutoCAD.ApplicationServices;

using Autodesk.AutoCAD.DatabaseServices;

using Autodesk.AutoCAD.EditorInput;

using Autodesk.AutoCAD.Runtime;

namespace AnnotationScaling


  public class Commands



    static public void addScale()


      Document doc =


      Database db = doc.Database;

      Editor ed = doc.Editor;



        ObjectContextManager cm =


        if (cm != null)


          // Now get the Annotation Scaling context collection


          ObjectContextCollection occ =


          if (occ != null)


            // Create a brand new scale context

            AnnotationScale asc = new AnnotationScale();

            asc.Name = "MyScale 1:28";

            asc.PaperUnits = 1;

            asc.DrawingUnits = 28;

            // Add it to the drawing's context collection





      catch (System.Exception ex)







Here's the new annotation scale, selected manually in the Property Palette after running the code:


In the next post we'll look at what it takes to make an object annotative programmatically, by setting its annotative property and annotation scale.


TrackBack URL for this entry:

Listed below are links to weblogs that reference Adding a new annotation scale in AutoCAD using .NET:

blog comments powered by Disqus


10 Random Posts