Delete duplicate vertices in 3d polyline

Delete duplicate vertices in 3d polyline

Anonymous
Not applicable
2,030 Views
17 Replies
Message 1 of 18

Delete duplicate vertices in 3d polyline

Anonymous
Not applicable

Hi all,

Could someone please help me by providing a LISP / Script that will delete duplicate vertices on a 3d polyline (in AutoCad 2020).

 

Note the overkill command has failed in doing so. The duplicate vertices have the exact x, y, z coordinates. 

 

Appreciate any and all assistance. 

Thanks

0 Likes
Accepted solutions (1)
2,031 Views
17 Replies
Replies (17)
Message 2 of 18

cadffm
Consultant
Consultant

Hi,

did you search for it before?

Untested:

Is Explode and JOIN an option?

Perhaps vetween explode and join, run PURGE zero length objects

 

Object selection for JOIN - use P<enter>

Sebastian

0 Likes
Message 3 of 18

Anonymous
Not applicable
Hi Betreff,

I have searched for a solution to no avail - hence my post on the Autodesk
Forum.

Yes, explode join has been tried. Among many other things...

My understanding is that purge command is not for removing drawn objects,
but removing unused layers, linetypes, text styles etc.

Regards,
0 Likes
Message 4 of 18

Washingtonn
Collaborator
Collaborator

A couple of questions:

Why are there 3D Polylines with duplicate vertices (is this an operator issue)?

How many 3D Polylines are involved (is this a recurring issue)?

Are the locations of the vertices known?

 

 

 

0 Likes
Message 5 of 18

Washingtonn
Collaborator
Collaborator

What is your tolerance setting when using Overkill?

 

0 Likes
Message 6 of 18

Anonymous
Not applicable

Hi Washington,

 

The 3d polylines are direct outputs provided from 12d. They do not have duplicated vertices within 12d - only when opened in CAD. The linework from 12d has been output in different ways as test cases - all returning a similar product within CAD (with duplicate vertices).

 

Multiple 3d polylines.

 

Locations (all coordinates) of the vertices can be known. 

 

Overkill tolerance has been tested across a range of values at both ends of the allowable spectrum of the overkill function.

 

I am just wondering if there is a Script / Lisp that performs a weeding type function for any vertex along a 3d polyline that may resolve this issue. 

 

We have tried all manner of work arounds and different functions and methods in CAD to try to resolve the issue to no avail. 

 

Regards,

 

0 Likes
Message 7 of 18

parkr4st
Advisor
Advisor

Please post a .dwg with some of the problem lines so we can try to work a solution.

0 Likes
Message 8 of 18

cadffm
Consultant
Consultant

1 >>"The duplicate vertices have the exact x, y, z coordinates."

then it would work (or is it far away from wcs0,0,0? ( tried it near to 0,0 wcs?)

 

2 >>"My understanding is that purge command "

Understanding and facts are different sometimes. Read more about PURGE in your [F1] Help.

See my mentiod purge option about ZERO length geometry.

 

But i think expode will not create a real zero object, because overkill would work in this case,

you vertex are not at the exact  same coordinate.

 

3. JOIN works as expected then.

 

4 Share your DWG with one original 3dpline, this is the simple way to show you what you really have and way things work or doesn't as it is.

 

Sebastian

0 Likes
Message 9 of 18

Washingtonn
Collaborator
Collaborator

When converting a 12d file, are there duplicate vertices at each vertex location or just some of them?

0 Likes
Message 10 of 18

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... a LISP / Script that will delete duplicate vertices on a 3d polyline (in AutoCad 2020). ....


Try this [in simplest terms, lightly tested]:

;; by Kent Cooper, 15 December 2021
(vl-load-com)
(defun C:3DPRDV ; = 3DPolyline: Remove Duplicate Vertices
  (/ 3dpl 3dpobj coords verts verts2)
  (setq
    3dpl (car (entsel))
    3dpobj (vlax-ename->vla-object 3dpl)
    coords (vlax-get 3dpobj 'coordinates)
  )
  (repeat (/ (length coords) 3)
    (setq verts (append verts (list (list (car coords) (cadr coords) (caddr coords)))))
    (setq coords (cdddr coords))
  )
  (repeat (length verts)
    (if (not (equal (last verts2) (car verts)))
      (setq verts2 (append verts2 (list (car verts))))
    )
    (setq verts (cdr verts))
  )
  (vlax-put 3dpobj 'coordinates (apply 'append verts2))
  (princ)
)

If it does what you want with a single User selection, it could be made to verify you picked the right kind of thing, or allow multiple selection, or find all 3DPolylines for you, etc.

Kent Cooper, AIA
0 Likes
Message 11 of 18

Anonymous
Not applicable

Please find attached example of one of the original outputs (3d poly with duplex vertices).

 

I appreciate everyone's help on trying to resolve this.

 

Cheers,

0 Likes
Message 12 of 18

cadffm
Consultant
Consultant

As i said..

overkill works, if the next vertex is placed at the same point

 

1. Set your shown decimal places for coordinates  to 8, LUPREC 8

    (this changes nothing in your drawing data, the setting is just for program prompts like in your properties palette)

 

2. User OVERKILL and it reduces your 62 to 23 vertex

 

3. Select the 3Dpline, open your properties panel and step thru the vertecs, you will see,

    all the left 23 vertecs are at another place.

   (15 doubles and 24 "unneeded" vertex, which are on a straight between 2 other vertecs)

 

 

 

 

Sebastian

0 Likes
Message 13 of 18

cadffm
Consultant
Consultant

>>"and 24 "unneeded" vertex"

 

If you don't like delete such vertex, use the .LSP above instead overkill

Sebastian

0 Likes
Message 14 of 18

Anonymous
Not applicable

I see - thanks for illuminating that they are not an 'exact' duplicate. (It is rare to ever view anything at such a micro scale)

 

Can you please assist in getting rid of these points? (ie ones that are so close together - to 3 decimal places say.)

 

Thanks in advance

0 Likes
Message 15 of 18

cadffm
Consultant
Consultant

I have tools like this and you can find some from others,

but I won't offer it and I don't know names of other programs.

 

It is just a small edit in the code above, so perhaps the programmer will offer an edited version.

Or you have to search for it.

 

Sorry

 

 

Sebastian

0 Likes
Message 16 of 18

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

.... they are not an 'exact' duplicate. (It is rare to ever view anything at such a micro scale)

Can you please assist in getting rid of these points? (ie ones that are so close together - to 3 decimal places say.)

....


....
(if (not (equal (last verts2) (car verts) 1e-3))
....
Kent Cooper, AIA
0 Likes
Message 17 of 18

Anonymous
Not applicable

Hi Kent1Cooper, 

 

Thanks for this piece of code. I assume it slots into your above lisp routine somewhere?

 

Regards

0 Likes
Message 18 of 18

Anonymous
Not applicable

Hi Kent1Cooper,

 

You've saved the day - worked like a treat mate! Thanks very much for providing. 

 

Thanks everyone for your patience and assistance on the above query.

 

Cheers

0 Likes