Through the Interface: Creating an AutoCAD Wipeout 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


« Getting the names of the colors in an AutoCAD color-book using .NET | Main | Launching AutoCAD from a .NET application »

December 12, 2007

Creating an AutoCAD Wipeout using .NET

This topic was suggested via a comment from Dale Bartlett on this post.

In AutoCAD 2008 an API was exposed for the Wipeout object. For those of you who aren't familiar with Wipeouts: this handy object was originally developed as part of the AutoCAD Express Tools, and has since been integrated into core AutoCAD. The implementation uses a raster image of the same colour as the drawing canvas to "wipe out" the graphics behind it (assuming it's nearer the front in terms of draw order relative to the entities being masked). This is the main reason the Wipeout class is derived from RasterImage in the managed API.

The RasterImage-based implementation was chosen at a time when True Color support was not available through AutoCAD's graphics interface (a.k.a. AcGi for the ObjectARX coders reading this). Since then it has been altogether possible to implement Wipeouts without using RasterImage: you can simply use the AcGi protocol to create the same effect. But that's history - once the Wipeout class became widely used it was unfeasible to change the implementation and introduce an incompatibility. On a design note: if the raster had been contained rather that derived from, the choice would have been simpler (an implementation detail, rather than something affecting the class hierarchy in AutoCAD). The design choice was probably due to the capabilities of the ObjectARX API at the time the object was originally developed - containment was inherently more complicated that derivation, back then. Anyway, I digress.

The below C# code shows how to create a Wipeout based on an array of points - in this case we simply make it square, from 0,0 to 100,100. The tricky part is to make sure we close the wipeout manually by specifying the first vertex again as the last point in the list - something Dale and I discovered independently when researching this.

using Autodesk.AutoCAD.Runtime;

using Autodesk.AutoCAD.ApplicationServices;

using Autodesk.AutoCAD.DatabaseServices;

using Autodesk.AutoCAD.Geometry;

namespace WipeoutApplication


  public class Commands



    public void CreateWipeout()


      Document doc =


      Database db = doc.Database;

      Transaction tr =


      using (tr)


        BlockTable bt =






        BlockTableRecord btr =






        Point2dCollection pts =

          new Point2dCollection(5);

        pts.Add(new Point2d(0.0, 0.0));

        pts.Add(new Point2d(100.0, 0.0));

        pts.Add(new Point2d(100.0, 100.0));

        pts.Add(new Point2d(0.0, 100.0));

        pts.Add(new Point2d(0.0, 0.0));

        Wipeout wo = new Wipeout();


        wo.SetFrom(pts, new Vector3d(0.0, 0.0, 0.1));


        tr.AddNewlyCreatedDBObject(wo, true);







TrackBack URL for this entry:

Listed below are links to weblogs that reference Creating an AutoCAD Wipeout using .NET:

blog comments powered by Disqus


10 Random Posts