Author Topic: Delete an edge within hence split a polyline  (Read 2591 times)

0 Members and 1 Guest are viewing this topic.

SteveK

  • Guest
Delete an edge within hence split a polyline
« on: November 10, 2009, 11:52:40 PM »
gday (hello),

My aim is to delete a line within a polyline (and therefore split a polyline). To do this I quickly wrote this code just making two lines and trim using these lines. You don't need to tell me there's better ways of doing this but I just wanted something fast with one select. Anyways, was wondering if anyone can (if you're bored) or has come up with something better.

Code: [Select]
; Split Polyline by trimming either side of a line (This is dodgy)
(defun c:trpl (/ MSPC PT LN1 LN2 VE1 VE2 VP1 VP2 TR)
  (vl-load-com)
  
  (setq mspc (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))
tr (ssadd))

  (setq pt (cadr (entsel))
ve1 (car (nentselp pt))
ve2 (entnext ve1))

  (setq vp1 (cdr (assoc 10 (entget ve1)))
vp2 (cdr (assoc 10 (entget ve2))))

  (command "_UNDO" "BEGIN")

  (setq ln1 (vlax-vla-object->ename (vla-addline
     mspc
     (vlax-3d-point vp1)
     (vlax-3d-point (list
      (+ (car vp1) 1.)
      (+ (cadr vp1) 1.)
      (caddr vp1)
      ))
     )
     )
)
  (ssadd ln1 tr)

  (setq ln2 (vlax-vla-object->ename (vla-addline
     mspc
     (vlax-3d-point vp2)
     (vlax-3d-point (list
      (+ (car vp2) 1.)
      (+ (cadr vp2) 1.)
      (caddr vp2)
      ))
     )
     )
)
  (ssadd ln2 tr)

  (command "_TRIM" tr "" pt "")

  (setq tr nil)
  (entdel ln1)
  (entdel ln2)

  (command "_UNDO" "END")
    
  (princ)
  )

steve  :-)

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Delete an edge within hence split a polyline
« Reply #1 on: November 11, 2009, 12:35:37 AM »
This should make you laugh:

Code: [Select]
(defun c:test (/ e)
  (and (setq e (entsel "\nSelect *Polyline: "))
       (command "_.trim" e "" e ""))
  (princ))
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Serge J. Gianolla

  • Guest
Re: Delete an edge within hence split a polyline
« Reply #2 on: November 11, 2009, 01:53:14 AM »
And not using lisp.  :lol:
Select Pline as cutting edge, then select segment to remove!

DEVITG

  • Bull Frog
  • Posts: 481
Re: Delete an edge within hence split a polyline
« Reply #3 on: November 11, 2009, 04:42:18 AM »
This should make you laugh:

Code: [Select]
(defun c:test (/ e)
  (and (setq e (entsel "\nSelect *Polyline: "))
       (command "_.trim" e "" e ""))
  (princ))

Hi AlanJT , please explain how or why it can be used the e as
as ENTITY despite it also hold the point .

Quote
(<Entity name: 7da769b8> (84.6011 56.7525 0.0))

Normally it is used as

Code: [Select]
(setq ent  ( car e))
Location @ Córdoba Argentina Using ACAD 2019  at Window 10

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Delete an edge within hence split a polyline
« Reply #4 on: November 11, 2009, 07:42:38 AM »
Several commands will use the list (ename point), look at Break.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

DEVITG

  • Bull Frog
  • Posts: 481
Re: Delete an edge within hence split a polyline
« Reply #5 on: November 11, 2009, 08:04:52 AM »
Ok , thanks , new for me .
Location @ Córdoba Argentina Using ACAD 2019  at Window 10

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Delete an edge within hence split a polyline
« Reply #6 on: November 11, 2009, 08:20:52 AM »
Several commands will use the list (ename point), look at Break.
or Lengthen
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

SteveK

  • Guest
Re: Delete an edge within hence split a polyline
« Reply #7 on: November 11, 2009, 04:09:52 PM »
This should make you laugh:

Code: [Select]
(defun c:test (/ e)
  (and (setq e (entsel "\nSelect *Polyline: "))
       (command "_.trim" e "" e ""))
  (princ))
  :-D hahaha. dearie me :oops:. Thanks Alan.

And not using lisp.  :lol:
Select Pline as cutting edge, then select segment to remove!
Sorry what command is that?

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Delete an edge within hence split a polyline
« Reply #8 on: November 11, 2009, 04:12:47 PM »
This should make you laugh:

Code: [Select]
(defun c:test (/ e)
  (and (setq e (entsel "\nSelect *Polyline: "))
       (command "_.trim" e "" e ""))
  (princ))
  :-D hahaha. dearie me :oops:. Thanks Alan.

And not using lisp.  :lol:
Select Pline as cutting edge, then select segment to remove!
Sorry what command is that?

:)

He's referring to doing exactly what I did, except w/o code.
Code: [Select]
Command: tr TRIM
Current settings: Projection=UCS, Edge=None
Select cutting edges ...
Select objects or <select all>: 1 found

Select objects:

Select object to trim or shift-select to extend or
[Fence/Crossing/Project/Edge/eRase/Undo]:

Select object to trim or shift-select to extend or
[Fence/Crossing/Project/Edge/eRase/Undo]:
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

SteveK

  • Guest
Re: Delete an edge within hence split a polyline
« Reply #9 on: November 11, 2009, 04:15:07 PM »
He's referring to doing exactly what I did, except w/o code.
Code: [Select]
Command: tr TRIM
Current settings: Projection=UCS, Edge=None
Select cutting edges ...
Select objects or <select all>: 1 found

Select objects:

Select object to trim or shift-select to extend or
[Fence/Crossing/Project/Edge/eRase/Undo]:

Select object to trim or shift-select to extend or
[Fence/Crossing/Project/Edge/eRase/Undo]:
Ah Right :ugly:. Ta

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Delete an edge within hence split a polyline
« Reply #10 on: November 11, 2009, 04:25:08 PM »
Actually, now that I think of it, Lee wrote this exact same program a month or so back.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox