WhoCanDo Posted March 3, 2022 Share Posted March 3, 2022 Hi, Using GetVertNum I can get the number of vertices in a polygon. Using DelVertex I can delete one of those vertices. But how can I delete a specific vertex? Can I point to it with the cursor? How can I find the vertex number from pointing to it? Quote Link to comment

MullinRJ Posted March 3, 2022 Share Posted March 3, 2022 You can use the GetPt(X, Y) function, then count the vertices in a loop until the XY values match. It's kind of a brute force method but it will get you there. One way to test the points' proximity is to store both points in vector variables, one for the GetPt value in P1, and the other for the vertex values in P2. Then use this line in your loop to decide: IF (Norm(P2-P1) < Tol) THEN {points match} Set the value of Tol to a number significantly smaller than the distance between your vertices, for example: Tol := 1e-6; { or some relevantly small number } The NORM() function returns the length of a vector, in this case, NORM(P2-P1), or NORM(P1-P2), is the distance between the two points, and it's always non-negative. Also, make sure Snap to Points is turned ON when your script runs. HTH, Raymond 2 Quote Link to comment

WhoCanDo Posted March 3, 2022 Author Share Posted March 3, 2022 Nice one Raymond, this works for me 😊 procedure Delete_Vertex; var i, j, VT : integer; AR : real; p1, p2 : vector; hPoly : handle; begin GetPt (p1.x, p1.y); hPoly := PickObject (p1.x, p1.y); SetSelect (hPoly); j := GetVertNum (hPoly); for i := 1 to j do begin GetPolylineVertex (hPoly, i, p2.x, p2.y, VT, AR); if (Norm (p2 - p1) = 0) then DelVertex (hPoly, i); end; end; run (Delete_Vertex); Quote Link to comment

Juliensv Posted January 10 Share Posted January 10 Hi there, Stumbled on this thread, and remembered a function that might be relevant. GetClosestPt seems to do the exact job you want, you give it the handle of your object and a coordinate, and it should give you the index of the vertex closest. Hope this helps, or is at least interesting. https://developer.vectorworks.net/index.php/VS:GetClosestPt 1 Quote Link to comment

## Recommended Posts

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