Jump to content
Developer Wiki and Function Reference Links Read more... ×
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

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.

×