Author Topic: multi extend at one time  (Read 19918 times)

0 Members and 1 Guest are viewing this topic.

dussla

  • Bull Frog
  • Posts: 286
multi extend at one time
« on: February 09, 2008, 10:32:19 AM »


hello friends
how are you ?
i need some help again ~
please help me again
if you see my attached file , you can see mutilple line

white line : boundary line

my wanted process
if i select 1  boundary edge   or   many boundary edges ,    i would like to extend lines at one time

is that possible ?

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: multi extend at one time
« Reply #1 on: February 09, 2008, 11:54:16 AM »
Hi,

Here's a way for one boundary.
It's quite more difficult with more boundaries.

Code: [Select]
(defun c:extlines (/ bound int pt)
  (vl-load-com)
  (or *acdoc*
      (setq *acdoc* (vla-get-ActiveDocument (vlax-get-acad-object)))
  )
  (if (and (setq bound (car (entsel "\nSelect the boundary: ")))
   (setq bound (vlax-ename->vla-object bound))
      )
    (if (ssget '((0 . "LINE")))
      (progn
(vla-StartUndoMark *acdoc*)
(vlax-for l (vla-get-ActiveSelectionSet *acdoc*)
  (setq int (vlax-invoke bound 'IntersectWith l acExtendOtherEntity))
  (while int
    (setq pt  (list (car int) (cadr int) (caddr int))
  int (cdddr int)
    )
    (if (< (distance (vlax-get l 'StartPoint) pt)
   (distance (vlax-get l 'EndPoint) pt)
)
      (vlax-put l 'StartPoint pt)
      (vlax-put l 'EndPoint pt)
    )
  )
)
(vla-EndUndoMark *acdoc*)
      )
    )
  )
  (princ)
)
« Last Edit: February 09, 2008, 12:02:37 PM by gile »
Speaking English as a French Frog

dussla

  • Bull Frog
  • Posts: 286
Re: multi extend at one time
« Reply #2 on: February 10, 2008, 08:06:41 PM »
gile  .  always  thank you
really , you are   genius  :-) :-) :-)

Bob Wahr

  • Guest
Re: multi extend at one time
« Reply #3 on: February 10, 2008, 09:04:29 PM »
Why automate a built in function?

EXTEND
select boundary objects
FENCE
put in a fence that crosses the lines that you want to extend

ronjonp

  • Needs a day job
  • Posts: 7526
Re: multi extend at one time
« Reply #4 on: February 11, 2008, 05:39:13 PM »
A little late to the show, but here is my contribution to do multiple boundaries:

Code: [Select]
(defun c:mextend (/ ang c e lines lwp lyr ptlst pts ss)
  (if (setq ss (ssget ":L" '((0 . "LWPOLYLINE,LINE,SPLINE,CIRCLE"))))
    (progn
      (mapcar '(lambda (e)
(if (wcmatch (cdr (assoc 0 (entget e))) "LINE")
   (setq lines (cons e lines))
   (setq lwp (cons e lwp))
)
       )
      (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
      )
      (if (and lwp lines)
(foreach l (mapcar 'vlax-ename->vla-object lines)
  (setq ang   (vla-get-angle l)
lyr   (vla-get-layer l)
ptlst nil
  )
  (foreach pl (mapcar 'vlax-ename->vla-object lwp)
    (setq c nil)
    (if
      (and (vlax-property-available-p pl 'closed) (zerop (vlax-get pl 'closed)) (setq c t))
       (vlax-put pl 'closed -1)
    )
    (if (setq pts (vlax-invoke l 'intersectwith pl acextendthisentity))
      (while pts
(setq ptlst (cons (list (car pts) (cadr pts)) ptlst))
(setq pts (cdddr pts))
      )
    )
    (and c (vlax-put pl 'closed 0))
  )
  (if ptlst
    (progn (setq ptlst (vl-sort ptlst
(function (lambda (d1 d2)
    (if (equal ang 0.0 pi)
      (> (car d1) (car d2))
      (< (cadr d1) (cadr d2))
    )
  )
)
       )
   )
   (while ptlst
     (entmakex
       (list '(0 . "LINE") (cons 8 lyr) (cons 10 (car ptlst)) (cons 11 (cadr ptlst)))
     )
     (setq ptlst (cddr ptlst))
   )
   (vla-delete l)
    )
  )
)
      )
    )
  )
  (princ)
)
« Last Edit: November 29, 2010, 01:22:44 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

dussla

  • Bull Frog
  • Posts: 286
Re: multi extend at one time
« Reply #5 on: February 11, 2008, 07:41:26 PM »
wow ~~~~~ronjonp

that is perpect also

ronjong  ?   i drawn  circles
but that is failure about circle ~~
can you modify some~
at any way  , really thank you~~~

litss

  • Guest
Re: multi extend at one time
« Reply #6 on: February 12, 2008, 12:47:30 AM »
 :-D

ronjonp, great routine! just the one i want

thx!

it takes all the plines as boundary, and then extends all the lines to the boundary, right? if the rects are made of lines, not plines, can it work?  Well, I don't have autocad at hand, just can't test.

BTW, it's that possible to deal with circles,splines,ect.? :( if not, I have to change them into plines. not easy ha






ronjonp

  • Needs a day job
  • Posts: 7526
Re: multi extend at one time
« Reply #7 on: February 12, 2008, 08:42:26 AM »
I updated the code above to work with circles and splines. I'd imagine if the line rectangles were on a separate layer than the lines that needed to be extended, it could work. Or i could modify it to allow for two selections (one to extend and the objects to extend to).

I'll try and work on that later this morn.

Enjoy :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Joe Burke

  • Guest
Re: multi extend at one time
« Reply #8 on: February 12, 2008, 09:37:04 AM »
ronjonp,

Looks interesting.  :-)

One suggestion. If a boundary object is open and one end of a line points toward the open area, the line should not be deleted as it is now. The line end which points toward the closed area of the boundary should extend to there. The other end should remain fixed.

dussla

  • Bull Frog
  • Posts: 286
Re: multi extend at one time
« Reply #9 on: February 12, 2008, 09:48:36 AM »
ronjonp ~ wow  good   

ronjonp  , can you make  this  routine  as your routine  put to practical use

pls see attached image

ronjonp

  • Needs a day job
  • Posts: 7526
Re: multi extend at one time
« Reply #10 on: February 12, 2008, 10:04:48 AM »
Joe,

I'm not sure I understand what you are saying? The intent of the routine was to have an overall closed boundary with multiple closed boundaries within it that would not be crossed by the extending lines.

Dussla,

I'm not clear on the intent of your last question.

Sorry,

Ron
« Last Edit: February 12, 2008, 05:00:19 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Joe Burke

  • Guest
Re: multi extend at one time
« Reply #11 on: February 12, 2008, 10:54:36 AM »
ronjonp,

I think I understand the intent of the code, but at least you need some error checking to ensure line objects are not erased which should not be erased.

litss

  • Guest
Re: multi extend at one time
« Reply #12 on: February 12, 2008, 11:01:44 AM »
Thx, ron!

nice one:) It's very helpful for me.

As to the line-boundary question, either way you mentioned will be ok if there are inside boudaries. We have to give the routine some hints, I guess. But, if there is only one boundary, the outside boundary, could you let the routine recoginze it automatically, no matter the outside boundary is made of lines or circles or splines?  


ronjonp

  • Needs a day job
  • Posts: 7526
Re: multi extend at one time
« Reply #13 on: February 12, 2008, 07:22:22 PM »
Updated code above per Joe's recommendation:

« Last Edit: February 12, 2008, 07:26:39 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Joe Burke

  • Guest
Re: multi extend at one time
« Reply #14 on: February 13, 2008, 03:40:04 AM »
Nice