One of the services ADN provides its members is representation of their wishes with Autodesk's Engineering teams, helping influence product direction. For instance, each year we run an API wishlist survey for a number of our products (this year it was AutoCAD, ADT, Revit, Inventor, and Map 3D). An online survey for each product gets filled out by ADN members, allowing them to provide targeted feedback that goes straight to the appropriate Product Management contacts.

I wanted to talk about an item that has featured highly in recent AutoCAD API surveys – the exposure of custom objects through .NET. The reason I wanted to broach this subject in particular is that it has been high on the wishlist for a few releases, and I dislike the fact we haven't yet been able to address it. So part of this entry explains the background to where we are today (I really don't want to call it an apology 🙂 and the rest asks you to let us know – whether by email or by comments to this blog – what it is you want us to do to address the situation. Unfortunately I can't commit to how and when it will be addressed, but I can guarantee that the feedback you provide will be compiled and brought to AutoCAD Engineering, to help influence the direction that's taken.

OK, so let's start with some background...

Custom objects were introduced back in Release 13. The mechanism was a core part of ARX, the AutoCAD Runtime eXtension (which later became ObjectARX), and allowed both Autodesk and external developers to implement new functionality inside AutoCAD without modifying the core product. It was pretty revolutionary at the time – it allowed developers deep access into AutoCAD, resulting in very tight integrations with the platform. Autodesk's AutoCAD-based vertical applications (such as ADT, AutoCAD Mechanical, Map 3D, Civil 3D etc.) and many other complex 3rd party products would not have been possible without custom objects.

However powerful this mechanism has proven to be, there are downsides:

  • The effort required to implement a fully-fledged custom object is high. Many different virtual functions need implementing and the entities need testing in many different scenarios – open, save, wblock, undo, explode, move, copy, scale, object snaps, grip stretching, trim, extend, refedit, audit, etc. etc.
  • There needs to be an Object Enabler or .DBX module for the object to be functional on someone else's system
    • This can be a problem for some customers – they would rather not depend on multiple providers to safeguard their data
  • Custom objects are a mix of custom data (stored in the DWG) and custom behaviour (defined by the .DBX module) – there's currently no way to have one without the other in ObjectARX
    • Many developers implementing custom objects only really need a subset of the functionality they get
    • For example, many only really need custom graphics and/or behaviour – they don't need to store large chunks of custom binary data

It would be technically relatively straightforward to expose ObjectARX's current custom object mechanism to a managed environment. Ultimately, though, this would not actually improve on the existing mechanism very much at all: the benefits from a developer's perspective would be around the use of VB.NET or C# to implement the various callbacks needed to define the data to be stored in the DWF & DXF formats and the behaviour of the objects when used inside AutoCAD. While it would allow developers to consolidate more of their development under a single .NET language, it would not reduce the number of callbacks that would need to be implemented, nor would it make the objects inherently easier to develop.

C++ is considered one of the more complicated programming languages to learn: requiring it for exposure of custom objects (which is the situation right now, mainly from a historical perspective), considerably reduces the audience for this technology. Now that may or may not be a bad thing, depending on your perspective: the complexity of the architecture makes it hard to do *anyway*, so having the additional hurdle of C++ getting in the way does naturally restrict it to people that are strongly motivated (enough to learn C++ or hire C++ programmers to get there).

So what's the right thing to do? Clearly we could just go ahead and expose the mechanism as it is today in ObjectARX. And yet here we are with a technology we know to be highly complex and difficult to implement, and an ideal opportunity to redesign it – enabling more people to harness it effectively at lower effort. The more favoured approach (at least from our perspective) would be to investigate further how better to meet developers' needs for enabling custom graphics/behaviour (a.k.a. stylization) in AutoCAD – in a way that could be supported technically for many releases to come.

Here are some of the questions that we have been asking ourselves, for instance...

  • What could be done to enable stylization without custom data being stored? Should this be implemented per class or per object instance?
  • Can we reduce the requirement to store custom binary data, perhaps by enabling data storage in XML fragments?
  • What (if anything) needs to be done to the existing Dynamic Blocks mechanism to meet developers' needs?

We did ask our ADN members a follow-up question during a previous API wishlist survey. Here are the results (respondents could select multiple options, hence the [response rate] numbers adding up to >100%):

  • Support for custom drawing of object instances. (i.e. stylization) [83%]
  • Support for custom transform on object instances. (ability to override how stretch, move etc. work on an instance by instance basis) [60%]
  • Support for custom grips on object instances. (ability to add or override grips on a specific line, for instance) [58%]
  • Support for custom copy on object instances. (ability to override how objects are copied on an instance by instance basis) [42%]

So... what do you think? If you care strongly about what Autodesk should do about this topic, post a comment to this blog or send me an email. As I expect this to generate quite a lot of responses (given the clear popularity of this item in our wishlist surveys), I apologise in advance if I don't manage to respond to each one.

22 responses to “Custom objects in .NET”

  1. Great news!
    Is it possible for ObjectARX 2007 to use the Custom objects in .NET?

  2. Unfortunately not: as we're still in the planning stages the earliest release we'd be likely to see .NET custom objects would be 2 releases after AutoCAD 2007. The point of this post is to start a dialogue around the approach that would best address developers' needs.

    Regards,

    Kean

  3. In the interim, it might be interesting to update the current custom object mechanism to use some .NET features (still staying with a C++/CLI implementation). As one specific example: replace the custom ARX type system with .NET's (ARX was never "upgraded" to C++ in this area).

    Another step would be to allow a "ref class" to be a custom object (again, only in C++/CLI).

    While such things don't specifically solve any of the problems you mention, it would allow more "stick time" to try out different ideas.

  4. Hmm... I’m not sure I understand the advantages of using the .NET type system (by this I assume you mean RTTI – RunTime Type Identification – please do say if you actually mean something else). As you’re well aware, we had to go our own way with ObjectARX, as it pre-dated RTTI’s inclusion in the C++ standard (and – probably more importantly – compiler support for it). For us to implement .NET’s RTTI it feels as though we’d have to provide it in parallel to the existing one, as purely unmanaged clients would presumably not be able to harness it. One concern would be how this would affect AutoCAD’s memory footprint (and impact performance).

    I’d certainly like to understand your suggestions better – please post a follow-up or email me directly.

    Thanks,

    Kean

  5. I can understand the notion of lowering the entry barrier, making simple tasks easier to implement and it may be true that many developers don't need the complete functionality of ObjectARX but just a subset of its features.

    On the other hand, at our company we really make heavy use of ObjectARX and I doubt there are many features we aren't using or even requiring.

    We have many custom entities which interact with and rely on each other. They store and manage custom information and specialized behaviour. They also interact with our databases and more.

    So for us, a .NET API to AutoCAD will have to support most of ObjectARX' functionality in order to be a viable alternative to ObjectARX. At least for any non-trivial applications.

    Will we be able to do as much with a .NET API?

    Of course, this doesn't have to be achieved in the same way as with ObjectARX, as it probably would be beneficial to make use of .NET features (like introspection/reflection which C++ doesn't have yet). Otherwise, what use would .NET be? 😉

    It's an interesting topic. Please keep us updated on thoughts and progress within the AutoCAD team, if possible. 😉

  6. Thanks for your comment, Stephan - it's good to hear from one of our heavier implementors of custom objects.

  7. How to create a wblock in VB.net

  8. Database.Wblock(ObjectId blockId)

    or

    Database.Wblock(ObjectIdCollection outObjIds,Point3d basePoint)

  9. Benjamin Weir Avatar

    I'm looking forward to being able to create custom objects in VB.Net. It'd be nice to work with the DB classes as templates and simply override a function or two to create a whole new drawing object to achive your goals, needs, wants.

  10. Hi Kean,

    I'm getting into trouble when invoking Database.Wblock(ObjectIdCollection outObjIds,Point3d basePoint).
    (after searching from google, I'm getting here)

    An exception "ePermanentlyErased" was threw.

    I don't know what's the paradigm when using Database.Wblock().

    following is my code snippet:

    BlockTableRecord origBTR = (BlockTableRecord)origTrans.GetObject(origBT[bkstr], OpenMode.ForRead);
    BlockTableRecordEnumerator origIT = origBTR.GetEnumerator();
    while (origIT.MoveNext())
    {
    Entity pEnt = (Entity)origTrans.GetObject(origIT.Current, OpenMode.ForRead);
    DBDictionary pDict = null;
    if (false == pEnt.ExtensionDictionary.IsNull)
    {
    pDict = (DBDictionary)origTrans.GetObject(pEnt.ExtensionDictionary, OpenMode.ForWrite);
    pDict.TreatElementsAsHard = true;
    }
    list.Add(pEnt.Id);
    }
    tmpDB = new Database(false, true);
    tmpDB = origDB.Wblock(list,Point3d.Origin);
    destDB.Insert(bkstr, tmpDB, true);
    origTrans.Commit();
    destTrans.Commit();

  11. Kean Walmsley Avatar

    I'd suggest committing your transaction earlier, and you can use foreach to loop through the entities in your BTR.

    If these suggestion don't help, please post your question to the AutoCAD .NET Discussion Group.

    Regards,

    Kean

  12. It's been a few releases since 2007. Any updates on custom objects in .Net. It is something I would love to have.

    Thanks

  13. We're working on it (although "it" isn't a direct exposure of the ability to define custom objects to .NET). I can't comment beyond that, right now.

    Kean

  14. Hi Kean, Is there anymore news about Custom Objects using .Net? Regards, Dale

  15. Hi Dale,

    We don't have plans to expose the ability to define custom objects to .NET: we believe that the vast majority of use cases are handled by the Overrule API, and the inherent complexity of implementing custom objects would not be lessened by exposing the C++ mechanism to .NET.

    People comfortable with this complexity can, of course, implement custom objects using C++ and expose COM or .NET interfaces for them to be used from other languages.

    Regards,

    Kean

  16. In other words: the ability "to implement custom objects" using .NET *is* the Overrule API.

    It provides all the capabilities but doesn't encourage (or allow) you to lock away your custom data in binary blobs that add a dependency on an object enabler.

    Kean

  17. Hello Kean,
    Is it possible for ObjectARX 2017 to use the Custom objects in .NET?

    1. Kean Walmsley Avatar

      There's been no change on that front.

      Kean

  18. Very useful information in this article! its really useful in asp.net web development services
    Will we be able to do as much with a .NET API?

  19. Thanks for the awesome share
    Hi we at Colan Infotech Private Limited , a company which is Situated in US and India, will provide you best service and our talented team will assure you best result and we are familiar with international markets, We work with customers in a wide variety of sectors. Our talented team can handle all the aspects of custom application development, we are the best among the dot net development companies in Chennai . asp .net web development company

    We have quite an extensive experience working with
    asp .net development services. we are the only
    asp.net web development company which offer custom services to a wide range of industries by exceeding our client’s expectations. You can even interact directly with the team regarding your project, just as you would with your in-house team. hire asp.net programmers to achieve your dream product.

    Custom application development company, asp.net development companies, asp .net web development company,Hire asp .net programmers,asp.net web development services,dot net development companies in chennai

  20. Subir Kumar Dutta Avatar
    Subir Kumar Dutta

    I got a drawing with Custom Entities and also got the Object Enablers. So now the entities show up in the drawing. Now is it possible to read the properties of the Custom Entities through .Net API ?

    My best guess is, the developer of the Custom Entity need to take care about exposing the properties so that those properties can be accessed by .Net API. Am I correct ? Now I don't have anything excepts the object enablers ( dbx ). How to proceed ?

    1. Correct - it's up to the OE provider to develop and give you the API DLL(s).

      Kean

Leave a Reply to J. Daniel Smith Cancel reply

Your email address will not be published. Required fields are marked *