Jump to content
Developer Wiki and Function Reference Links Read more... ×
Ryan McCuaig

Renaming a field in an existing record format?

Recommended Posts

Is there a Vectorscript function to give a new name to a field in an existing record format?


I'm really hoping that something with a signature like `FUNCTION SetFldName(recFormatHd : HANDLE; index : INTEGER; newName : STRING) : BOOLEAN;` exists somewhere, notwithstanding it not existing in the docs ... ie. the apparently missing setter half of `GetFldName(recFormatHd : HANDLE; index) : STRING;`.


On reflection, I can imagine that this could cause some potential mayhem with existing record instances. But, my ability to rename a field from the UI suggests that it's perfectly do-able, but not exposed to Vectorscript.


I'm speculating that that `GetParamName(size_t paramIndex)` hanging off of VWRecordFormat in the SDK's VW foundation classes is what the Vectorscript `GetFldName` is under the hood. But that class has only a `SetParamLocalizedName` ... no `SetParamName` so there doesn't look to be anything I could publish to Vectorscript with an SDK library.

Share this post

Link to post


   I don't think you can do it directly. The best I can suggest is to use a brute force approach.


1) create a new record with the fields of the old record and the one renamed as you like.

2) move default values from the old record to the new.

3) go through the file and attach the new record to any object that has the old record attached. 

4) move values from the old attached record to the newly attached record.

5) delete the old record format. This should detach all instances in the file, but if you like, remove the old record after you attach and clone the new one.

6) rename the new record to the old record name with SetName(GetObject('NewRecordName'), 'OldRecordName').

7) turn this code module into a procedure so you can use it again without a lot of grief.


   Ideally, if you could get a handle to a record field, you could use SetName() on it, but I don't see that as an option in the VS calls.


NOTE: If the record is a PIO record, all bets are off. Also, I have no idea how this will affect any worksheet that references the old record. Since the formulae are text based, it may not matter. As with all complex surgeries, try this on a COPY of your file first!


Have fun. If you get it to work let me know. I love it when you get to use a bazooka to swat a fly.  🙂



Share this post

Link to post

Hi Raymond--


Blerg, this is what I'd feared. Thanks for laying out the approach though. Seems straightforward but a bit more of a nail-biter than I'd like.




Yeah, I'm not sure either that record fields even have handles, or at least not any VS can see.


Fortunately it's not a PIO record. The records in question are regular user-attached records on drawing tags, as part of a schedule generator. I do use worksheets as part of the implementation, but (also fortunately) the worksheets aren't the source of truth (the tags/records are) and can be automatically re-generated after the record replacement.



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.