1 Reply Latest reply on May 25, 2015 3:46 AM by fsengul

    How to Register MGCPCB Command Class In C#


      C#code_Command.jpgHello All,


                      I want to register MGCPCB Command Class for Handling mouse events from Expedition PCB in C# Code for event(OnMouseDrag).Kindly help me in registering and using Command class while I was registering using the below code I am getting COM register error.Please find the snapshot C# code below.




      Thanks & Regards,





        • 1. Re: How to Register MGCPCB Command Class In C#

          Hi, I even don't know where to begin, but you got all this wrong.


          If you handle a pcb document, you need to use the MGCPCB.Document class. The MGCPCB.Command is unrelated of any of your code.

          Also you have run licensing ritual by using MGCPCBAutomationLicensing.Application class. You have to create a token by the licensing application and you have to validate your pcb document by this token.


          I don't have the exact codes right now, but it should be like this:


          MGCPCB.Document pcbDoc = pcbApp.ActiveDocument;

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

          int key = pcbDoc.Validate(0);

          int token = _licApp.GetToken(key);





               //Do something right here





          Also, I strongly encrouge you to define your Document hooks after the validation ritual.





          Edit: Before I forget, If you don't know how to define pcbApp, it can be MGCPCB.Application or MGCPCB.ExpeditionPCBApplication.

          You can connect the exact applicaton with Marshal.GetActiveObject("MGCPCB.ExpeditionPCBApplication") or by using ROT (Running object Table)