hexagon logo

Saving Pdf and Csv reports without prompting the user

Currently I am trying to write a C# app that will run a PCDmis program and then save the reports with specific names, in a specific folder based on some inputs from another source. I found an example of what I'm trying to do but it involves changing the prg file directly and I was wondering if I can do the same thing in C#?

I found this code from from 2021 but it's an embedded script.

GROUP_PRINT_COMMANDS=GROUP/SHOWALLPARAMS=YES
ASSIGN/NUMOOT=GETPROGRAMINFO("NUMOOT")
ASSIGN/PROG_NAME=GETPROGRAMINFO ("PARTNAME")
ASSIGN/DATE=STR(SYSTEMDATE ("dMMMyyyy"))
ASSIGN/TIME=STR(SYSTEMTIME ("HHmmss"))
ASSIGN/REJECT="____REJECT____"
IF/NUMOOT=="0"
ASSIGN/REPORT_NAME="O:\\CMM PROGRAMS\\CMM_PDF_PC DMIS\\AG0OFFLINETEST\\"+PROG_NAME+"__"+VAR_SERIAL_ NUMBER+"__"+VAR_RUNNUMBER+"__"+DATE+"__"+TIME+"__. PDF"
END_IF/
ELSE/
ASSIGN/REPORT_NAME="O:\\CMM PROGRAMS\\CMM_PDF_PC DMIS\\AG0OFFLINETEST\\"+PROG_NAME+"__"+VAR_SERIAL_ NUMBER+"__"+VAR_RUNNUMBER+"__"+DATE+"__"+TIME+"__" +REJECT+".PDF"
END_ELSE/
PRINT/REPORT,EXEC MODE=END,$
TO_FILE=ON,AUTO=1,AUTO OPEN=OFF,$
TO_PRINTER=OFF,COPIES=1,$
TO_DMIS_REPORT=OFF,FILE_OPTION=OVERWRITE,FILENAME= [B]REPORT_NAME[/B],$
REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMENSIONS=NO,$
TO_EXCEL=OFF,$
PREVIOUS_RUNS=KEEP_INSTANCES
ENDGROUP/ID=GROUP_PRINT_COMMANDS
Parents
  • yes you can add this pcDmis-code by an external programm.
    You just have to keep in mind that you can't do this while a measurement routine is running.

    with an open pcDMIS routine you can click "file->export->basic". There you get a whole measurement routine as basic code,
    means a general idea how to add pcDMIS-commands with an external programm.

    the help file for the pcDMIS Object Library is also certainly helpful:
    https://docs.hexagonmi.com/pcdmis/2021.1/en/helpcenter/mergedProjects/automationobjects/webframe.html
  • "file->export->basic" whoa!! That's a really useful trick. Thank you so much! I have use the object hierarchy before but sometimes it's not clear to me how to actually write code using it. I have already figure out how to add Tracefields and values before the program runs so I am hoping it will be something similar and I can add this code before the program runs. Thus far my use cases are adding metadata before the program runs and knowing at runtime where the file is going to be saved based on that metadata. Hopefully, I won't have to mess with anything while the program is running. Does the print command need to be the last thing to avoid interfering with the program run?
Reply
  • "file->export->basic" whoa!! That's a really useful trick. Thank you so much! I have use the object hierarchy before but sometimes it's not clear to me how to actually write code using it. I have already figure out how to add Tracefields and values before the program runs so I am hoping it will be something similar and I can add this code before the program runs. Thus far my use cases are adding metadata before the program runs and knowing at runtime where the file is going to be saved based on that metadata. Hopefully, I won't have to mess with anything while the program is running. Does the print command need to be the last thing to avoid interfering with the program run?
Children
No Data