AutoCAD 2008 - new .NET samples

In the last post we looked at the new ObjectARX samples for AutoCAD 2008, while today we're looking at the .NET samples. In the next post we'll look at the other new APIs available with AutoCAD 2008.

With the exception of custom objects, .NET now includes essentially all the functionality available in ObjectARX. While the ObjectARX samples are a good reference for .NET programmers, we've also bolstered our collection of .NET samples.

Unfortunately, we were unable to add full .NET documentation for this release, but rest assured that our Technical Publications team is working hard on it. In the meantime, please do let me know of your interim documentation requirements, and we'll try to post something via this blog.

CUISamp

A little know fact is that the .NET CUI API does not actually depend on AutoCAD, so it can be accessed when AutoCAD itself isn't running. This means you can use it directly from your installer. We've reworked the CUISamp sample to better demonstrate how your application can add its own CUI entries at install time and remove them again during uninstallation.

The CUISamp sample itself remains an AutoCAD add-in, but demonstrates these concepts through the following added functionality:

  • Run once configuration โ€“ The CUI is updated the first time your application loads into AutoCAD. Subsequent loads will leave the CUI untouched.
  • Forced CUI state โ€“ Removes and rebuilds the workspace to a default setting.
  • Removal โ€“ Removes all the CUI elements added by the sample, as you would do during uninstallation.

The CUI API also includes new support for the AutoCAD 'dashboard' โ€“ a feature not demonstrated in the sample. Check out the 'Customization' namespace in our .NET API for details of those classes.

Managed_SurfaceHelix and ManagedRender

Managed_SurfaceHelix is a direct port of the ObjectARX Surface_Helix sample to .NET, and ManagedRender does the same for the Render sample.

Note: The ObjectARX Render sample has been enhanced this year. Those enhancements are not yet reflected in the managed sample.

SimpleSquare

SimpleSquare is actually both an an ObjectARX and a .NET sample, in that it demonstrates how to expose a simple ObjectARX custom entity to .NET through a managed C++ wrapper. This is clearly of great interest of developers who wish to use .NET wherever possible, but still require the use of custom objects in their application.

We also demonstrate how to generate .NET events from the custom entity, and how to consume them in a managed .NET application; and how to jig the entity from .NET.

Those of you who are interested in this topic and have access to the ADN site will find this whitepaper on Managed Wrappers to be helpful.

16 responses to “AutoCAD 2008 - new .NET samples”

  1. Hi,Kean
    I noticed that there is a new namespace in AutoCAD 2008:ComponentModel.
    Can you say something about this namespace?
    Thanks!

  2. Great, managed C++ wrappers could be very interesting.

    The problem with that is when the custom object class/data is too complex and frequently updated. It's a pain the keep the wrapper syncronized with the C++ code.

    Maybe some macros could automate this task but it won't help too much once the method's parameters may vary a lot.

    I'm not able to think now about anything else to do this better than by hand. Maybe you guys from Autodesk can create a pattern or wizard to do that.

    In fact we are talking about how to fill the lack of not being able to create custom objects inside .NET API. The rest of the unmanaged C++ API will be covered soon by .NET wrappers (guess we are almost covering 90% of ObjectARX API except the custom object part). I don't know much of Autodesk strategy about migration of the AutoCAD core to .NET but maybe this will happen soon.

    I'm just concerned about the great number of wrappers like COM and, most recently, .NET created just to expose the C++ core to other APIs.

    Just to think about... ๐Ÿ™‚

  3. Hey Kean,
    I'm glad to see the updated CUISamp. I spent a bit of time working on what I wanted to be a full stand alone CUI installation application before Bill Z. and I discussed some of the limitations of that approach.

  4. Hi csharpbird,

    Autodesk.AutoCAD.ComponentModel appears to be related to the Data Extraction feature... I'll add it to my list to research and cover in a future post.

    Regards,

    Kean

  5. Udhayamoorthy Avatar

    Hi,

    we are developing an autoprint .net windows application, to print the autocad files automatically. Before printing we need to set customize the footer part and put user specific information.

    I tried a lot using AutoCAD APIs to access footer part of the document, no luck.

    could you please give any idea or workarounds?....

  6. Hi my friend
    I would like to draw a solid3d in one viewport with c#.net (AutoCAD .NET)
    It is like command SOLDRAW or SOLPROF.
    Do you know to do that?
    Where could i find a good documentation about AutoCAD .NET?

    Thanks a lot my friend.

  7. Hi Luis,

    I haven't done it myself, but you might try creating a Section object and calling GenerateSectionGeometry() with your Solid3d.

    The best place to get documentation on AutoCAD .NET is in the ObjectARX SDK, otherwise you might try searching the AutoCAD .NET Discussion Group or this blog.

    Cheers,

    Kean

  8. Thanks very much Kean, I will try to do that.

    Cheers. ๐Ÿ™‚

    Luizo

  9. Sorry Kean, but that not generate entitys, like a SOLDRAW and SOLPROF. ๐Ÿ™ Ok?
    Thanks,
    Luizoo

  10. If you know C++ you might check out the HLR API in the Utils directory of the ObjectARX SDK.

    Kean

  11. Thanks, but C++ ..... It's very complicate to me yet!.....

    I have done good somethigs in AutopLisp and VB (ActiveX) but ARX ....

    Ok Dean, thanks for your attention.

    Cheers. ๐Ÿ™‚

  12. Hi Kean, all right?
    On the code below i get to set a Ucs active, but the view do not keep like it was.
    [CommandMethod("myucs")]
    public void myucs()
    {
    Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
    Database db1 = HostApplicationServices.WorkingDatabase;
    Transaction trans = db1.TransactionManager.StartTransaction();

    ViewportTable viewTbl = (ViewportTable)trans.GetObject(db1.ViewportTableId, OpenMode.ForWrite);
    ViewportTableRecord viewTblRec;
    SymbolTableEnumerator symEnum = viewTbl.GetEnumerator();

    if (db1.TileMode == false)
    {
    db1.TileMode = true;
    }

    symEnum.Reset();

    while (symEnum.MoveNext())
    {
    viewTblRec = (ViewportTableRecord)symEnum.Current.GetObject(OpenMode.ForWrite);
    if (viewTblRec.Name == "*Active")
    {
    viewTblRec.SetUcs(new Point3d(100, 100, 0), new Vector3d(1, 1, 0), new Vector3d(-1, 1, 0));
    ed.UpdateTiledViewportsFromDatabase();
    }
    }

    trans.Commit();
    trans.Dispose();

    }
    I would like to rotate the ucs without change the view. Do you know how i can do that?

    Thanks.

  13. Kean, I would like to know if exist an Extension Dictionary data that behaves like a 1011 Xdata code. The 1011 Xdata chance when we move, rotate, etc the object. Is there an Extension Dictionary data that behaves like this? I have tried to find but i haven't got it yet!...
    Could you help me?

    Cherrs.

    Luizoo

  14. Hi Luiz,

    Please submit your question via the discussion groups or the ADN website (if you're a member).

    Regards,

    Kean

  15. Hi Kean,

    Is there a way to reference a specific sheet within an Excel workbook(spreadsheet) when creating a datalink to an AutoCAD table using vb.NET? For example, I want to create three tables on my drawing. The three sheets within the Excel workbook(spreadsheet) contains the data for each table.

    Thank you for your help.

  16. Hi Mark,

    Sorry, I don't know off the top of my head, and don't have time to research this.

    Please post your question to the ADN team, if you're a member, of to the AutoCAD .NET Discussion Group.

    Regards,

    Kean

Leave a Reply to Luiz Cancel reply

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