hexagon logo

PC-DMIS event handler in Python

Hello,

Has anyone implemented PC-DMIS event handler in Python?

I tried both win32com.client.getevents and win32com.client.DispatchWithEvents, but I got the TypeError.
  • win32com.client.getevents
    TypeError: Objects of type 'CDispatch' can not be converted to Unicode solution
  • win32com.client.DispatchWithEvents
    TypeError: This COM object can not automate the makepy process - please run makepy manually for this object

The equivalant C# code is as follows.

Any of your reply is welcome.


Thanks and Best Regards,
Aki

using PCDLRN;

public PCDLRN.ApplicationObjectEvents pcdmisEvents;

namespace Automation
{
    /// <summary>
    /// An empty window that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainWindow : Window
    {
    
        private void main()
        {
            var objDmisApp = Type.GetTypeFromProgID("PCDLRN.Application");
            var objPCDMIS = Activator.CreateInstance(objDmisApp) as PCDLRN.Application;

            objPCDMIS.Visible = true;
            objPCDMIS.Maximize();
            objPCDMIS.ErrorDialogEnabled = 0;

            //Add events
            pcdmisEvents = objPCDMIS.ApplicationEvents;
            pcdmisEvents.OnStartExecution += pcdmisEvents_OnStartExecution;
            pcdmisEvents.OnEndExecution += pcdmisEvents_OnEndExecution;

           //TO DO
​
        }

        private void pcdmisEvents_OnStartExecution(PartProgram PartProg)
        {
            Debug.WriteLine("pcdmisEvents_OnStartExecution");
        }

        private void pcdmisEvents_OnEndExecution(PartProgram PartProg, int TerminationType)
        {
            Debug.WriteLine("pcdmisEvents_OnEndExecution");
        }
    }
}​
Parents
  • Not sure but I suspect unless you HAVE to use python for this then its probably going to be more trouble than its worth at the end of the day when you have to figure out the right python syntax and data types for all of the PC-DMIS function args... Curious to know what exactly you intend to do with this.
  • Thank you for your reply.

    I am simply enabling PC-DMIS loads an external program from a shared folder through command-line with some additional commands. It is not complicated program.
    The reason why I selected Python is that it does not require any specific development environment.

    It sounds like the event-handler is not suitable with Python. I will leave the status monitoring out-of-scope for the 1st stage, then implement it with C# after the detailed specifications are fixed.

    Any other information is also welcome!
Reply
  • Thank you for your reply.

    I am simply enabling PC-DMIS loads an external program from a shared folder through command-line with some additional commands. It is not complicated program.
    The reason why I selected Python is that it does not require any specific development environment.

    It sounds like the event-handler is not suitable with Python. I will leave the status monitoring out-of-scope for the 1st stage, then implement it with C# after the detailed specifications are fixed.

    Any other information is also welcome!
Children
No Data