m.soucek

C# / COM connection to Expedition events blocks parts placement

Discussion created by m.soucek on Aug 23, 2010
Latest reply on Sep 26, 2010 by m.soucek

Hello,

 

I tried to make my improvement to Display control in C#, so more layers will automatically change their visibility when I will change the route working layer ( e.g.  solder mask, paste mask etc. )

This is " the body" of the program.

Problem is, that even with that nothing-doing event attached to Expedition, You cannot place parts.

You pick up a part with mouse, but You can not place it back to PCB - it still holds on cursor.

After closing the C# program, it works again normally.

If You add a line which removes the delegate after it is assignet, it works OK too.

 

Any ideas ?

I used C# 2008 and expedition 2007.8

Has anybody tested this event-handling with other language and COM ( no VBscript - it works, but has other problems ) ?

 

public partial class FormAutoswitch : Form

{

MGCPCB.IMGCPCBApplication pcbApp;

MGCPCB.Document pcbBrd;

 

private MGCPCB.Document GetLicensedDoc(MGCPCB.Document doc)

{

MGCPCBAutomationLicensing.Application licserver = new MGCPCBAutomationLicensing.Application();

 

int key = doc.Validate(0);

 

int token = licserver.GetToken(key);

doc.Validate(token);

 

return doc;

}

 

public FormAutoswitch()

{

InitializeComponent();

}

 

private void Form1_Load(object sender, EventArgs e)

{

pcbApp = (MGCPCB.ExpeditionPCBApplication)Marshal.GetActiveObject("MGCPCB.ExpeditionPCBApplication");

pcbBrd = GetLicensedDoc(pcbApp.ActiveDocument);

pcbBrd.OnActiveRouteLayerChange += new _IMGCPCBDocumentEvents_OnActiveRouteLayerChangeEventHandler(pcbBrd_OnActiveRouteLayerChange);

 

}

 

 

 

 

 

void pcbBrd_OnActiveRouteLayerChange(int Layer)

{

// do something here

}

}

 

 

 

 

 

 

Outcomes