Jump to content
relume

how to convert a polygon with curved vertices to an approximated "lines only" polygon?

Recommended Posts

 

Hello

 

For external geometrical processing in a python script, every VW polygon that has one or more curved vertices has to be converted to an approximated "lines only" polygon. This represents the standard transformation for any curved vortex on exporting VW objects by the export function to the Shape-Geodata format. There is also an VW-menu functionality, that converts a polygon to a multi-line group, where curved vertices were approximated by as many needed short lines.

 

At the moment I can not see, how I can get/convert to such a "lines only" polygon by a VS function. The idea is the following:

 

  1. get the handle of the VW polygon.
  2. test if there is one or more curved vertices by looping through all vertices of the polygon (using vs.GetPolylineVertex).
  3. if there is any curved vertex in the referenced polygon, make a temporal copy of the original polygon and convert this copy to a "lines only" polygon.
  4. process the "lines only" polygon as needed in the python script

 

Step 3. is the operation  I am interessted in – a "fast" and VW internal converting operation to a "lines only" polygon or a group of lines.

 

Many thanks in advance for any hint, best regards,

 

relume

Share this post


Link to post
Posted (edited)

@relume ,

Use:

def  vs.ConvertToPolygon(h, resolution):

   return HANDLE

 

Setting integer "resolution" higher creates more vertices.

 

Notes:

1) This function creates a duplicate object, so you don't have to duplicate it beforehand.

2) If the original is selected, the duplicate will be selected, and vice versa.

3) Magic numbers for the resolution are powers of 2.

 

Raymond

Edited by MullinRJ

Share this post


Link to post

@MullinRJ

 

Many thanks four your hint! It seems that I did not seek the VS functions in deep 🙄.  The vs.ConvertToPolygon(h, resolution) is perfect.

 

relume

Share this post


Link to post

You're welcome. I like the easy answers. You get full credit, just for using your memory. 😉

 

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