Jump to content
Developer Wiki and Function Reference Links ×

Script to Call the Width & Height of a Rectangle


sle7en7

Recommended Posts

I was messing with worksheets again to create an areas table with length and width listed but do not want to put the information manually because I'm... umm LAZY, but fell short of the task basically.

So after searching the forum a bit, I was unable to find a way to call the Width/Height of a rectangle in a database header. Is there a way to do this (like punching in "=S" to call a symbol's name) or is this information not stored as a default data like area, perimeter or ratio?

Thanks for all the help in advance. :blush:

Link to comment

Would you believe =Width and =Height?

There are two places to look that will give you all the possible database calls.

1. In VW help search for Retrieving Object Attributes in a Worksheet. That will give you all the cool things like =S for symbol or =T for Type, etc.

2. In the worksheet, click the little triangle under the red X. In the pull down choose Paste Function? That will give you a list of all possible calls.

hth

mk

Link to comment

Be careful with the Width and Height commands. They refer to the projection onto the screen, not the object itself.

They will work fine if you are working with rectangles that are parallel or perpendicular to the screen, but as soon as you have a rectangle rotated a few degrees it will not give you the dimensions of the rectangle, but rather of the bounding box you would get if you converted the rectangle to a polygon.

=Height - Returns the delta Y (height) of objects

=Width - Returns the delta X (width) of objects

Link to comment

Not that I know of.

Sorry,

Actually, since this is the Vectorscript forum, the information is valuable with the HHeight and HWidth functions of a script. At least for Rectangles and Ovals which is all I tested this morning.

If you then needed that data in a worksheet you could write a script that would attach a custom Record Format to each object and use the above functions to store the VS HHeight and HWidth into the record which could be accessed with a record.field function in the worksheet.

The problem is that you would have to remember to run the script every time you changed an object with the attached record.

Edited by Pat Stanford
Link to comment

Thank you for the heads up Pat.

You think you can send a file with the script you just mentioned? I'm kind of lost at this point but I believe what I'm trying to do is to define the edges of a rectangle in terms of delta Y (height) and delta X (width), so I guess we will write a script in order to accomplish this?

Link to comment

I just posted an example script on the Vectorscript Sharing forum.

https://techboard.vectorworks.net/ubbthreads.php?ubb=showflat&Number=202373Post202373

Note that this has the same limitations as the rest of VW when it comes to how rectangles are oriented. If your rectangles are rotated after you create them, the Width and Height may not be what you expect them to be, but the two values will be correct.

Link to comment

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.

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

×
×
  • Create New...