• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    .NET

    Reply
    Contributor
    Posts: 21
    Registered: ‎12-18-2006

    Command not starting in debug

    196 Views, 4 Replies
    10-15-2012 11:03 AM

    I am writing a program in vb.net.

    I have a command.

    <CommandMethod("att2att")> _
        Public Sub att2att()
            Dim ed As Editor
            ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
            ed.WriteMessage(String.Format("{0} commande: att2att, maintenant disponible...", System.Environment.NewLine))
            Dim start As New FileSelect
            start.ShowDialog()

        End Sub

     

    In the debug mode, the att2att is not recognize.

    If I compile, netload and call the command, it works. Why is the command not recognize in debug mode?

    Please use plain text.
    *Expert Elite*
    Posts: 1,640
    Registered: ‎04-29-2006

    Re : Command not starting in debug

    10-16-2012 01:00 AM in reply to: Patrick.Fillion

    Salut,

     

    Si ça fonctionne avec NETLOAD c'est probablement que le problème ne vient pas du code mais de ce qui est automatiquement exécuté au lancement du débogage.

    Si rien n'a été explicitement fait pour que la dll soit chargée au démarrage d'AutoCAD (un script par exemple), elle ne sera pas automatiquement chargée (c'est le cas avec les AutoCAD .NET Wizards).

     

    Tu trouveras sur Augifr un tuto pour créer des modèles AutoCAD pour Visual Studio avec une méthode de chargement automatique de la dll via un script :

    http://augifr.ning.com/group/augi-france-developer-network-afdn/page/bibliotheque-afdn#.UH0UElHYf3Q

    Gilles Chanteau
    Please use plain text.
    *Expert Elite*
    Hallex
    Posts: 1,338
    Registered: ‎10-08-2008

    Re: Command not starting in debug

    10-16-2012 03:51 AM in reply to: Patrick.Fillion

    Try compile your project as follows:

     #region "Imports"
    '' your imports here
    
    #End Region
    
     <Assembly: Autodesk.AutoCAD.Runtime.CommandClass(GetType(MyProjectName.MyClass))> 
    
    Namespace MyProjectName
    
        Public Class MyClass
    
            <CommandMethod("att2att")> _
            Public Sub att2att()
    ' wrap your code in try-catch block
    Try
                Dim ed As Editor
                ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
                ed.WriteMessage(String.Format("{0} commande: att2att, maintenant disponible...", System.Environment.NewLine))
                Dim start As New FileSelect
                start.ShowDialog()
    Catch ex as System.Exception
    Msgbox(ex.message & vblf & ex.stacktrace)
    Finally
    ' do nothing or add informative message
    end Try
    
    End Sub
    
    end class
    
    End Namespace

     

    _____________________________________
    C6309D9E0751D165D0934D0621DFF27919
    Please use plain text.
    Contributor
    Posts: 21
    Registered: ‎12-18-2006

    Re: Command not starting in debug

    10-16-2012 05:36 AM in reply to: Patrick.Fillion

    Well, the problem is that in the debug, I do the netload but the att2att commande doesn't show. If I compile then run autocad and then netload the same dll, the att2att command is available...

     

    I really wish I could use the debugger... it will save me so much time. Thanks all for the help!

     

    That is kind of strange! I change my code as:

     

    #Region " Imports "

    Imports System.IO
    Imports Autodesk.AutoCAD.Interop

    Imports System.Runtime.InteropServices
    Imports System.Windows.Forms
    Imports Autodesk.AutoCAD.Runtime
    Imports Autodesk.AutoCAD.ApplicationServices
    Imports Autodesk.AutoCAD.DatabaseServices
    'Imports Autodesk.AutoCAD.PlottingServices
    Imports Autodesk.AutoCAD.EditorInput
    Imports Autodesk.AutoCAD.Geometry
    #End Region

     

    <Assembly: Autodesk.AutoCAD.Runtime.CommandClass(GetType(UpdCart.commandes))>

    Namespace UpdCart


        Public Class Commandes


            <CommandMethod("att2att")> _
            Public Sub att2att()



                Try
                    Dim ed As Editor
                    ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
                    ed.WriteMessage(String.Format("{0} commande: att2att, maintenant disponible...", System.Environment.NewLine))
                    Dim start As New FileSelect
                    start.ShowDialog()

                Catch ex As System.Exception
                    MessageBox.Show(ex.ToString, "System Exception")

                End Try



            End Sub

        End Class

    End Namespace

    Please use plain text.
    ADN Support Specialist
    Balaji_Ram
    Posts: 359
    Registered: ‎03-21-2011

    Re: Command not starting in debug

    10-23-2012 10:29 AM in reply to: Patrick.Fillion

    Hello Patrick,

     

    Are you referring to debugging by attaching to an running instance of AutoCAD to debug the .Net Plug-in ?

     

    If so, “Attach to Process” for debugging a .Net plugin is not recommended and the suggested way to debug a .Net plugin is to set AutoCAD as the external program and use F5.

     

    The reason for it is due to the use of fibers in AutoCAD which is being removed in the newer releases of AutoCAD.

    Hopefully this will not be a limitation in a future release of AutoCAD.

     

    You may try "Attach to Process" after setting the "NEXTFIBERWORLD" to 0 to disable the fibers in AutoCAD but it has some drawbacks such as the ribbon not responding. I havent tried this though.

     

     

     

     

     



    Balaji
    Developer Technical Services
    Autodesk Developer Network

    Please use plain text.