Jump to content

Record Format Scripting

Recommended Posts

I've been scouring the internet for any indication as to how to go about creating a record format that auto-populates the extrusion length of a symbol...and I've had no luck. But I just saw this script posted on another topic:  https://forum.vectorworks.net/index.php?/topic/46334-help-with-auto-record-formats-fields/ and I was wondering if anybody could help me alter this to work for my purpose.


I have a number of 2D shapes that I often extrude and then make into symbols. These symbols then act as the structures of trade show displays that I help design. As there are a number of similar objects in these structures, I'd love to be able to run a report that includes the length that I've extruded the symbols. 


Or any other suggestions as to how to get a similar result would be greatly appreciated. Thanks!!!

Share this post

Link to post

The script in the other thread should be easy to modify to do what you want.


Can you post a a sample file with a couple of your extrudes/symbols and the record format you want. Also indicate the field you want.


Are there other objects in the symbol other than the extrude? Is there some way to identify the object? A better description of your desired workflow would probably help.

Share this post

Link to post

I've attached a super simple file as an example. The record format in the file doesn't include nearly as much as I might have eventually; but the extrusion length is all I'm looking at for now.


And the symbols I'm using are just the extrusions for the most part. Almost all other complex symbols I would be using wouldn't necessarily require an extrusion length to be included in a report.

Extrusion Example.vwx

Share this post

Link to post

I think this does what you want/need.


It has very little error checking.  As written it only operates on Selected object that already have a Record attached.


If a selected object is not a Symbol, it is ignored.  If the first object inside the symbol is not an extrude, it stores the value 9999999 into the field. For Feed&inches, this is assumed to be inches and converted to feet for display in the record so 833333'3".


Copy the script below into a new blank script in your VW file, select 1 or more extrudes with the Extrusion Details record attached and run the script.


Let me know if this helps.





Procedure ExtrusionToRecordField;

{Written in response to a request on the Vectorworks forum General Discussion Forum}
{© Pat Stanford, January 25, 2017, Pat@coviana.com  Released into the Public Domain. No Rights Reserved}

{If the first object in a symbol placed in a VW drawing is an extrude, get the length of the}
{extrude and store it in a Record and Field as specified in the Const section of the script.}
{As written it only works on symbols that are selected and already have the record format named}
{in the TheRecord constant attached.}

{Based on a script (also posted on the Vectorworks forums) requesting the Dimension Text of}
{an object be stored in a record field. That script written April 2, 2015,}

{Change the TheRecord and TheField constants to match your record and field names}
{Script store the data from the DimText into a user attached record and field}

Const	TheRecord='Extrusion Details';

Function GetExtrudeLength(H3:Handle):String;
	{GetExtrudeLength takes the handle to the symbol instance uses that to get the symbol definition}
	{The script then checks the first object. If it is an Extrude it gets the length and returns it}
	{If the first object inside the symbol is not an extrude, it returns a value of 9999999}
	{This will display as 833333' 3" in feet & inches dimensions and as 9999999 in most other settings}

	Var	SymDefHand:	Handle;
		ObjectHand: Handle;

		SymDefHand:= GetObject(GetSymName(H3));
		If GetTypeN(ObjectHand)=24 then GetExtrudeLength:=Num2StrF(HLength(ObjectHand))
		else GetExtrudeLength:=Num2StrF(9999999);
Function HasRecord(H2:Handle; RecordName:String):Boolean;
	{HasRecord checks to make sure the object passed is a symbol and has the record attached. Not stricly}
	{neccessary if the criteria already requires it, but a safety check in case different}
	{criteria are used.}
	Var		N1:Integer;
		If GetTypeN(H2)=15 then
				For N1:= 1 to NumRecords(H2) do
						If GetName(GetRecord(H2, N1))=TheRecord then HasRecord:=True;
				{You could add code here to SetRecord if you wanted to add the record}
				{to items that don't have it already attached}

Procedure Execute(H1:Handle);

		If HasRecord(H1,TheRecord) then SetRField(H1,TheRecord,TheField,GetExtrudeLength(H1));

	ForEachObject(Execute, (((R IN ['Extrusion Details']) & (SEL=TRUE))));
	{You can change the criteria in the above line as needed for hte objects you are concerned with}



  • Like 1

Share this post

Link to post

You need to copy everything in the code window. You need to start with the line that says Procedure ExtrusionToRecordField; and go all the way down to the semicolon on the line that says Run(ExtrusionToRecordField);






Share this post

Link to post

I have an updated request on this...Is there an easy way to add the symbol name associated with the extrusion length to the record field?


As it is right now, the lengths are listed in reports that I run, but without symbol name info. It would be nice to merge the standard info given if selecting "List all symbols" upon creating a report (symbol name and quantity) with the extrusion lengths of those symbols.


Does that make sense?

Share this post

Link to post

I don't think you need to store it in the record you can just use a formula of =S in the worksheet database to display the symbol name.


You could potentially have conflicting info (just like if you change the symbol and don't rerun the script) if you replaced the symbol and the stored name no longer matched the symbol name.

Share this post

Link to post

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.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


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.

  • Create New...