Message 1 of 25
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, I made a lisp with the help of others here to extend a line to the boundarys of a closed polyline.
I tried to make a little extra change, so it creates a new line for every 2 points.
The reason of that is, so if it finds like 4,6 or more intersection points so a Line gets created between those.
Like that example:
To do that i take the points returned from LM:intersections and try to split them into 2 lists.
However this pointlist is not really sorted so the created lines get messed up sometimes.
Do you have tips for a better split-list function and how to sort that depending on the direction of the starting line?
(defun c:test123 ()
(create-intersecting-lines (car (entsel "\nLine: ")) (car (entsel "\nPolyline: ")))
(princ)
)
(defun create-intersecting-lines (line poly / LM:intersections split-list makeline linex splitted-lst line-list)
(defun LM:intersections (ob1 ob2 mod / lst rtn)
(if (and (vlax-method-applicable-p ob1 'intersectwith)
(vlax-method-applicable-p ob2 'intersectwith)
(setq lst (vlax-invoke ob1 'intersectwith ob2 mod))
)
(repeat (/ (length lst) 3)
(setq rtn (cons (list (car lst) (cadr lst) (caddr lst)) rtn)
lst (cdddr lst)
)
)
)
(reverse rtn)
);defun
(defun split-list (lst / i list1 list2)
(setq i 1)
(foreach x lst
(if (= i 1)
(setq list1 (cons x list1)
i 2
)
(setq list2 (cons x list2)
i 1
)
)
)
(list list1 list2)
);defun
(defun makeline (p1 p2 / v1 v2 lineobj)
(setq v1 (vlax-3d-point p1))
(setq v2 (vlax-3d-point p2))
(setq lineobj (vla-addline (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))) v1 v2))
(vlax-vla-object->ename lineobj)
);defun
(setq linex (entget line)
lineobj (vlax-ename->vla-object line)
polyobj (vlax-ename->vla-object poly)
)
(setq splitted-lst (split-list (LM:intersections lineobj polyobj acExtendThisEntity)))
(setq line-list (mapcar 'makeline (car splitted-lst)(cadr splitted-lst))) ;; makeline needs osmode 0?
(entdel line)
line-list
)
Solved! Go to Solution.