Kean Walmsley

July 2009

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 31  

Twitter Updates

    follow me on Twitter



    « Getting the list of .NET-defined commands in AutoCAD | Main | Closing all open AutoCAD documents from a .NET application »

    March 16, 2007

    TrackBack

    TrackBack URL for this entry:
    http://www.typepad.com/services/trackback/6a00d83452464869e200d83523aee569e2

    Listed below are links to weblogs that reference Showing AutoCAD's hatch dialog from a .NET application:

    Comments

    Dear Kean
    Thanks again for an example
    it worked like a charm
    Here is VB.NET version I used

    [Code deleted by Kean at the request of Fatty]

    Oops...
    the code uploaded incorrectly
    remove it please

    Oleg

    Kean,

    Is there .Net interface for autocad command "DrawOrder"? For example: after solid-hatch a polyline, need to reorder polyline and hatch, how to make it happen using .NET? Thanks!

    Limin,

    The short answer is that it should be possible, using Autodesk.AutoCAD.DatabaseServices.DrawOrderTable.

    When I have some time I'll take a look into creating some sample code. In this case do you want to put the hatch behind the boundary? They don't typically intersect, so that change won't be very visible... unless you mean they need to be reordered relative to other entities.

    Kean, thanks for the quick response.

    Actually it's not only pline boundary. I have some furniture inside that polyline. So after running the hatch, I want them behind hatch. When you start working on draworder example, can you also include some code add xdata? I have tried hatch.XData.add(ResultBuffer), it always retruns error like following:

    System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.

    Have a great trip to China. I have some good friends in Beijing, if you need some help, please let me know.

    I've created a new post on this:

    http://through-the-interface.typepad.com/through_the_interface/2007/03/manipulating_th.html

    Regarding the XData issue... it's not specifically relevant to the topic, so I've left it off. There are two likely reasons for your error: either the Registered Appication has not been added properly, or the list of typed values you're passing in via the ResultBuffer is malformed, in some way.

    Thanks for your kind offer, by the way. My Autodesk colleagues in Beijing have been incredibly welcoming and helpful, but I'll certainly let you know if I need additional help.

    This example doesn't work on Autocad 2009. Can I use this method to show hatch dialog with Autocad 2009 and vb.net 2008?

    It worked fine for me with AutoCAD 2009.

    Kean

    Hi Kean,

    I have been attempting to follow the same path for showing the text style dialog. I can get the Dialog to show but it doesn't initialise properly. Any pointers gratefully received.

    Imports Autodesk.AutoCAD.ApplicationServices
    Imports Autodesk.AutoCAD.Runtime

    Namespace TextStyleDialogTest

    Public Class Commands
    Private Declare Auto Sub acedTextStyleDialog2006 Lib "acad.exe" Alias "?invokeTextStyleDialog@@YAXPAVAcDbDatabase@@PAV?$CStringT@DV?$StrTraitMFC@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@@Z" (ByVal AcadDatabase As IntPtr, ByVal StyleName As String)
    Private Declare Auto Sub acedTextStyleDialog2007 Lib "acad.exe" Alias "?invokeTextStyleDialog@@YAXPAVAcDbDatabase@@PAV?$CStringT@_WV?$StrTraitMFC_DLL@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@@Z" (ByVal AcadDatabase As IntPtr, ByVal StyleName As String)


    Public Sub ShowTextStyleDialog()
    Dim db As Autodesk.AutoCAD.DatabaseServices.Database
    db = Application.DocumentManager.MdiActiveDocument.Database
    If Autodesk.AutoCAD.ApplicationServices.Application.Version.Major > 16 Then
    acedTextStyleDialog2007(db.UnmanagedObject, "Standard")
    Else
    acedTextStyleDialog2006(db.UnmanagedObject, "Standard")
    End If

    End Sub

    End Class

    End Namespace

    Thanks

    Adam

    Hi Adam,

    Sorry - nothing immediately obvious springs to mind.

    I suggest posting your question via ADN, if you're a member, of otherwise the AutoCAD .NET Discussion Group.

    Regards,

    Kean

    Hi Kean,

    Thanks for the speedy reply.

    I tried ADN and was given pointers to either Send command or recreating the dialog in .NET.
    Fine, but as was so near with InvokeTextStyleDialog and you obviously have coerced AutoCAD with other dialogs I thought I would post just in case it was something obvious :-)

    I will try the .NET forums.

    Thanks

    Adam

    Hi Adam,

    OK, I just unmangled the name using DependencyWalker, and see the signature is more complex than you thought:

    void invokeTextStyleDialog(class AcDbDatabase *,class ATL::CStringT<wchar_t,class StrTraitMFC_DLL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > *)

    I think the chances of calling this unpublished function via P/Invoke are slim to none, I'm afraid. And much closer to none than slim, speaking frankly. At least it's not something I'd attempt, personally.

    Regards,

    Kean

    Hi Kean,

    No problem - I thought I was close but obviously not :-)
    Still I learnt today that you can Undecorate a name in Dependency Walker which makes it all worthwhile.

    Thanks again,

    Adam

    Verify your Comment

    Previewing your Comment

    This is only a preview. Your comment has not yet been posted.

    Working...
    Your comment could not be posted. Error type:
    Your comment has been posted. Post another comment

    The letters and numbers you entered did not match the image. Please try again.

    As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

    Having trouble reading this image? View an alternate.

    Working...

    Post a comment

    Feed & Share

    Search