Page 1 of 1
Multiple plots in the same page with VB.NET
Posted: Wed Apr 25, 2007 3:59 pm
by Mao
Good afternoon:
Can I define an array of DPLOT entities ? I am trying to plot several plots in the same page with VB.NET using the structure of the example btest4.vb. As the settings of the plots are very similar, I would like to have something like this (assuming I will plot 9 plots in one page):
For i=0 to 8
d(i) = New PLOT
...
...
Next i
However the system does not le me do this. Does it mean I have to declare each one of the plots separately and repeat all the settings again and again ?
d = New DPLOT
...
...
...
e = New DPLOT
...
...
...
f = New DPLOT
...
...
...
Thanks for the help.
Mao
Posted: Wed Apr 25, 2007 5:26 pm
by DPlotAdmin
I'm no VB.NET guru; the only time I touch it is to slog my way through creating example programs for DPlot. When you say "the system does not let me do this"... what happens exactly? If you get an error message, what does it say?
Off the top of my head I don't see why you'd need a new DPLOT structure for each new plot, as long as you're careful to initialize any members that should be different from the previous plot. In other words you should be able to call DPlot_Plot, change whatever DPLOT structure members need changing, call DPlot_Plot again with the same structure, and repeat as many times as needed.
Posted: Wed Apr 25, 2007 8:15 pm
by Mao
David:
I do not have the error message right now (I will send it to you tomorrow from my office). What I am trying to do is to use the following DPLOT command for printing:
cmds = cmds & "[FilePrintMultiple("",9,1,2,3,4,5,6,7,8,9,3,0.25,0.25)]"
then
DPlot_Command(XXX, cmds) (what document number should I use instead of XXX) ?
I assume that by the time I send this command I should have ready 9 plots, each one created with its own d=New DPLOT entity. Are you saying that I could use the same DPLOT entity for all of them ? How does the system recognizes which plot is number 1, which is umber 2 and so on ?
Thanks.
Mao
Posted: Wed Apr 25, 2007 8:16 pm
by Mao
David:
I do not have the error message right now (I will send it to you tomorrow from my office). What I am trying to do is to use the following DPLOT command for printing:
cmds = cmds & "[FilePrintMultiple("",9,1,2,3,4,5,6,7,8,9,3,0.25,0.25)]"
then
DPlot_Command(XXX, cmds) (what document number should I use instead of XXX) ?
I assume that by the time I send this command I should have ready 9 plots, each one created with its own d=New DPLOT entity. Are you saying that I could use the same DPLOT entity for all of them ? How does the system recognizes which plot is number 1, which is umber 2 and so on ?
Thanks.
Mao
Posted: Thu Apr 26, 2007 3:15 am
by DPlotAdmin
DPlot_Command(XXX, cmds) (what document number should I use instead of XXX) ?
Any valid document index (the number returned by DPlot_Plot).
I assume that by the time I send this command I should have ready 9 plots,
Yes, that is correct.
each one created with its own d=New DPLOT entity.
that shouldn't be necessary.
Are you saying that I could use the same DPLOT entity for all of them ?
Yes.
How does the system recognizes which plot is number 1, which is umber 2 and so on ?
Don't get confused about
your plot numbers vs. DPlot document indices, because they won't necessarily be the same. (If you run DPlot hidden
and you're sure there are no open documents other than those you've created, then they should be the same. But if the user has any access to DPlot then you can't count on that.) The values you want to use are those returned by DPlot_Plot (or DPlot_Plot8 or any other function that returns a document index). In your program you'll want to store an array of document numbers, as in
Dim DocNum(9) as Integer
DocNum(1)=DPlot_Plot(...)
DocNum(2)=DPlot_Plot(...)
.
.
DocNum(9)=DPlot_Plot(...)
.
.
cmds="[FilePrintMultiple(9," & DocNum(1) & "," & DocNum(2) & "," <etc.> & "3,0.25,0.25)]"
Posted: Thu Apr 26, 2007 3:14 pm
by Mao
David:
Following your advice this is what I did:
Dim DocNum( 8 ) As Integer
For k = 0 To 8
...
...
...
DocNum(k) = DPlot_Plot8(d, vector_x(0), vector_y(0), cmds)
Next k
print_cmd = "[FilePrintMultiple(" & Chr(34) & "Adobe PDF" & Chr(34) & ",9," & DocNum(0) & "," & DocNum(1) & "," & DocNum(2)
print_cmd = print_cmd & "," & DocNum(3) & "," & DocNum(4) & "," & DocNum(5) & ","
print_cmd = print_cmd & DocNum(6) & "," & DocNum(7) & "," & DocNum( 8 ) & ",3,0.25,0.25]"
DPlot_Command(0, print_cmd)
I have 9 plots, but when the last instruction is performed, instead of having one page with 9 plots on it, it only plots DocNum( 8 ) and reports the following error message:
ERROR PROCESSING THIS COMMAND:
[FilePrintMultiple("Adobe PDF",9,1,2,3,4,5,6,7,8,9,3,0.25,0.25]
It is like if DPLOTLIB.DLL only sees the last DPLOT entity (DocNum(8 )) and not the rest of them. That is why I suggested in a previous mail that we might need separate DPLOT entities for each graph.
Please, any help is welcome.
Thanks.
Mao
Posted: Thu Apr 26, 2007 3:55 pm
by DPlotAdmin
Aaarrggghhh. There is an uninitialized data problem in processing FilePrintMultiple that is causing that error message, and of course you called attention to it 5 minutes after I finished uploading updates
This shoud work (for now, until the fix is in place). Immediately before the [FilePrintMultiple(...)] add an Activate command, as in:
cmds = "[Activate(" & DocNum(0) & ")][FilePrintMultiple(....
The Activate command needs to be in the same call to DPlot_Command as FilePrintMultiple. I'll have this fixed sometime today/tonight. Sorry for the trouble.
Posted: Thu Apr 26, 2007 5:08 pm
by Mao
David:
I added Activate to my code and it did not work. It prevents the program from printing any plot; if I remove it, I still can print the last created plot.
I think I have a mismatch of commands and functions (please correct me if I am wrong):
cmd = "[FilePrintMultiple("" ,9,1,2,3,4,5,6,7,8,9,3,0.25,0.25]" is a command that applies to multiple plots simultaneously (9 in my case).
On the other hand:
DPLOT_Command(DocNumX, cmd) is a function that is focused to one plot (DocNumX), so when I combine it with cmd, DPLOT generates an error.
How can I inform the DLL that the command I am tryint to send applies to all the plots and not only to the one listed in the argument list of DPLOT_Command ?
I appreciate your patience and help.
Thanks.
Mao
Posted: Thu Apr 26, 2007 7:31 pm
by DPlotAdmin
DPLOT_Command(DocNumX, cmd) is a function that is focused to one plot (DocNumX), so when I combine it with cmd, DPLOT generates an error.
Whatever the problem is, this isn't it. Two things:
1) Get version 2.1.1.8, which corrects a bug in handling FilePrintMultiple (which may or may not be the culprit here - but even if it isn't the current problem it may be a problem later). If you're a licensed user, get the update with Help>Check for Updates. If using the trial version, download and install
http://www.dplot.com/dplotsetup.exe. If using DPlot Jr, download and install
http://www.dplot.com/dplotjr_setup.exe.
2) Get rid of the space after the printer specification. (I need to go through the code and be a bit more forgiving about extra spaces.)
Posted: Fri Apr 27, 2007 9:01 am
by Mao
David:
I have noticed that there is an inconsistency in the document "Executing DPLOT commands from another application" when decribing the command FilePrintMultiple; in the declaration of the command it says it should be declared as:
[FilePrintMultiple("printer",numdocs,doc1,doc2,...docn,layout,space)]
However the two examples used to explain the command do not follow the syntax:
FilePrintMultiple("",4,1,2,3,4,2,0.25,0.25) and
FilePrintMultiple("",4,1,100,3,4,2,0.25,0.25)
The examples contain two space declarations (0.25,0.25) while the generic declaration only calls for one. Which one is right ?
By the way, I tried both an none of them worked in my application. Just to verify there is nothing wrong with the rest of my appplication I tried to print a plot per page using [FilePrint()] and it works fine. The problem is specifically related to the FilePrintMultiple command.
I downloaded the registered version of DPLOT as you suggested, but there was not change. I noticed that there are several DPLOTLIB.DLL versions around; the one with DPLOT 2.1.1.8 is 44K, created on 9/13/2006 3:23 p.m.; there is an additional version that come with the C, Fortran, Basic and VB examples (54K, 2/16/2007 6:00 a.m. and 54K). Are all the updates applied to the mutiple dlls ?
Thanks.
Mao
Posted: Fri Apr 27, 2007 10:45 am
by DPlotAdmin
However the two examples used to explain the command do not follow the syntax:
FilePrintMultiple("",4,1,2,3,4,2,0.25,0.25) and
FilePrintMultiple("",4,1,100,3,4,2,0.25,0.25)
Thanks, the documentation is a little outdated. The first value is the horizontal spacing, the second is the vertical spacing. If the vertical spacing is omitted then it is set equal to the horizontal spacing. If both are omitted then whatever the current settings are will be used.
I noticed that there are several DPLOTLIB.DLL versions around; the one with DPLOT 2.1.1.8 is 44K, created on 9/13/2006 3:23 p.m.; there is an additional version that come with the C, Fortran, Basic and VB examples (54K, 2/16/2007 6:00 a.m. and 54K). Are all the updates applied to the mutiple dlls ?
The DLL distributed with the example code is the most up-to-date and should be used. The one copied to your Excel Add-In's folder is a bit behind; newer features aren't used by the Add-In but I need to update it anyway. Thanks for pointing this out.
I'm at a loss for what the problem might be right now. I just tried FilePrintMultiple from an example program and it worked correctly whether using DPlot Jr or the full version. If you can, it might be helpful if you'd send me your source code.
Posted: Fri Apr 27, 2007 3:47 pm
by DPlotAdmin
Whoa... this is a little embarrassing if this turns out to be the problem, as I can't believe I didn't notice this before.
In two examples you've shown you're missing a trailing close parenthesis. For example
cmd = "[FilePrintMultiple("" ,9,1,2,3,4,5,6,7,8,9,3,0.25,0.25]"
should be
cmd = "[FilePrintMultiple("" ,9,1,2,3,4,5,6,7,8,9,3,0.25,0.25)]"
Posted: Mon Apr 30, 2007 4:15 pm
by Mao
David:
It may have been but I am not sure. As per your suggestion I cleaned my code, removed spaces and used the latest DPLOTLIB.DLL and found a couple of errors (I do not remember if the one you mention was one of them) ; now the program is displaying the 9 plots in the same page.
I have a couple of questions:
- I need to print 90 plots (9 per page), and I am using the virtual printer Adobe PDF. However every time the program executes FilePrintMultiple, it creates a new file, so I end up with 10 separate PDF files. Is there any way to print all of them in a single 10-page document ?
- When plotting multiple curves DPLOT always plots them by number: curve 2 goes on top of 1, curve 3 on top of 2 and so on. I have a system that displays a variable number of curves (2 to

, and I would like to have the last two of them (the ones that will be plotted on top of the rest), sent back to the bottom of the others. Is there an easy way to do this ? Unfortunately I cannot assign them to curve #1 and curve #2.
Thanks.
Mao
Posted: Mon Apr 30, 2007 4:28 pm
by DPlotAdmin
- I need to print 90 plots (9 per page), and I am using the virtual printer Adobe PDF. However every time the program executes FilePrintMultiple, it creates a new file, so I end up with 10 separate PDF files. Is there any way to print all of them in a single 10-page document ?
Not with DPlot.
If you could have 90 open documents
and I changed the print routine to allow multiple print jobs you could do this. But neither is likely to happen. I'm guessing (don't have Acrobat on this system) that you can combine multiple PDF files into one file w/ Acrobat, but I don't know for sure. If you Google "merge PDF" you'll find several applications (some free and some not) that claim to do this, but I haven't tried any of them.
- When plotting multiple curves DPLOT always plots them by number: curve 2 goes on top of 1, curve 3 on top of 2 and so on. I have a system that displays a variable number of curves (2 to Cool, and I would like to have the last two of them (the ones that will be plotted on top of the rest), sent back to the bottom of the others. Is there an easy way to do this ? Unfortunately I cannot assign them to curve #1 and curve #2.
See the ReorderCurves macro/DDE command. Online version
here.