DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

How to script in Diadem 10.2 a viewsheet to pdf-printer?

Hi There,

 

haven't found that topic yet, so here's my Question:

 

I'm trying to script a small tool, that takes the Measurements from the Dataportal, imports them to the prepared *.tdv-File, prints a pdf of the View-Datasheet, deletes the first Dataset and loops till the Dataportal is empty again.

 

The script is working fairly good so far, the only part a can't get a grip on is the printing.

 

If I use the a physical (laser) printer as standard-windows-printer, its printing all the sheets on Paper, in portrait but it works...

BUT, I wont it to put out PDFs with the names I create in my script and in unfortunately in portrait but it works. From VIEW, no transfer to REPORT wanted.

 

The normally very fertile Diadem-Help is pretty lean in this case - printing from VIEW.

 

You may laugh, but my attempts yesterday ended like this:

...

  Printdevice = "PDFExport"                                 
  Printorient = "Landscape"                                
  Printfile = "00" & MsgName(0)+i-1                         

 

Call View.ActiveSheet.Print()                           

...

 

Using the last call, the script / VIEW / DIADEM.. what ever, will sent the printing job to the win-standard-printer for the time being. If it happens to be a pdf-printer the printing-dialog will open.

Given that adobe (or anything else) is not a part of diadem, I couldn't figure out a way to enter the the storing-path or the pdf-name into the printing-dialog by script. I read, that the Diadem-pdf-export just works in REPORT, so I didn't gave that a try... yet.

 

So if anyone could give my a clue..

Ah almost forgot, updating to a higher version of diadem is no option.

 

Thanks

Olaf

0 Kudos
Message 1 of 6
(6,100 Views)

Hey klatschmohn,

So I think the point you said "I couldn't figure out a way to enter the the storing-path or the pdf-name into the printing-dialog by script" is right. So this is part of windows and I think it´s not or quite really hard possible to add pdf-name or storing-path.

All in all I like to know, why you don´t like to transfer the VIEW in REPORT. In my eyes it´s the normal way, because if you like to print or safe something into a PDF it´s a report.
Also a transfer to VIEW goes really fast, so I think that would be the easiest way.
I send you a code (tested by DIADEM 12, I hope it also works for your version).
It transfer the VIEW to REPORT, safes this to PDF to the path you enter and refresh the REPORT again. So you don´t produce REPORT files.

Option Explicit  'Erzwingt die explizite Deklaration aller Variablen in einem Script.
Call Report.Refresh     
Call ScriptStart("C:\PROGRAM FILES (X86)\NATIONAL INSTRUMENTS\DIADEM 2012\Resource\VwLayTrans","VWTransViewRep",0)                'VIWE transfer to REPORT
Dim path : path = "Z:\Support\11_14\Forum PDF\test"
Call PDFExport(path)                                       'call PDFExport-function
Err.Clear
Call Report.Refresh                                          'refresh Report

Function PDFExport(SavePath)
  On Error Resume Next
  Call PrintMaxScale("REPORT")
    Do
      Dim counter : counter = 0                             'Counter to realize, when PDF is written
      Err.Clear                                                      'clear errors
      do                                                               'loop
        counter = counter + 1
    loop while FileExist(SavePath&".cat")                  'lopp until "*.cat" don´t exist
  Call PicPDFExport(SavePath, TRUE)                     'creat pdf-file (or extend it, if exist)
  If Err.Number <> 0 Then Call MsgBoxDisp(GraphSheetNGet(1) & "Fehler beim speichern der PDF!." &_
     vbcr & "No acess!" & vbcr & "Please close the PDF!",,,,3)
  Loop While Err.Number <> 0                                'loop until error
 End Function

0 Kudos
Message 2 of 6
(6,068 Views)

Sorry, aber ich schreib etz auf deutsch weiter... geht deutlich schneller.

 

Erstmal danke jSturm für deine Mühen.

 

Sicherlich könnte ich es das ganze als Report ausdrucken, ist mir aber zu umständlich.

Erklärung:

Ich habe Runde 600 Messungen von denen ich ausgewählte Kanäle über die Zeit als View (mit Kanalnamen, Farben,  X-& Y-Werte an Cursor-Position) quer als PDF mit dem Messungsnamen (der Messungsnummer) ausgedruckt haben möchte, um mir im Anschluss die Messungen einfach kurz anzusehen, zu entscheiden, ob die Anstiege der Kurven, die Schwingungen etc. ok sind, oder nicht. Auswerten (als Report) werde/will ich Anhand dieser Vorauswahl nur einige wenige der Messungen.

 

Warum als PDF? Nun es wäre mir lieber, da hier nicht jeder Kollege Diadem besitzt und zwecks zügiger Durchsprache sind PDFs immer eine gute Wahl.

 

Diese gewünschte Darstellung kann ich/man natürlich auch im REPORT darstellen, nur sehe ich es nicht ein, da ich im VIEW ja bereits alles so habe wie ich es für diese Übersicht benötige... nur dass ich es (augenscheinlich) nicht per Skript automatisch mit Wunschnamen ausdrucken kann.

Es handelt sich um 10 Kanäle, die, wenn man sie im Report alle über die Zeit in je einem einzelnen Diagramm untereinander anordnet so unleserlich werden, dass man (ich) sich wünscht es im VIEW gedruckt zu haben... den "Transfer to REPORT"-Knopf hatte ich schon mal benutzt und diesen Lösungsansatz verworfen.

 

Sorry, wenn ich da noch mal nachhake und meine Frage (jetzt auf deutsch) wiederhole, wie kann man im VIEW-Bereich ein Arbeitsblatt per Skript in ein PDF-Blatt ausdrucken und diese Datei automatisch mit seinem Wunschnamen benennen?

 

Alternativ muss ich die pdfs von Hand erstellen ... lassen.

0 Kudos
Message 3 of 6
(5,963 Views)

Ok, once again in english:

 

First of all, thank you jSturm for your effort.

It's surly possible to print the whole thing as REPORT, but it's too.. detailed, to complicated in the wrong way...

Explanation:

All in all there something like 600 readings/datasets. In eack reading there only 10 channels I'm interestet in. I roughly pre-rerate the datasets by looking them up by time flow

in VIEW (with the channel names, colours,  X-& Y-Values at the cursor-position etc.). As for a better discussion-base i'd like to have it as a pdf, in landscape format, named by the dataset number.

Now, I could print them by hand, reading by reading. I'd like to print & name it automatical by script.

To transfer the VIEW to REPORT would mean, to create a layout in which the 10 channels are listed by time flow, create a explenation with each channel values @ the cursor position...
I tried the Transfer-Button once, but the result was not that satisfying.

Imho, that would mean too much effort, because in VIEW all my wants are there but the printing is not that scriptable... for me scripting skills.
 
One could ask now, why transfer to pdf anyway? Its because not every collegue of mine has got a DIADEM licence and pdfs are easier to handle, in discussions.

Sorry if I repeat myself: How do you script in VIEW a worksheet to pdf print, landscape format, pdf naming by my script.
 
Alternativ I would have to print each pdf by hand...

0 Kudos
Message 4 of 6
(5,933 Views)

Hi klatschmohn,

 

I think your only option to print from DIAdem-VIEW directly to PDF file is to set up the default printer on the computer to be a PDF printer.  That may work with the DIAdem PDF printer, or you might have to buy your own PDF printer driver, I'm not sure.  There's probably a way in VBScript to programmatically assign the default Windows printer, but I don't know that either.  You could test this by setting the default printer manually to a PDF printer, then manually printing in VIEW.  If that works, then programmatically printing in VIEW should work as well-- DIAdem will not know the difference.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 5 of 6
(5,894 Views)

Hi @ all and many thanks for your support! Smiley Happy

 

Sadly I'm still stuck with my little problem.

@ Brat Turpin: I tried to use your way, but I must admit, that I couldn't get the hang of it.Smiley Sad

 

BUT... I've two new ideas of dealing with my printing from VIEW by script and if you read this you know that I'm again depending on the communities support:

  1. How to use a Windows-Commandline-order in Diadem-Script? My intention is to implement a commandline order directly in the script trying to print direktly, pretending path and file name in the order. also trying to do that dynamicaly... but thats second thought
  2. I heard from an ex-NI-employee, that it is probably possible to implement foreign-software in Diadem using their libraries or something like that.I only found the following code-lines so far:

' Acrobat                                                                     
' C:\Program Files (x86)\Adobe\Acrobat 10.0\Acrobat\Acrobat.tlb               
Call AutEdTypeLibAdd("78165D71-DF28-11d3-9A89-005004A56D53", "1.0")

 

I tried to find more informations to these two ideas but on the one hand my job doesn't give me the time to search properly, on the other hand I thing I'm using the wrong term for searching... technicaly thouse two points are called differently to my notion.

 

Has anybody experience to the one or other or even both matters or is otherwise able to help?

 

thanks

olaf

0 Kudos
Message 6 of 6
(5,513 Views)