Jump to content
The Hamma

Script Error

Recommended Posts

I have attached a file with two scripts in progress.  It is a script that I was developing to replace circles with hexagons.  The first version doesn't work as expected. It creates the hexagons but they are 1/25.40157 sized and location from the origin.  I modified the script to multiply the X,Y coordinates by 24.40157 and the size.  This places the hexagons in their proper location and size.   It seems that the script is converting the units to mm from inches. If I set the drawing units to mm the first script works

Script Error.vwx

Share this post


Link to post

You must specify units when nominating a size in a script, so this line:

 

RegularPolygon(Px,Py,12,6,1);

 

should be something like:

 

RegularPolygon(Px,Py,12",6,1);

 

or

 

RegularPolygon(Px,Py,12mm,6,1);

Share this post


Link to post

The native units for VW is in mm, and some functions will only return mm. (1" ~= 25.4mm). In VS, you can specify units when assigning values to reals, e.g. w := 6"; Otherwise, VW can be inconsistent.

Share this post


Link to post

Yes, I did try adding the unit to the script but that does not work either.  The size and the location of the created polygon are still 1/25.4 scaled. 

Share this post


Link to post

This modification corrects the issue but it seems to me that if the points are read from HCenter as inches then they should be passed to RegularPolygon as inches. 

 

HCenter(h,Px,Py);
RegularPolygon((Px*25.4),(Py*25.4),(9*25.4),6,1);

Share this post


Link to post
6 hours ago, The Hamma said:

This modification corrects the issue but it seems to me that if the points are read from HCenter as inches then they should be passed to RegularPolygon as inches.

 

@The Hamma ,

   That would make perfect sense, but RegularPolygon() is one of those procedures that always takes its input as mm, and not document units. So, YES, you have to scale the  inputs to be mm before calling RegularPolygon(). Unfortunately, the documentation does not reflect that. Welcome to the quirky world of VS programming.   )

 

Raymond

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.

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.


 

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