Aller au contenu principal

Recherche

Recherche

How To Use Onidenticalcopies For Print-Time Scripting?

Commentaires

15 commentaires

  • Avatar
    Legacy Poster

    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
  • Avatar
    Shotaro Ito

    OnIdenticalCopy runs even when object placed on off-label - though the object won't be printed.

    0
  • Avatar
    Legacy Poster

    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
  • Avatar
    Legacy Poster

    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
  • Avatar
    Legacy Poster

    [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
  • Avatar
    Legacy Poster

    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
  • Avatar
    Legacy Poster

    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   :D

     

    Glad 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
  • Avatar
    Legacy Poster

    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
  • Avatar
    Legacy Poster

    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
  • Avatar
    Legacy Poster

    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
  • Avatar
    Legacy Poster

    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
  • Avatar
    Legacy Poster

    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
  • Avatar
    Legacy Poster

    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
  • Avatar
    Legacy Poster

    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
  • Avatar
    Kai Kohler

    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.