AnsweredAssumed Answered

C# event DestroyNotify2 for drawings

Question asked by Paco Poche on May 30, 2018
Latest reply on Jun 1, 2018 by Paco Poche

Hi,

 

I am writting an addin in C# for Solidworks 2017 and I cannot find an example of the file EventHandling.cs online so I wrote one.

But I got a mistake I cannot solve

 

internal class DrawingEventHandler : DocumentEventHandler
{
    private DrawingDoc drawingDoc;

    public DrawingEventHandler(ModelDoc2 modDoc, SwAddin swAddin) : base(modDoc, swAddin)
    {
        this.drawingDoc = (DrawingDoc)sw_model;
    }

    override public bool AttachEventHandlers()
    {
        drawingDoc.DestroyNotify2 += new DDrawingDocEvents_DestroyNotify2EventHandler(DrawingDoc_DestroyNotify);

        return true;
    }

    override public bool DetachEventHandlers()
    {
        drawingDoc.DestroyNotify2 -= new DDrawingDocEvents_DestroyNotify2EventHandler(DrawingDoc_DestroyNotify);

        sw_swaddin.DetachModelEventHandler(sw_model);
        return true;
    }

    public int DrawingDoc_DestroyNotify()
    {
        DetachEventHandlers();
        return 0;
    }
}

 

Error    CS0123    No overload for 'DrawingDoc_DestroyNotify' matches delegate 'DDrawingDocEvents_DestroyNotify2EventHandler'

Error    CS0123    No overload for 'DrawingDoc_DestroyNotify' matches delegate 'DDrawingDocEvents_DestroyNotify2EventHandler'

 

it works with the event DestroyNotify but it now obselete and replaced by DestroyNotify2

 

Cheers,

 

Hope this helps you out..

 

Paco

Outcomes