Jump to content
Gabriel Chan

Updating Dates field in titleblock script

Recommended Posts

Hi all,

 

Is there a way to vectorscript an automatic update of dates in the titleblock fields prior to publishing?

 

I understand there is the data stamp tool available but it just seems more direct if there was a plugin to execute that targets the date field. 

 

Gabriel

VW2017 Spotlight user MacOS

 

  • Like 1

Share this post


Link to post

I just use the data stamp tool to be honest. Would like a better way of doing it but this is the most reliable way I've found. 

 

I use a specific font in my title blocks -  but the date stamp doesn't allow for that font so it looks odd - but works. 

Share this post


Link to post

And, by default, the data stamp updates when the the drawing prints or publishes.  Kind of like having a script to update the date …

 

mk

Share this post


Link to post
14 hours ago, Andrew Davies said:

I just use the data stamp tool to be honest. Would like a better way of doing it but this is the most reliable way I've found. 

 

I use a specific font in my title blocks -  but the date stamp doesn't allow for that font so it looks odd - but works. 

Hi guys,

 

Thanks for the input. Yes I think the most reliable work around right now is the data stamp in titleblock. It's just less intuitive for me I think. 

 

Not just fonts Andrew, I think when we get to scaling titleblock say for different paper sizes, alignment can run as well. Right now I alternate between A3 through A1 prints so I scale my titleblocks between 0.7 and 1 - data stamp does not scale along so it barely fits some times. 

 

Gabriel

Share this post


Link to post

I believe all the publish-like commands are available in vectorscript.

You could create a script that updates each titleblok date field, next run the publish dialog in one command.

Share this post


Link to post
On 12/04/2017 at 1:49 PM, Hippocode said:

I believe all the publish-like commands are available in vectorscript.

You could create a script that updates each titleblok date field, next run the publish dialog in one command.

Hi Hippocode,

 

I'm fairy new to coding scripts. Would you be able to point me to some links for such resources? On the flip side, there's marionette and I'm wondering if that would be more intuitive for designers? Any upsides/downsides to either methods of scripting?

Share this post


Link to post

My personal opinion is the Marionette is the best option for creating new geometry. For anything more complicated than a rectangle with some text in it, you are going to have a much easier time getting a Marionette network to do what you want than a script.

 

For simple modifications to objects where you want them to remain as their original object type and not end up as a marionette object, then scripting is a better option. Passing an already existing object into a Marionette network is a non-trivial task for most real world uses. The options are to hard code an object name into the network (which means that you have to edit the network to make if work on a different object as only one object in a VW drawing can have a given name) or to Wrap the network and Convert to a Marionette Object and pass the data as part of what is called "Control Geometery." If there is more than one object to be passed in it must be grouped first and then ungrouped in the Marionette network to get the individual objects. Stacking order becomes very important.

 

Manipulating data in records and fields as suggested by Hippocode above is certainly a better task for a script than for a Marionette.

 

I ran out of time tonight, but I will see if I can put something together over the weekend.

 

Can you post a VW file with your title block in it so I can see exactly how the fields are named?

Share this post


Link to post

Hi Pat,

 

Thanks for offering to help. I've attached a sample title block file for your reference.

 

My current workaround is that I place a data stamp with just the dates over the P_date text.

 

The stamp updates itself every time I publish. I place it on a Titleblock-Stamp class so If I decide that I need to manually enter the date, I just turn off the class, and the "original" title block date field is unmasked.

 

The downside to this is that the data stamp does not scale with the title block. So it sort of lives in the rectangle of the date field for a limited range of scales I apply to the title block.

 

Gabriel

VWX Sample Titleblock.vwx

Share this post


Link to post

A couple of things.

 

1. The Custom Titleblock Record in the file you sent does not have a P_Date field, but rather an S_Date field. Which is fine, but it means that you will need to change the date on each sheet border separately. If you always want all the sheets to have the same date, the script can be modified to do that easily. If you want to set a non-explicit subset of the sheets, that will be harder.

 

2. The S_Date field is formatted at YYDM, This is very different than the way you have the date stamp formatted.

 

3. I know the attached file could be boiled down to a one-liner, but I needed the Begin/End for debugging and just left it. It will also make it easier to expand in the future to handle multiple sheets.

 

Here is a script that will update a sheet border which is the first selected object on a layer (i.e. the only selected object on the layer as the stacking order determines which is first) that will update the S_Date field of a record named "Custom Titleblock Record" to the current system date.

 

Procedure UpdateS_Date;

Begin
	SetRField(FSActLayer,'Custom Titleblock Record','S_Date',Date(2,0));
End;

Run(UpdateS_Date);

Try this out and let me know what else you would like it to do.

  • Like 1

Share this post


Link to post

Hi Pat,

 

The script works great! I think using the S_Date is more useful for my own application where individual sheets are updated separately as compared to using P_Date.

 

Just out of curiosity and making infant steps in coding, is there some place that I can actually reference these coding vocabulary?

i.e. Setting the record field = SetRField.

 

I can't really figure out what FSActLayer does. Or am I approaching coding the wrong way to begin with?

 

Gabriel

Share this post


Link to post
1 hour ago, michaelk said:

Check out the VectorScript Language Guide and the VectorScript Function Reference.  You're in for hours / years of fun :-).

 

FSActLayer is First Selected object on the Active Layer.  Your first 20 scripts will use that function.

 

hth

 

mk

 

Thanks Michael for the treasure trove. I suspect years of fun... Just hoping to find that time!

 

Gabriel

Share this post


Link to post

The Language Guide and the Function Reference will get you 80% - 90% of the way there.  

 

Asking questions here for Pat, Raymond, Josh, Orso, et. al. will get you the rest of the way.  

 

At least that was (and still is!) my experience.  Can't believe how patient they are.

 

mk

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

 

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.

×