Jump to content

Text value from Text Object

Recommended Posts

Is it possible to get the text value from a text object within a worksheet?


I am (still) looking for a way to take a text item from an imported DWG i.e. Room Number, and assign it to the Space Number of the closest Space object. I figure I could do this with a worksheet using the nearest x and y centres, but I still need the text value of my text object.

Share this post

Link to post

Select the text block. Set the Horizontal Alignment to Center.


In the Width field click at the end of what is already there and type a plus sign (+) and the value you want the text block to expand by and hit enter. The Text Block will expand by 1/2 the value you entered on each end.


Or just enter the new width you want the text block to have in the Width field.

Share this post

Link to post

@Pat Stanford hi Pat. Thanks for your reply.


My query seems to have led you along a different path. It is not the positional value I am looking for, but rather the actual text of the text object reported in the worksheet.

E.g I have an unnamed polygon which has a text object typed near its centre which reads “abc”.

I can set up a worksheet which finds the x and y centres of the polygon and the x and y centres of the text object. (So I can match them).

I can show the Name value of the polygon (empty) so I want the “abc” text Value of the text object which I can then paste into the empty polygon name.


My next step is to repeat to extract the polygon name and paste into the Space Number field of a Space object with same 2D centre. I'm sure there are scripts which would do this better, but I’m no script writer. I have looked at marionette, but can’t find a Space object node.

So I’m after the actual text of a text object to view in the worksheet if this is possible?

[Full kudos and thanks to anyone who can write a marionette script to get the text room numbers which lie within the bounds of a polygon room then create spaces with that number added to The SpaceNumber field, that would solve all my issues. This has to be a regular requirement of anyone working with imported 2D dwg’s who needs to add wonderful data-rich Space objects. Perhaps less so for domestic projects but definitely for multi-storey buildings of say 80 spaces per floor].


Edited by DaviesTheChair

Share this post

Link to post

I responded to the wrong thread. Sorry about that. 


How about to make it up I answer your question also?  ;-) Or at least the easy part.


The following script will return the text of a text block to a worksheet cell. It is designed to work in a database and will return the value of the text block for each subrow.


Copy the script below and create a new Vectorscript in your file. I named the script 'Text to Ws' In the column where you want the text, enter a formula of =RunScript('Text to WS'). Click the Always Allow button when asked it you want to run scripts.


The values in the worksheet will be updates when you recalculate the worksheet, not when you change the data in the text block on the drawing.


Procedure TextToWS;
{August 22, 2020}
{©2020 Patrick Stanford pat@coviana.com}
{Licensed under the GNU Lesser General Public License}

{No Warranty Expressed of Implied. Use at your own risk.}

{Returns the value of a text block to a worksheet cell.}
{Run usinging a cell formula of =RunScript('TextToWS') or}
whatever neame you save the script as in if the script}
{is stored in the local file.}
{Edit the _SetResStr line in the Else statement if you }
{want something other than a dash for objects that are}
{not text blocks.}
{If the text block has manually entere line breaks/returns}
{you will only see part of the data depending on the height}
{of the row. Increase the row height to see all the text.}

Var	H1:Handle;

	If GetTypeN(H1)=10 then




Share this post

Link to post

In order to have the script work it has to be in the active file. If this is something that you are going to use in a lot of different files, there is also a way to store it as a text file in your user or workgroup folder and I can help you set that up.


But if you do that, then you have to remember to move the script to the user or workgroup folder for the new version when you upgrade.

Share this post

Link to post

Hi @Pat Stanford . I added your script and it works a treat. As long as the text is fairly central to the Space object, and the worksheet is sorted appropriately, I can now copy the number text into the Space Number field in the worksheet in one shot. Great stuff.


[There is still scope for a master puppeteer to knit together some marionette strings if you know of anyone].


Many thanks,


Edited by DaviesTheChair

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