Jump to content
bcd

Dimension Length in Worksheet

Recommended Posts

I believe this has been asked before: Is there a way to return the length of a dimension to a worksheet?

Interestingly I can report the dimension height, width, x or y center etc. but am stumped to find the call for the dimension value itself.

 

I'm associating Setback dimensions and would like their values to automatically populate the Zoning Check worksheet.

Edited by bcd

Share this post


Link to post

ok this is far from ideal but   =(WIDTH^2+HEIGHT^2)^0.5 gets it but only after

- turning off witness lines

- turning off dimension markers

- and tuning off 'Show Dim Value'

Share this post


Link to post

Here is a partial/temporary solution.  As long as you can deal with the returned value being a string, this will work fine. If you need to have the actual value to do calculations on, more work will need to be done,

 

In the Resource Manager create a new blank script and name it LinDimLength

 

WSScript_SetResStr(GetDimText(WSScript_GetObject));

 

In a worksheet with a database row with criteria set to Type is Dimension enter a formula in the database header row of:

 

RunScript('LinDimLength')

 

Note that the name must match the script name and must be encased in single quotes.

 

This will return the text representation shown in the dimension object.  If you need it as a number, more work will be required because (at least in Feet & Inches), there is a dash between the two parts and this is treated as a minus by all of the string to number routines. So if the text was 12'-3" once you convert it to a number you get 11' 9"

 

If this script is useful and something you will use often in different files, we can expand on the RunScript line and store the script in the user folder.

 

Let me know what you think. 

Share this post


Link to post

Hi Pat,  Thanks again for this. Nice & speedy & gets the job done!

Yes, I agree - it's a partial/temporary solution to be returning a text string rather than a numeric value, but very effective as far as it goes. Thank you.

 

Eventually I would like the dimensions to be numeric so that I can perform a logical test on them and flag any nonconforming values. I'll see if I can unpuzzle that one & post back.

 

It's peculiar how deeply ingrained this is 'num to string' business is throughout the software. I assume for good reason but it's hard to imagine VW forever converting strings back to numbers. I think I heard once that VW calculates everything in mm and converts&presents it in the Users chosen Unit.

I think, per you're parallel wish, we should have system-wide access to the numerical value of fields, without exception. And perhaps instead of a Dimension format for a worksheet cell the user could specify the intended unit. This would do away with the dangerous & clumsy need to add unit marks in the Trailer field. Could it be as simple as the developers giving us access to one more function?

 

Share this post


Link to post

Sorry to take so long to get back to this. Here is the version of the script that will return a numeric value.

 

Copy and paste the following into a script named LinDimLenAsReal.  Run using =RUNSCRIPT('LinDimLenAsReal').

 

Procedure LinDimLenAsReal;
{© 2017, Pat Stanford, pat@coviana.com}
{Licensed under the LGPL}
{When used in a Vectorworks Worksheet Script this script will return}
{The numeric value of the dimension string. If the string is in }
{feet and inches with the dash between, it will automatically }
{remove the dash and convert the returned value to inches which}
{can be displayed properly in the worksheet cell}
{Usage Example:                        }
{RunScript('LinDimLenAsReal');      }
{This script will not return proper values for feet&inches if the dim}
{string does not include the dash}
{No Warranty Expressed or Implied. Use at your own risk}

Var	B1:Boolean;
	N1:Integer;
	R1:Real;
	S1:String;
Begin
	S1:=GetDimText(WSScript_GetObject);
			N1:=POS('-',S1);
			Delete(S1,N1,1);
			Insert(' ',S1,N1);
	B1:=ValidNumStr(S1,R1);
	If N1<>0 then R1:=R1/12;
	WSScript_SetResReal(R1);
End;

Run(LinDimLenAsReal);

 

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.

×