Jump to content
Developer Wiki and Function Reference Links ×

Identifying a vertex to delete


Recommended Posts

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?

Link to comment

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

 

 

  • Like 2
Link to comment

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);

 

Link to comment
  • 10 months later...

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