ionw Posted October 19, 2007 Share Posted October 19, 2007 (edited) In the General discussion I was trying to help someone out with a self updating Data Stamp. I modified a script suggested by VectorGeek to include Printing. The script does everything it should, except that it sends the version prior to updating to the printer. Essentially it prints on the document when the document was last printed. Is there anyway to reset this prior to sending it to the printer? Thanks, ion Procedure printandUpdate; VAR h : HANDLE; i : INTEGER; Procedure DoIt(h : HANDLE); BEGIN ResetObject(h); END; BEGIN ForEachObject(DoIt,PON='Data Stamp'); ReDrawAll; i:=PrintUsingPrintDialog; END; Run(printandUpdate); Edited October 19, 2007 by ionw Quote Link to comment
phorn78 Posted October 19, 2007 Share Posted October 19, 2007 Thanks for working on this, Ion. I will be really excited (and grateful) if someone figures it out for '08. There have been so many times that I've been looking at two copies of the same plot, wondering which is newer and if there are any critical details I'd be losing if I issue the wrong one. Until now, my QC method has been to throw them both away a reprint the sheet : ) Thanks, David Quote Link to comment
Miguel Barrera Posted October 19, 2007 Share Posted October 19, 2007 Ion, The data stamp object actually gets reset after the script completes executing and not within the script as you would expect. If the data being updated is linked to a record field then you can update the field(s) prior to sending to the printer with the following: Procedure DoIt(h : HANDLE); VAR dateStr: STRING; dateFmt,infoFmt: INTEGER; BEGIN dateFmt:= 2; infofmt:= 1; dateStr:= Date(dateFmt,infoFmt); SetRField(h,'Data Stamp','dateFieldName',dateStr); ResetObject(h); END; Quote Link to comment
VectorGeek Posted October 19, 2007 Share Posted October 19, 2007 (edited) I think the problem is that the ResetObject() procedure doesn't register until after the script completes its execution. So essentially, the PrintUsingPrintDialog function is printing before the data stamp is updated. It may not be fixable - but I too will try. Funny how it worked in VW12. NNA, can you shed some light on this? VG Edited October 19, 2007 by VectorGeek Quote Link to comment
islandmon Posted October 20, 2007 Share Posted October 20, 2007 Speaking metaphorically for the Vectorscript Division of Nemetschek North America International & Bermuda Ltd. ... go screw yourself .. this is secret stuff ... back-off ... Quote Link to comment
VectorGeek Posted October 20, 2007 Share Posted October 20, 2007 (edited) Sing-along everybody....... island-mon what you wantin' wit da vector world? vec-tor geek want to take you from this digital-world he want to ween you from the locus tool he want to take you but you're being a fool island-mon, island-mon, island-mon, ooo-ooh, tell me what you wantin' with da vector world? {with apologies to Sir Elton John, and the inimitable Kiki Dee.} VectorGeek -------------------------------------------------- Mac Plus, 1MB RAM, 10MB HD, System 1.2 Currently playing a marathon game of "Dark Castle" Edited October 20, 2007 by VectorGeek Quote Link to comment
phorn78 Posted October 22, 2007 Share Posted October 22, 2007 Are we at a dead end on this topic? Islandmon, are you suggesting Vectorworks has prohibited this feature? Thanks for trying, guys. I will wishlist this. Quote Link to comment
phorn78 Posted October 22, 2007 Share Posted October 22, 2007 Can you create a script that updates the data stamp and then runs a second script to print? It seems like that would allow the stamp to be updated before the print command was initiated and you wouldn't have to click on several menu items to accomplish it. Two scripts chained together. David Quote Link to comment
ccroft Posted October 23, 2007 Share Posted October 23, 2007 iThink iMon is saying that we wish we had a script-savy moderater for this forum who was active here, and could definitively explain the what-what on this, and other things. In particular, we'd like an answer to the Geek's question as to why this worked in 12. I think it's a case of the guys who have this wisdom are too busy with development to moderate. Actually, I'm surprised it did work in 12. My experience so far says that nothing really happens in a script in the step-wise manner we percieve in text. The drawing is not updated until the whole script is done. Therefore you can't chain together 2 scripts in the way David is thinking, cause it becomes one script. You'd need a macro program for that....something more like pShop actions. "run the script called update stamp,save and then run the menu command called print". Somebody out there might check in at some point and know a workaround. I suppose you could have a print script that popped a dialog saying when the stamp were last updated and if you want to continue, but that would get old pretty fast. Quote Link to comment
VectorGeek Posted October 23, 2007 Share Posted October 23, 2007 Not sure how Ion had it working in 12. After trying his code, I get the same behavior as in 2008 (i.e. NOT working). AFAIK, there is no way to have a script call a script after executing. We may be stuck folks. V-G. Quote Link to comment
Dieter @ DWorks Posted October 23, 2007 Share Posted October 23, 2007 You can't make a script that call's a script after executing, but you can make a script that call's itself again after executing. I will explain this further. I had made some plug-in point objects. Sometimes you want the parameters to update before going further into the script. So you'll need to terminate the script and because of the parameter change, the script runs again. With the correct lines of code, you can let the script run the times you want. I do not know anymore how I did it exactly, but I will look at it. It worked on plug-in objects, but I do not know if this will work on a menu or tool object. I will check this out. But what if: you make a script for updating the stamps. you make a script for executing those updating scripts. then the updating scripts will terminate and update the stamps, while the main script still runs. maybe it will work? Quote Link to comment
Petri Posted October 23, 2007 Share Posted October 23, 2007 (edited) This should still work. It uses named text blocks. Creates those if they don't exist. Only one stamp set per file, though. PROCEDURE PrintAndStamp; { ? Diehl Graphsoft (date stamp) & Petri Sakkinen 2003 (filename stamp & object creation) } VAR x, y : REAL; dateNow, fName : STRING; obHd : HANDLE; PROCEDURE makeDateStamp; BEGIN PUSHATTRS; MESSAGE('Click to position date stamp'); GETPT(x, y); TEXTORIGIN(x, y); NAMEOBJECT('DateStamp'); CREATETEXT(dateNow); CLRMESSAGE; POPATTRS; END; PROCEDURE makeNameStamp; BEGIN PUSHATTRS; MESSAGE('Click to position filename stamp'); GETPT(x, y); TEXTORIGIN(x, y); NAMEOBJECT('FilenameStamp'); CREATETEXT(fName); CLRMESSAGE; POPATTRS; END; BEGIN dateNow := DATE(2, 1); { short date with time - see below for optionss } fName := GETFNAME; obHd := GETOBJECT('DateStamp'); IF obHd = NIL THEN makeDateStamp ELSE SETTEXT(obHd, dateNow); obHd := GETOBJECT('FilenameStamp'); IF obHd = NIL THEN makeNameStamp ELSE SETTEXT(obHd, fName); DOMENUTEXTBYNAME('Print', 0); END; RUN(PrintAndStamp); { date options: DATE(0, 1) - full date with time DATE(0, 0) - full date without time DATE(1, 1) - abbreviated date with time DATE(1, 0) - abbreviated date without time DATE(2, 1) - short date with time DATE(2, 0) - short date without time } EDIT Of course the items should be in the titleblock, as linked text to a drawing data record; this is how I nowadays handle the situation. Edited October 23, 2007 by Petri Quote Link to comment
phorn78 Posted October 23, 2007 Share Posted October 23, 2007 I couldn't get Petri's script to work in VW2008. It works great in earlier versions though. I wish I'd been using it since 2003. Does someone who's more familiar with scripting know what has changed in '08 to affect this script? David Quote Link to comment
ionw Posted October 23, 2007 Author Share Posted October 23, 2007 The way I had it working in 12(& 9 & 10 & 11)was along the lines of what Miguel was suggesting. We have a titleblock symbol with an attached record. It was a trivial matter to include a print date in as a part of that symbol, and a field in the record. I didn't realize that a PIO would act differently than a record value being displayed in a symbol. Quote Link to comment
Petri Posted October 23, 2007 Share Posted October 23, 2007 I couldn't get Petri's script to work in VW2008. I actually tested it in VW 2008. Quote Link to comment
phorn78 Posted October 23, 2007 Share Posted October 23, 2007 I see what I did. It's working now for me now. This will be a really handy tool! Quote Link to comment
ccroft Posted October 24, 2007 Share Posted October 24, 2007 Ion, I think the reason the PIO works differently is due to how .vso regeneration happens. You're trying to regenerate the Date Stamp pio from within a script to show it's new value, prior to calling print. VW itself handles PIO regeneration after the script ends, despite calling ResetObject within the script. A parametric object is different from other simple "graphical" objects and records in this regard. It can't regenerate itself and do something based on that regeneration because the new state of on-screen geometry doesn't exist yet. At least this is how I understand it to be. Quote Link to comment
ionw Posted October 25, 2007 Author Share Posted October 25, 2007 Thank you for the explanation Charles. It helps me understand a bit more of what is possible, and what is not. Petri, many thanks for the script, I must admit I gutted it, and used only the concept of named objects, but that one concept opened up an entirely new method of working to me. Thanks to all who contributed here, ion Quote Link to comment
Petri Posted October 25, 2007 Share Posted October 25, 2007 Ion, You chose badly. Cheers, Indiana Quote Link to comment
ionw Posted October 25, 2007 Author Share Posted October 25, 2007 When the choice is between a Red Pill or a Blue pill I will always choose the red... cheers, ion Quote Link to comment
Petri Posted October 25, 2007 Share Posted October 25, 2007 Yeah, right. You shoud've chosen the little yellow pill. Californians obviously no longer are what some of us expect them to be... Just put a date field & a filename field into your "drawing data" record format and link the fields to the titleblock symbol, will'ya! Quote Link to comment
ionw Posted October 25, 2007 Author Share Posted October 25, 2007 I know, maybe I am a little tightly wound, but not a native, maybe that explains it... I already had the required record fields linked to my titleblock symbol. I was trying to answer someone else's question on using the data stamp. Your script simply opened my eyes to something new, the concept of named objects. Maybe I am dense but I never considered that I could uniquely identify one object out of many like objects on a drawing. In hindsight all the information was there I just missed it. Then again, it took two versions before I realized you could modify the name of a previously created Viewport... Maybe too many Mother's little helpers trying to assimilate as a Californian? Cheers! Quote Link to comment
ccroft Posted October 26, 2007 Share Posted October 26, 2007 but I never considered that I could uniquely identify one object out of many like objects on a drawing I seem to remember a huge debate somewhere about how stupid it was the vWorks only allows one name in a file.... Quote Link to comment
Dieter @ DWorks Posted January 31, 2008 Share Posted January 31, 2008 I was looking for this and finally found it. I can get Petri's script to run, BUT: *it will not work if the object is in a symbol *it will not work if it belong to a titleblock I now use another method: a symbol that has text linked to a record. This works fine as long as this symbol is not in a drawing border (the pio). Does anyone figured something out for updating date and time in a drawing border? Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.