Jump to content

How can I use variables to name files/paths on PiWeb exports?


---
 Share

Recommended Posts

Running Calypso 2021 SP1.
In Calypso, I can set the output of the PDF reports that are generated using custom variables to determine the file name and folder structure. In "Resources > Name for Output Files > For All Measuremet Plans" I've got it set to basically "C:\Inspection Reports\Customer\Part Number\Part Number Serial Number Date.pdf", where the underlined are values pulled from the report header data. This works as expected and I've had no issues with it.

I'm being pushed to lean into PiWeb more in an effort to capture more data. I want to use the "Notes" field in the footer as well as the approve/reject functions. Where I'm running into a problem is keeping that data recorded. Currently I don't have a way to re-write the PDF in the same manner that Calypso creates it. How can I get PiWeb to change location and file names?

Here's where I've been so far. For reference, I'm using the default PiWeb "Standard Protocol", and editing the hyperlinked Actions from the control buttons on the top right of the header, far right icon (The one titled "export_pdf.png")

Default: Brings up a standard Save As dialog.
Change: Edit Hyperlink>Default Action>Export> Check "Set Filename" box, type filename test1.pdf.
Result: PDF named "test1.pdf" created at C:\Users\Public\Documents\ZEISS\CALYPSO 7.2 [old location]
Technically, this could work but is prone to entry error.

Change: Set Filename to ${Qdb.Measurement(14, -1)}.pdf This is the PiWeb variable for Incremental Part Number / Serial Number
Result: File SERIALNUM-1 is created at old location
Ok, so this is proof variables CAN be used in file names

Change: Set Filename to "C:\Users\ZEISS-CMM-DESKTOP\Test Folder\test1.pdf [new location]
Result: File "test1.pdf" is created in the new location.
Progress!

Change: Change: Set Filename to "C:\Users\ZEISS-CMM-DESKTOP\Test Folder\${Qdb.Measurement(14, -1)}.pdf
Result: File "${Qdb.Measurement(14, -1)}.pdf" is created at the new location.
Boo. I didn't want the variable name in plain text!

Where did I go wrong?
Link to comment
Share on other sites

I had some guessing stuff going on in this post, but I found the solution in the manual so I'm going to replace it. You need to double backslash everything if you're using PiWeb variables in the path. So in your example, what you want is

C:\\Users\\ZEISS-CMM-DESKTOP\\Test Folder\\${Qdb.Measurement(14, -1)}.pdf

This is on page 104.
Link to comment
Share on other sites

The PiWeb manual. For reasons only known to Zeiss, they didn't store it with all the other manuals. Instead it's in

C:\Program Files (x86)\Zeiss\Calypso whatever version you have\bin\PiWebReporting\manual.pdf
Link to comment
Share on other sites

  • 5 weeks later...
  • 5 months later...
Hi Greg,

In your original post your stated you were able to use header parameters as variables to define an output file path. I am trying to do the same thing, but it doesn't seem to be straight forward. What is the typed syntax when you include a header parameter in the file path portion?
Link to comment
Share on other sites

You can use the same PiWeb syntax.

For mapped variables use the K number:
K20001: ${Qdb.Measurement(20001, -1)
K20002: ${Qdb.Measurement(20002, -1)

Incremental Part Number:
${Qdb.Measurement(14,-1)

Order:
${Qdb.Measurement(53, -1)}

If you need a variable just copy the syntax from the report.
Link to comment
Share on other sites

  • 10 months later...

Please sign in to view this quote.

This helped a lot, but "date" seems to be in the wrong format for me.
Whenever I add "date" to the file name it crashes. I have changed the appearance for the date on the protocol but for the file naming it seems to fall back to some default mode (version 7.4.04).

Is this a bug or is it a different setting?

File naming string: Z:\\Measuring Results\\Zeiss\\Temp\\${Qdb.Measurement(53, -1)}\\NOK\\${Qdb.Measurement(53, -1)}_Part ${IfNotEmpty(Qdb.Measurement(14,-1), Qdb.Measurement(10096,-1))}_${Qdb.Measurement(4, -1)}.pdf

Zeiss.JPG

Link to comment
Share on other sites

Please sign in to view this quote.

You can not have colons ":" in a filename.
For file I do it that way:

Datum = dateInNumbers()
Zeit = time()
Tag = strElement(1,".",Datum)
if len(Tag) == 1 then
Tag = text("0",Tag)
endif
Monat = strElement(2,".", Datum)
if len(Monat) == 1 then
Monat = text("0",Monat)
endif
Jahr = strElement(3,".", Datum)
Stunde = strElement(1,":",Zeit)
Minute = strElement(2,":",Zeit)
Sekunde = strElement(3,":",Zeit)
ZeitF = Stunde+"_"+Minute+"_"+Sekunde
DatumFile = Jahr+Monat+Tag+"__"+ZeitF
Link to comment
Share on other sites

Sorry, I should have included the file naming string:
Z:\\Measuring Results\\Zeiss\\Temp\\${Qdb.Measurement(53, -1)}\\NOK\\${Qdb.Measurement(53, -1)}_Part ${IfNotEmpty(Qdb.Measurement(14,-1), Qdb.Measurement(10096,-1))}_${Qdb.Measurement(4, -1)}.pdf

The bold part doesn't come out in the same way as it does on the protocol
(Backslash in the datum format cause the file naming to create unwanted folders).

*Edit*
Figured out a way to change the format of the date that solved the issue
${DateTimeFormat(Qdb.Measurement(4, -1), "HH.mm.ss - yyyy-MM-dd")}
Link to comment
Share on other sites

 Share

×
×
  • Create New...