.NET

Reply
Member
Alexey_Terno
Posts: 4
Registered: ‎05-18-2011
Message 1 of 3 (272 Views)
Accepted Solution

Hatch dialog box

272 Views, 2 Replies
10-28-2013 12:57 PM

Is it possible to show hatch dialog box using .NET?

I have found one old issue (link) but it does not work with AutoCAD 2014.

Hi,

 

Please try with this code

There is a commnet from MathewWebber in the same link where you find the code.

 

 

Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.EditorInput
Imports System.Runtime.InteropServices
Imports System
Namespace HatchDialogTest
Public Class Commands
Private Declare Auto Function acedHatchPalletteDialog _
Lib "acad.exe" _
Alias "?acedHatchPalletteDialog@@YA_NPEB_W_NAEAPEA_W@Z" _
(ByVal currentPattern As String, _
ByVal showcustom As Boolean, _
ByRef newpattern As IntPtr) As Boolean
<CommandMethod("SHD")> _
Public Sub ShowHatchDialog()
Dim sHatchType As String = "ANGLE"
Dim ptr As IntPtr
Dim bRet As Boolean = _
acedHatchPalletteDialog(sHatchType, _
True, ptr)
If bRet Then
Dim sNewHatchType As String = _
Marshal.PtrToStringAuto(ptr)
If sNewHatchType.ToString.Length > 0 Then
Dim ed As Editor
ed = _
Application.DocumentManager.MdiActiveDocument.Editor
ed.WriteMessage( _
vbLf + "Hatch type selected: " + sNewHatchType)
End If
End If
End Sub
End Class
End Namespace

 

Valued Mentor
Ajilal.Vijayan
Posts: 449
Registered: ‎01-12-2008
Message 2 of 3 (246 Views)

Re: Hatch dialog box

10-28-2013 11:09 PM in reply to: Alexey_Terno

Hi,

 

Please try with this code

There is a commnet from MathewWebber in the same link where you find the code.

 

 

Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.EditorInput
Imports System.Runtime.InteropServices
Imports System

Namespace HatchDialogTest

    Public Class Commands

        Private Declare Auto Function acedHatchPalletteDialog _
        Lib "acad.exe" _
        Alias "?acedHatchPalletteDialog@@YA_NPEB_W_NAEAPEA_W@Z" _
        (ByVal currentPattern As String, _
        ByVal showcustom As Boolean, _
        ByRef newpattern As IntPtr) As Boolean

        <CommandMethod("SHD")> _
        Public Sub ShowHatchDialog()

            Dim sHatchType As String = "ANGLE"
            Dim ptr As IntPtr
            Dim bRet As Boolean = _
              acedHatchPalletteDialog(sHatchType, _
                True, ptr)
            If bRet Then
                Dim sNewHatchType As String = _
                  Marshal.PtrToStringAuto(ptr)
                If sNewHatchType.ToString.Length > 0 Then
                    Dim ed As Editor
                    ed = _
                      Application.DocumentManager.MdiActiveDocument.Editor
                    ed.WriteMessage( _
                      vbLf + "Hatch type selected: " + sNewHatchType)
                End If
            End If

        End Sub

    End Class

End Namespace

 

Member
Alexey_Terno
Posts: 4
Registered: ‎05-18-2011
Message 3 of 3 (208 Views)

Re: Hatch dialog box

10-30-2013 01:50 PM in reply to: Ajilal.Vijayan
Yes - it's works!!!
Thanks a lot!
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.