Hi,
below I copied an pasted the script. It works fine for me, AutocAD gets
started and the debbugger connects to it and I can debug, It might be
that you have to tweak the time out a bit on your machine.
Simply open up a new module in you macro IDE and paste the code in
there.
I hope that solves your Problem.
Cheers,
Andy
Imports EnvDTE
Imports System.Diagnostics
Public Module AcadDebugAttach
Public Sub DebugAttach()
Try
Dim procId As Integer = StartAutoCAD()
'This time out gets us around the attaching issue
Dim timeOut As Integer = 20000'TWEAK ME
System.Threading.Thread.Sleep(timeOut)
AttachToAcad(procId)
Catch ex As System.Exception
MsgBox("An Error occured: " + ex.Message)
End Try
End Sub
Private Function StartAutoCAD() As Integer
'Dim strAcad As String = _
"C:\Programme\Autodesk Architectural Desktop 2004\acad.exe"
Dim strAcad As String = AcadPathFromReg()
Return Microsoft.VisualBasic.Shell(strAcad, _
AppWinStyle.NormalFocus, False)
End Function
Private Function AttachToAcad(ByVal procId As Integer) As Integer
Dim attached As Boolean = False
Dim proc As EnvDTE.Process
For Each proc In DTE.Debugger.LocalProcesses
If proc.ProcessID = procId Then
proc.Attach()
attached = True
Exit For
End If
Next
If Not attached Then
MsgBox("acad.exe is not running")
End If
Return attached
End Function
Private Function AcadPathFromReg() As String
Dim regKey As Microsoft.Win32.RegistryKey = _
Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\Autodesk _
\AutoCAD\R16.0\ACAD-204:409")
If regKey Is Nothing Then
Throw New System.Exception("Can't extract AutoCAD 2004 _
Path from registry")
End If
Return CType(regKey.GetValue("AcadLocation"), String) + _
"\acad.exe"
End Function
End Module
"Andrew Elmore" schrieb:
> I guess I'm haveing the same problem as you. I have read the add-in
> readme file and it still locks up.
>
> Andy
>
> "Andreas Müller"
wrote in message
> news:[email protected]...
> > "Andy Elmore" schrieb:
> >
> > > How come VS & Acad freezes when I call my command in autocad?
> > > I have settings set in the debug. Set my break point in VS. I
> > > press F5 and acad.exe runs. I then drop the .arx file into
> > > autocad. type my command "test" and they freeze up?
> > >
> > > Andy E
> > >
> > > "Joseph Pods" wrote in message
> > > news:[email protected]...
> > > > Yes there is one for MS VisualC++ IDE, it's in ObjectArx
> > > > Reference (arxref.chm).
> > > > Have you downloaded and installed ObjectArx SDK? If you have,
> > > > open up that CHM and on Index tab, type Debugging an ObjectARX
> > > > Application.
> > > >
> > > > Joseph
> > > >
> > > >
> > > > "Andy Elmore" wrote in message
> > > > news:[email protected]...
> > > > > Is there any docs on how to debug a arx program? Such as I
> > > > > would like to
> > > > step through my code and set break points.
> > > > >
> > > > > Andy E
> > > >
> > > >
> > >
> > This might be related to the problem that you can't Debug a locked
> > version of AutoCAD using F5. In te util section of the ARX SDK,
> > there is an AddIn for Visual Studio (and a short exxplanation
> > what happens) to solve this problem. It seems to work without a
> > problem. (For some reason, this addin never worked on my machine,
> > but it looks like I'm the only one where that happens :-(. If it
> > fails to work for you, come back here, I have a small VB script
> > that does the same thing) )
>