Problem with the Publish command when called within VB.NET.

Discussion in 'AutoCAD' started by Paul Thompson, Feb 2, 2004.

  1. I have noticed a few other postings regarding this problem, however, I have not been able to find a solution yet. When I try running the publish command from within a VB.NET application I get the following FATAL ERROR: Unhandled Access Violation Reading 0x4caf778 Exception at 62d2e8aah.

    Here are the lines that cause the problem:

    strCommand = "(command " & Chr(34) & "-publish" & Chr(34) & " " & Chr(34) & "C:/temp/A00214.dsd" & Chr(34) & ")" & Chr(13)
    objAcadDoc.SendCommand(strCommand)

    If I break right before this call and try running the exact same command from the AutoCAD command prompt, everything works fine.


    Since I havn't had any luck with the SendCommand method, I'm also trying to implement the WinAPI SendMessage method. If anyone can post an example of how I would implement the SendMessage method from VB.NET it would help a lot.

    Here is what I have so far with the SendMessage method. This doesn't error on me, instead nothing happens at all.

    <DllImport("user32.dll", EntryPoint:="SendMessageA", _
    SetLastError:=True, CharSet:=CharSet.Unicode, _
    ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _
    Public Shared Function SendMessageA(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
    End Function

    <DllImport("user32.dll", EntryPoint:="FindWindowA", _
    SetLastError:=True, CharSet:=CharSet.Unicode, _
    ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _
    Public Shared Function FindWindowA(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    End Function

    Public Function SendACADCommand(ByVal strCommand As String, ByVal objAcadDoc As AutoCAD.AcadDocument) As Boolean
    'remeber that strCommand = "(command " & Chr(34) & "-publish" & Chr(34) & " " & Chr(34) & "C:/temp/A00214.dsd" & Chr(34) & ")" & Chr(13)
    Const WM_COPYDATA = &H4A
    Dim Hwnd As Long = FindWindowA(vbNullString, objAcadDoc.Name)

    SendMessageA(Hwnd, WM_COPYDATA, Hwnd, strCommand)
    End Function


    Thanks,

    Paul Thompson
    Continental Imaging Products

    (403)541-2545
     
    Paul Thompson, Feb 2, 2004
    #1
  2. Paul Thompson

    peterw Guest

    I struggled with this in VBA last summer.
    My solution was to run '-publish' fron lisp.
    You will not get any of these error meassages.
    My investigation from other newsgroups is there is an autodesk problem here.
    This means to automate the publish command I must
    build the 'dsd' from within lisp. this is difficult but not impossible.
     
    peterw, Feb 4, 2004
    #2
  3. I have had success running the publish command from LISP as well.
    Unfortunatly if I try loading and running my lisp from inside VB, I still
    get this error. Only when I run the LISP from the command line do I get it
    to work. Have you been able to get the LISP to work from inside VB or just
    from the command line.

    Thanks,

    Paul.
     
    Paul Thompson, Feb 4, 2004
    #3
  4. I finally figured out a way around this issue. First I build all of my .dsd
    files and a master LISP file from within VB.NET. The master LISP file
    contains a seperate publish line for each .dsd file. I than use the Shell
    command in VB.NET to call acad.exe with the /b argument. The script that I
    call using the /b option will (1) load my new master LISP file, (2) run my
    new master LISP program to publish all of my .dwf files, and (3) quit to
    close down acad.exe. After the Shell command is finished executing I clean
    up all of the .dsd and .csv files and the master LISP file. I can also check
    out all of the .csv log files that were created during publish to find any
    problem files.
     
    Paul Thompson, Feb 4, 2004
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.