How To Use Onidenticalcopies For Print-Time Scripting?
I have 3 images in a document. Depending upon which print copy it's on, I want to show image 1, 2, or 3. I have attempted to do this via the Mod operator, placing the following script within the OnIdenticalCopies event:
If Format.IsPrinting Or Format.IsPrintPreview Then Select Case counter Mod 3 Case 0 UserMessage Severity, "0" Format.Objects("Picture 1").PrintVisibility = True Format.Objects("Picture 2").PrintVisibility = False Format.Objects("Picture 3").PrintVisibility = False Case 1 UserMessage Severity, "1" Format.Objects("Picture 1").PrintVisibility = False Format.Objects("Picture 2").PrintVisibility = True Format.Objects("Picture 3").PrintVisibility = False Case 2 UserMessage Severity, "2" Format.Objects("Picture 1").PrintVisibility = False Format.Objects("Picture 2").PrintVisibility = False Format.Objects("Picture 3").PrintVisibility = True End Select counter = counter + 1 End If
('counter' is defined in 'Procedures For All Events')
The message box, when printing or previewing, correctly shows 0, 1, 2 in turn, but only Picture 1 is ever printed. What's happening?
-
Legacy Poster
★ BarTender Hero ★
Ok, this is really bizarre but if i create a text object whose data source is Page Number and place it anywhere in the document, even off-label, my script behaves how you would expect.
Can this possibly be intended? It seems there is a side-effect of that object that is allowing the OnIdenticalCopies to function properly. Hmm...
0 -
Shotaro Ito
★ BarTender Hero ★
OnIdenticalCopy runs even when object placed on off-label - though the object won't be printed.
0 -
Legacy Poster
★ BarTender Hero ★
OnIdenticalCopy runs even when object placed on off-label - though the object won't be printed.
I understand that, Shotaro, but the conceit here is that the mere existence of that object seems to allow the script to function as intended, whereas they should be independent of each other.
0 -
Legacy Poster
★ BarTender Hero ★
Just a guess, but referring to your original script/configuration (without the page number object): Try declaring the counter variable in the "Functions and Subs" event (just 1 line: "dim counter"). I have a hunch that OnIdenticalCopies loses the variable after each copy (thus why only ever picture 1 is printed and why it works if you use an on-label object).
Edit: Also, I'm not sure you actually need the If-function-construct (checking Format.IsPrinting etc.)...? Should work without it (but I kinda like it :-) )
0 -
Legacy Poster
★ BarTender Hero ★
[attachment=2002:bt-script-screenshot.PNG]
Just a guess, but referring to your original script/configuration (without the page number object): Try declaring the counter variable in the "Functions and Subs" event (just 1 line: "dim counter"). I have a hunch that OnIdenticalCopies loses the variable after each copy (thus why only ever picture 1 is printed and why it works if you use an on-label object).Edit: Also, I'm not sure you actually need the If-function-construct (checking Format.IsPrinting etc.)...? Should work without it (but I kinda like it :-) )Thanks for the suggestion, KM3. Where is the "Functions and Subs" event? I'm using BT2016, and attached is a screenshot of the relevant pane. I like your hunch, though, and will give it a shot once I know the appropriate spot for the global var.
That if/else for printing is at the recommendation of Ian (one of the admins here) from another post, since the event code gets annoyingly executed every time you unfocus to a new event in the pane while just modifying the scripts ;)
Btw, I greatly refactored the if/else logic (the first version was just a rough proof-of-concept):
DYN_TEXT = Array("day-mon", "day-tue", "day-wed") Sub MakeVisibleOnly(objToShowName) For Each objName in DYN_TEXT Format.Objects(objName).PrintVisibility = (objName = objToShowName) Next End Sub
If Format.IsPrinting Or Format.IsPrintPreview Then MakeVisibleOnly(DYN_TEXT(counter Mod 3)) counter = counter + 1 End If
0 -
Legacy Poster
★ BarTender Hero ★
I'm using an older BarTender version so the Event List looks different for me but I would guess that the equivalent to "Functions and Subs" would be the first entry "Procedures for Document Events" (or even "...for all Events" above). Try it.
The explanation regarding the If/else section makes a ton of sense. In fact, you probably just helped me a lot more than (and if) I helped you :D
0 -
Legacy Poster
★ BarTender Hero ★
I'm using an older BarTender version so the Event List looks different for me but I would guess that the equivalent to "Functions and Subs" would be the first entry "Procedures for Document Events" (or even "...for all Events" above). Try it.
Unfortunately the implementation of VBS in BT seems to not allow the standard Dim declaration; I get the following output error when I use it:
Procedures for All Events (Line 1): Dim counter = 0: Expected end of statement
[Attached is the relevant section of the VBS documentation from within BT's own Help file]
The explanation regarding the If/else section makes a ton of sense. In fact, you probably just helped me a lot more than (and if) I helped you :DGlad I could help! B) And I appreciate you taking the time to respond with suggestions; seems there are some quirks to using VBS in BT so the more collective, practical knowledge here in this forum, the better.
0 -
Legacy Poster
★ BarTender Hero ★
Yes, there are quirks to VBS in BT... lots of 'em...
Don't dim the variable and assign a value on the same line. I get the same error if I do that. Just dim on one line, then assign a value on the second line, as shown below. Then try this again with your original config/setup.
dim counter counter = 0
Edit: I was able to reproduce the issue you're getting (using your code minus the IsPrinting line) and adding the above code made it work (only tested in in Preview mode though)
0 -
Legacy Poster
★ BarTender Hero ★
So the problem is two-fold: declaring and assigning that variable in "Procedures for All Events" is that the counter is not reset per print-job, which is what I want. Instead, I now only declare the counter in that global space, and assign 0 to it in the OnPrintJobStart event; this is an improvement in the sense it's more "proper" in a software engineering sense, since there's no need for it to be set to 0 during assignment. This doesn't change any of the resulting behavior, but still, thanks for that!
The other issue is that this still doesn't remove the need for that print-field object; while indeed everything in the print-preview shows the proper cycling, if you don't have that print-field object within the template, in the actual print job it'll only ever print the first iteration.
I'm not too concerned with this oddity since I can work around it, but yeah: something that the Seagull BT developers should be aware of.
0 -
Legacy Poster
★ BarTender Hero ★
Weird though... I guess this must be an issue with BarTender 2016 then because even printout works fine for me - see attached picture. I also attached my testfile, containing your code. I still uspect this has something to do with where exactly the code is placed in the document. In my version (10.1 SR4) there are at least 4 possible placements for VBS code (+ the various events...).
0 -
Legacy Poster
★ BarTender Hero ★
I just tried your file; it works.
I then saved it, converting it to a BT2016 format, and it still works.
I then created it from scratch and... it didn't work (i.e., print preview cycles properly, but not when printed.) That is, until I added a trivial, non-printing print field page counter off-template, as I've done previously.
I think it must be a file-format version issue, as we've been suspecting. Unless I'm missing something. I've attached my from-scratch re-creation if you want to give it a shot to see what happens on your end. But no obligation. Thanks for all the investigative help thus far!! :)
0 -
Legacy Poster
★ BarTender Hero ★
I cannot open it because I have an older BT version.
All I can suggest at this point is to try different script event combinations, i.e. selectively put your script into one of the available events to see if it makes a difference...
Sorry :( I hope one of the "official support guys" can look at this.
0 -
Legacy Poster
★ BarTender Hero ★
I cannot open it because I have an older BT version.
D'oh! Haha, of course; my bad. I guess in my head I thought it might convert/strip what it didn't understand, but that's naive.
Thanks again for all the help & suggestions!
0 -
Legacy Poster
★ BarTender Hero ★
Np, glad I was of use :) - despite the fact that you pretty much solved it on your own anyway by using the dedicated non-printing field :D
0 -
Kai Kohler
★ BarTender Hero ★
Thank you for using the Seagull Scientific forums. Please be aware that forum posts are not guaranteed a response by Seagull Scientific Technical Support.
Issues with BarTender software should be reported directly to technical support @ 425 641 1408 or techsupport@seagullscientific.com.
I printed both of the .btw files attached to this post (test.btw and test-bt2016.btw) and both of them printed 3 labels with a different image on each (from what I could tell they worked as intended).
I suggest opening a ticket directly with technical support if you still need assistance with this issue.
Thanks
0
Vous devez vous connecter pour laisser un commentaire.
Commentaires
15 commentaires