hexagon logo

Get the information from the program visible in Command Mode via VB or C#?

I'm specifically interested in the date and time.​


Attached Files
  • hi,

    this is the time and date of the respective PC / System



    pcDMIS commands
      ASSIGN/V1=GETPROGRAMINFO("DATE​")
      ASSIGN/V2=GETPROGRAMINFO("TIME​")
    



    VBA commands
    Dim MyTime
    MyTime = Time ' Return current system time.
    
    Dim MyDate
    MyDate = Date ' MyDate contains the current system date.
    
    Dim Today
    Today = Now ' Assign current system date and time.
    

  • Unfortunately, one of the requirements of my project is that I can't change the programs themselves. In my tests I see those values updating when the program is done executing. I have access to the PartProgram object in my code but I can't tell if the existing values are accessible or not via the PCDLRN interfaces. When a report print is triggered I want to be able to get the existing date and time values from the part program.

    Triggers when a report is printed:

    public void OnReportPrintStart(PCDLRN.PartProgram PartProg)
  • Well, I haven't had a chance to try this myself using a delegate. Here is an example Pseudo code.

    class Program
    {
        // Define the delegate and event
        public delegate void OnReportPrintStartDelegate(PartProgram PartProg, DateTime eventDateTime);
        public event OnReportPrintStartDelegate OnReportPrintStart;
    
        static void Main(string[] args)
        {
            // Your main program code here...
            dynamic App = Activator.CreateInstance(Type.GetTypeFromProgID("Pcdlrn.Application"));
            dynamic PartProg = App.ActivePartProgram;
    
            // Raise the event and pass the current date and time as an argument
            OnReportPrintStart?.Invoke(PartProg, DateTime.Now);
        }
    }​​
    
  • Thanks again for your help! After digging in a little further I think I misunderstood what that time actually represents. It seems like it gets updated anytime you open or execute the program and then the report header always shows the time that the report was printed. I don't think that will work for my purposes.
  • Yes, your correct. I use the ASSIGN/VAR_SYSTEMDATE=STR(SYSTEMDATE("MM/dd/yyyy")) to get the date on the report using a Trace Field. This way the date that the part was measured on will not change when the measurement routine was automatically saved per serial number. When the saved per serial number measurement routine is opened the report date will still show the date that the part was measured on.

    Maybe use the system date and time when an event is triggered.