Delete vertexes on 3D polylines

Delete vertexes on 3D polylines

Dexterel
Collaborator Collaborator
1,538 Views
5 Replies
Message 1 of 6

Delete vertexes on 3D polylines

Dexterel
Collaborator
Collaborator

Hello,

 

I need a lisp that will delete all vertexes under a certain elevation from a selection of 3D polylines.

Note  that some 3d polylines will need to be divided in two or more if the lisp finds an vertex to delete in the middle of the 3d polyline.

I attached a DWG to show the expected result. White 3dpoly needs to become the green 3dpolys. In this example the unwanted elevation is 0.

Many thanks in advance.

0 Likes
Accepted solutions (1)
1,539 Views
5 Replies
Replies (5)
Message 2 of 6

Kent1Cooper
Consultant
Consultant

An AutoLisp routine may be possible, but there's also a relatively easy way to do it manually, taking advantage of the fact that if a Polyline [of any variety] is selected as a cutting boundary in a TRIM command, when you pick on any segment of the same Polyline, that segment will be Trimmed out:

 

"Look at" the situation from the bottom of the page:

 

UCS  ZA  0,0,0  0,-1,0 <and if you don't have UCSFOLLOW set to change the view,> PLAN <current>

 

[In the above, the red 0's would be replaced in each case by the particular elevation for which you want no segment that touches or crosses it to remain.]

 

TRIM  <select the 3DPolyline as its own Trim boundary>  <Enter>

FENCE  <with Snap on to some reasonable value, draw a Fence line along the current X axis, touching all places in the 3DPolyline that touch or cross it>

 

Back to UCS PLAN view.

Kent Cooper, AIA
Message 3 of 6

Dexterel
Collaborator
Collaborator

Thank you for your attention ,

The solution you provide, if I'm not mistaking, works only by trimming each 3dpoly separately. In my case I have multiple 3D poly (probably in the hundreds).

I attached a new dwg. Is it possible to do what I need in this dwg whiteout a lisp?

0 Likes
Message 4 of 6

Kent1Cooper
Consultant
Consultant

@Dexterel wrote:

.... In my case I have multiple 3D poly (probably in the hundreds).

I attached a new dwg. Is it possible to do what I need in this dwg whiteout a lisp?


Yes, with one small glitch.  I tried the very same approach in that drawing, selecting all of them for the cutting boundaries.  It worked except that it did not remove entirely those that lie fully in the 0-level plane [it may have Trimmed some part(s) out of them -- I didn't compare before and after closely].  But those are quite apparent after doing it, so they can be Erased easily.

Kent Cooper, AIA
0 Likes
Message 5 of 6

phanaem
Collaborator
Collaborator
Accepted solution

Hi Dexter

 

I am a little confused by the Title and by the sample you posted.

You are deleting segments, not vertexes and, in your sample, none of the deleted segments is BELOW the 0 elevation. All are above 0, except one vertex.

 

I hope this is what you want.

 

(defun c:test ( / ss z i e a b r p l)
  (vl-load-com)
  (if
    (and
      (setq ss (ssget '((0 . "POLYLINE") (-4 . "&") (70 . 8))))
      (setq z (getreal "\nSpecify elevation: "))
    )
    (repeat (setq i (sslength ss))
      (setq i (1- i)
            e (vlax-ename->vla-object (ssname ss i))
            a (vlax-curve-getstartparam e)
            b (vlax-curve-getendparam e)
            r nil l nil
      )
      (while (<= a b)
        (setq p (vlax-curve-getpointatparam e a))
        (cond
          ( (> (caddr p) z) (setq l (cons p l)))
          (T
            (if (> (length l) 1) (setq r (cons l r)))
            (setq l nil)
          )
        )
        (setq a (1+ a))
      )
      (foreach x (if (> (length l) 1) (cons l r) r)
        (vlax-put (vla-copy e) 'Coordinates (apply 'append (reverse x)))
      )
      (vla-delete e)
    )
  )
  (princ)
)
0 Likes
Message 6 of 6

Dexterel
Collaborator
Collaborator

Many thanks,

It dose exactly what I need.

0 Likes