Jump to content
Developer Wiki and Function Reference Links Read more... ×
Sign in to follow this  
ionw

How to refresh prior to print?

Recommended Posts

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 by ionw

Share this post


Link to post

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

Share this post


Link to post

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;

Share this post


Link to post

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 by VectorGeek

Share this post


Link to post

Speaking metaphorically for the Vectorscript Division of Nemetschek North America International & Bermuda Ltd. ...

go screw yourself .. this is secret stuff ... back-off ...

Share this post


Link to post

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 by VectorGeek

Share this post


Link to post

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.

Share this post


Link to post

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

Share this post


Link to post

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.

Share this post


Link to post

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.

Share this post


Link to post

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?

Share this post


Link to post

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 by Petri

Share this post


Link to post

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

Share this post


Link to post

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.

Share this post


Link to post
I couldn't get Petri's script to work in VW2008.

I actually tested it in VW 2008.

Share this post


Link to post

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.

Share this post


Link to post

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

Share this post


Link to post

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!

Share this post


Link to post

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!

Share this post


Link to post

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....

Share this post


Link to post

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?

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×