- Forums Home
- >
- AutoCAD Community
- >
- AutoCAD Customization Forum
- >
- Visual LISP, AutoLISP and General Customization forum
- >
- LISP for Iso in 2D

Community

Visual LISP, AutoLISP and General Customization

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

This page has been translated for your convenience with an automatic translation service. This is not an official translation and may contain errors and inaccurate translations. Autodesk does not warrant, either expressly or implied, the accuracy, reliability or completeness of the information translated by the machine translation service and will not be liable for damages or losses caused by the trust placed in the translation service.
Translate

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Message 1 of 21

07-30-2024
04:52 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report

07-30-2024
04:52 PM

Can someone help me modify a LISP command? I used ChatGPT to create it, and it works just fine. The LISP is intended to, in a way, "extrude" linework in 2D to facilitate creating isometric drawings in AutoCAD LT. Now, I want to add code so that the "extruded" linework stops right when it intersects another line or geometry. For example, if I have a triangle with vertex A at the top, vertex B at bottom right, and vertex C at bottom left, and if I tell the lisp to extrude at 30 degrees due northeast at X length, I want the new line being extruded from vertex C to stop at the intersection with the existing line AB. I've tried telling ChatGPT to add code but it simply spits out some buggy code that never seems to work, even starting from scratch. I've attached the LISP code.

Solved! Go to Solution.

Solved by ec-cad. Go to Solution.

Solved by ec-cad. Go to Solution.

20 REPLIES 20

Message 2 of 21

07-31-2024
01:46 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report

07-31-2024
01:46 AM

ChatGPT is doign better, but still a litlle talkative to isolate a pollyline list of points 😎

Make a little drawing if you please.

Is your goal (finding intersections if i understand) depending of the point of view ?

Message 3 of 21

07-31-2024
08:00 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report

07-31-2024
08:00 AM

Yeah I have no idea how to write LISPs, so I wouldn't know what is the most efficient way to write a lisp, but apparently it worked. But yeah the goal is to stop the lines being extruded from every vertex to stop at any intersecting line (or other geometry like polylines, circles, arcs, etc.) along the specified direction and length regardless of point of view. I've attached a drawing with the lisp already used in a polygon--the red rectangles are where I would like the lines to stop.

Thanks for replying!

Message 4 of 21

07-31-2024
03:56 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report

07-31-2024
03:56 PM

A suggestion, much shorter than the code you have.

```
(setq plent (entsel "\nPick pline"))
(if plent (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent))))))
```

When asked to enter a length maybe use 0 as a check so draw a line very short like 0.5 then ask for line to **Extend** to.

Sorry can not respond now, I am sure someone else will.

Message 5 of 21

07-31-2024
05:07 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report

07-31-2024
05:07 PM

@Sea-Haven wrote:

A suggestion, much shorter than the code you have.

....

[With the difference that their long-winded version is written to -- I haven't tested it -- get a list of vertex locations from a "heavy" Polyline as well as a "lightweight" one, whereas your suggestion will get them only from a "lightweight" one. But within that category, it is shorter than that part of their original.]

Message 6 of 21

08-01-2024
10:28 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report

08-01-2024
10:28 AM

Some strange things in that code. I was able to modify the 'lines' section to shorten the lines if they intersected

a line. Didn't do the parts for the Arc's or Plines. Maybe someone else here will pick up the slack.

Here's the revised code. Only does the Lines.

Cheers

ECCAD

```
;; Added this function 8-01-2024 ECCAD
(defun check_intersection_with_object ( ss pt1x pt2x N); Reset pt if intersects
(setq ssobj ss)
(setq pt pt2x); hold original extruded point
(if ssobj
(progn
(setq c 0)
(repeat (sslength ssobj)
(setq ent (ssname ssobj c))
(setq elist (entget ent))
(setq obj (vlax-ename->vla-object ent))
(setq oname (vlax-get obj 'ObjectName))
(if (or (= "AcDbPolyline" oname)(= "AcDbArc" oname))
(progn
(setq endpt (vlax-curve-getendpoint obj))
(setq begpt (vlax-curve-getstartpoint obj))
(setq pnt nil)
(setq pnt (inters endpt begpt pt1x pt2x T))
(if pnt
(progn
(setq np (vlax-curve-getClosestPointTo obj pnt))
(setq pt np)
); progn
); if
); progn
); if
;; Lines
(if (= "AcDbLine" oname)
(progn
(setq ename (ssname ssobj c))
(setq lent (entget ename))
(setq pa (cdr (assoc 10 lent))); end point1
(setq pb (cdr (assoc 11 lent))); end point2
(setq pnt nil)
(setq pnt (inters pa pb pt1x pt2x T))
(if pnt
(setq pt pnt)
); if
); progn
); if
(setq c (+ c 1))
); repeat
); progn
); if
; swap either original point, or intersecting point
(if (= N 1)(setq pt11 pt)); swap either original point, or intersecting point
(if (= N 2)(setq pt12 pt))
); function
(defun C:2DEXTRUDE (/ ss len pt1 pt2 dir dx dy)
;; Function to get vertices of a polyline
(defun get-polyline-vertices (polyline)
(setq vertices '())
(if (= (cdr (assoc 0 (entget polyline))) "LWPOLYLINE")
(progn
(setq pl-list (entget polyline))
(while pl-list
(if (= (car (car pl-list)) 10)
(setq vertices (cons (cdr (car pl-list)) vertices))
)
(setq pl-list (cdr pl-list))
)
)
(progn
(setq ent (entnext polyline))
(while ent
(setq dxf (entget ent))
(if (= (cdr (assoc 0 dxf)) "VERTEX")
(setq vertices (cons (cdr (assoc 10 dxf)) vertices))
)
(setq ent (entnext ent))
)
)
)
vertices
)
;; Prompt for selection of objects
(setq ss (ssget '((0 . "LWPOLYLINE,POLYLINE,LINE,ARC"))))
(if ss
(progn
;; Prompt for length of extrusion
(setq len (getdist "\nSpecify length of extrusion: "))
;; Prompt for direction of extrusion
(setq pt1 (getpoint "\nSpecify start point of direction: "))
(setq pt2 (getpoint pt1 "\nSpecify end point of direction: "))
(setq ang (angle pt1 pt2))
(if (and len pt1 pt2)
(progn
;; Calculate direction vector
(setq dx (- (car pt2) (car pt1)))
(setq dy (- (cadr pt2) (cadr pt1)))
(if (or (not (= dx 0)) (not (= dy 0)))
(progn
(setq dir (list (* len (/ dx (distance pt1 pt2))) (* len (/ dy (distance pt1 pt2)))))
;; Loop through selected objects
(setq i 0)
(while (< i (sslength ss))
(setq ent (ssname ss i))
(setq dxf (entget ent))
(cond
;; Handle polylines
((member (cdr (assoc 0 dxf)) '("LWPOLYLINE" "POLYLINE"))
(setq vertices (get-polyline-vertices ent))
(if vertices
(progn
(foreach vertex vertices
(command "line" vertex (mapcar '+ vertex dir) "")
)
)
)
)
;; Handle lines
((= (cdr (assoc 0 dxf)) "LINE")
(setq pt1 (cdr (assoc 10 dxf)))
(setq pt2 (cdr (assoc 11 dxf)))
;; Modified for Lines
(setq pt1o (polar pt1 ang 0.50)); Offset Point 1, cannot be a point on any line
(setq pt11 (polar pt1 ang len))
(setq pt12 (polar pt2 ang len))
(setq pt2o (polar pt2 ang 0.50)); Offset Point 2, cannot be a point on any line
(check_intersection_with_object ss pt1o pt11 1); see if line from pt1o will intersect
; if it does, reposition pt11 before adding line
(command "line" pt1 pt11 "")
(check_intersection_with_object ss pt2o pt12 2); see if line from pt2o will intersect
; if it does, reposition pt12 before adding line
(command "line" pt2 pt12 "")
;; End of Modified for Lines
)
;; Handle arcs
((= (cdr (assoc 0 dxf)) "ARC")
(setq center (cdr (assoc 10 dxf)))
(setq radius (cdr (assoc 40 dxf)))
(setq startAngle (cdr (assoc 50 dxf)))
(setq endAngle (cdr (assoc 51 dxf)))
(setq pt1 (polar center startAngle radius))
(setq pt2 (polar center endAngle radius))
(command "line" pt1 (mapcar '+ pt1 dir) "")
(command "line" pt2 (mapcar '+ pt2 dir) "")
)
)
(setq i (1+ i))
)
)
(princ "\nStart and end points are the same. Exiting...")
)
)
(princ "\nInvalid length or points. Exiting...")
)
)
(princ "\nNo valid objects selected.")
)
(princ)
)
(princ "\nType 2Dextrude to run the LISP routine.")
(princ)
```

Message 7 of 21

08-05-2024
11:40 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report

08-05-2024
11:40 AM

Worked on it in spare time (I'm retired)..

Got it to work!

Here's the sample drawing I tested it on, and the Lisp program.

Cheers

ECCAD

Message 8 of 21

08-05-2024
12:04 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report

08-05-2024
12:04 PM

Thanks man, I really appreciate it! Some lines go past the first intersection and it seems to add double overlapping lines for the new extrusions, but I don't mind doing some touch up.

Message 9 of 21

08-05-2024
02:34 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report

08-05-2024
02:34 PM

Can you post the drawing that has that issue. Thought I had them all resolved.

At some intersections, there will be (2) lines extruded, because they share a common

Vector point, end of line, beginning of next line at same point.. or vertex points of a Polyline,

that continues past that Vertex.

Maybe I can resolve that issue.

ECCAD

Message 10 of 21

08-05-2024
02:45 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report

08-05-2024
02:45 PM

I attached it. I put purple circles where the lines go past the 1st intersection.

Message 11 of 21

08-05-2024
08:27 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report

08-05-2024
08:27 PM

A few second fix convert the face into a pline then use wipeout, poly.

I found 2 lines still displayed so need to look at view angel and line work on bottom would be short.

Have you looked at using extrude and vpoint -1-1,1 in a layout mview. I also used dview.

Message 12 of 21

08-06-2024
12:20 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report

08-06-2024
12:20 PM

OK, here's the scoop. The reason for lines that cross a line, but terminate a little further on, is,

the selection set (order). The program gets all the lines, etc, steps through them one at a time.

Could be upper left to lower right, or lower right to upper left, doesn't matter. Same thing will happen.

The main loop goes one element at a time, gets the start / end points, then calculates a ray (line) that

would be drawn say toward N.E., at the given length. Then, it passes the entire selection set to the

check_intersection function, along with the points of the (ray). The check routine then goes through all

the selection set items, gets there location points, and sees if the ray will intersect. IF it does, it then

returns the intersection point to the main program, which draws a line between the start point and the

adjusted endpoint. Since the intersection may be on a line that is (past) the line that it crosses, it draws

the line to that further line, terminating at the intersection. IF the main program then finds the line

that is 'closer' to the original point, it's too late, since the main program goes on to the 'next' point.

I don't know how to fix that. ??

I tried a counter, to see if I could pick up the second intersection, no joy, since the main keeps chugging

along, and goes on to the next set of points.

😞

ECCAD

Message 13 of 21

08-06-2024
01:06 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report

08-06-2024
01:06 PM

Nah it's fine. Like I said, I don't mind doing some touch up. The code you provided works way better than the one I provided, so that right there is a huge plus. Thanks for the help man!

Message 14 of 21

08-06-2024
05:28 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report

08-06-2024
05:28 PM

@ec-cad I think if the original shape is made into a pline then draw all lines in one direction and length, then as you suggested look for intersectwith the pline and redraw shorter lines then the wipeout should give correct result without any edits, the sample dwg has shape as lines make into a pline as 1st step.

The intersectwith may return more than 1 point X Y Z, but only use 1st pt. Erase line then draw to intersection point.

`(setq intpt (vlax-invoke obj2 'intersectWith obj acExtendnone))`

Will try to find some time to test.

Message 15 of 21

08-07-2024
10:31 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report

08-07-2024
10:31 AM

Well, I got it to work for those remaining lines. Had to rework the check_intersection.. function (again).

Now looks for up to (4) intersections. IF more than 1, gets 'nearest' to begin point. Seems to work fine for

Lines, haven't tested for Arc's / Polylines.

```
;; 2DEXTRUDE.lsp, compliments, ECCAD {Control Systems & Services, L.L.C.}, an Arizona LLC
;; Final version 2.0 08-07-2024 for ACAD Forum
;; Added this function 8-01-2024, then modified 8-7-2024 ECCAD
;; Was not trimming to 'nearest' vector at times, now does it correctly
;;
(defun check_intersection_with_object ( ss pt1x pt2x N / xx c pa pb pta ptb pnt); Reset pt if intersects
(setq ssobj ss)
(setq pt pt2x); hold original extruded point
(if ssobj
(progn
(setq c 0 count 0 pi1 nil pi2 nil pi3 nil pi4 nil); Set Intersection Points nil & counters
(repeat (sslength ssobj)
(setq ent (ssname ssobj c))
(setq elist (entget ent))
(setq obj (vlax-ename->vla-object ent))
(setq oname (vlax-get obj 'ObjectName))
(if (= "AcDbPolyline" oname)
(progn
(setq vertices2 (get-polyline-vertices ent))
(if vertices2
(progn
(setq xx 0)
(repeat (length vertices2)
(setq pta (nth xx vertices2))
(setq ptb (nth (+ xx 1) vertices2))
(if (and pta ptb)
(progn
(setq pnt nil)
(setq pnt (inters pta ptb pt1x pt2x T))
(if pnt
(progn
(setq count (+ count 1)); found intersection
(setq np (vlax-curve-getClosestPointTo obj pnt))
(setq pt np)
(if (= count 1)
(setq pi1 pt)
); if
(if (= count 2)
(setq pi2 pt)
); if
(if (= count 3)
(setq pi3 pt)
); if
(if (= count 4)
(setq pi4 pt)
); if
); progn
); if
); progn
); if
(setq xx (+ xx 1))
); repeat
); progn
); if
); progn
); if
;;
(if (= "AcDbArc" oname)
(progn
(setq endpt (vlax-curve-getendpoint obj))
(setq begpt (vlax-curve-getstartpoint obj))
(setq pnt nil)
(setq pnt (inters endpt begpt pt1x pt2x T))
(if pnt
(progn
(setq count (+ count 1)); found intersection
(setq np (vlax-curve-getClosestPointTo obj pnt))
(setq pt np)
(if (= count 1)
(setq pi1 pt)
); if
(if (= count 2)
(setq pi2 pt)
); if
(if (= count 3)
(setq pi3 pt)
); if
(if (= count 4)
(setq pi4 pt)
); if
); progn
); if
); progn
); if
;; Lines
(if (= "AcDbLine" oname)
(progn
(setq ename (ssname ssobj c))
(setq lent (entget ename))
(setq pa (cdr (assoc 10 lent))); end point1
(setq pb (cdr (assoc 11 lent))); end point2
(setq pnt nil)
(setq pnt (inters pa pb pt1x pt2x T))
(if pnt
(progn
(setq pt pnt)
(setq count (+ count 1)); found intersection
(if (= count 1)
(setq pi1 pt)
); if
(if (= count 2)
(setq pi2 pt)
); if
(if (= count 3)
(setq pi3 pt)
); if
(if (= count 4)
(setq pi4 pt)
); if
); progn
); if
); progn
); if
;; check counter for more than (1) intersections, get the 'closest' to pt1x
(if (>= count 2)
(progn
(if pi1
(setq dx1 (distance pt1x pi1))
); if
(if pi2
(setq dx2 (distance pt1x pi2))
); if
(if pi3
(setq dx3 (distance pt1x pi3))
); if
(if pi4
(setq dx4 (distance pt1x pi4))
); if
(if (and (/= pi1 nil)(/= pi2 nil)(= pi3 nil)(= pi4 nil)); just (2) intersections found
(progn
(setq dxx 10000); way out there
(if (< dx1 dxx)
(setq dxx dx1 pt pi1)
); if
(if (< dx2 dxx)
(setq dxx dx2 pt pi2)
); if
); progn
); if
(if (and (/= pi1 nil)(/= pi2 nil)(/= pi3 nil)(= pi4 nil)); found (3) intersections
(progn
(setq dxx 10000); way out there
(if (< dx1 dxx)
(setq dxx dx1 pt pi1)
); if
(if (< dx2 dxx)
(setq dxx dx2 pt pi2)
); if
(if (< dx3 dxx)
(setq dxx dx3 pt pi3)
); if
); progn
); if
(if (and (/= pi1 nil)(/= pi2 nil)(/= pi3 nil)(/= pi4 nil)); found (4) intersections
(progn
(setq dxx 10000); way out there
(if (< dx1 dxx)
(setq dxx dx1 pt pi1)
); if
(if (< dx2 dxx)
(setq dxx dx2 pt pi2)
); if
(if (< dx3 dxx)
(setq dxx dx3 pt pi3)
); if
(if (< dx4 dxx)
(setq dxx dx4 pt pi4)
); if
); progn
); if
); progn
); if
(setq c (+ c 1))
); repeat
); progn
); if
; swap either original point, or intersecting point
(if (= N 1)(setq pt11 pt)); swap either original point, or intersecting point
(if (= N 2)(setq pt12 pt))
); function
(defun C:2DEXTRUDE (/ ss len pt1 pt2 dx dy)
; Added 08-07-2024, case OP is using snap / osnap / ortho on
(setq osm (getvar "OSMODE"))
(setq orth (getvar "ORTHOMODE"))
(command "SNAP" "OFF")
(setvar "OSMODE" 0)
(setvar "ORTHOMODE" 0)
; End of Added
;; Function to get vertices of a polyline
(defun get-polyline-vertices (polyline)
(setq vertices '())
(if (= (cdr (assoc 0 (entget polyline))) "LWPOLYLINE")
(progn
(setq pl-list (entget polyline))
(while pl-list
(if (= (car (car pl-list)) 10)
(setq vertices (cons (cdr (car pl-list)) vertices))
)
(setq pl-list (cdr pl-list))
)
)
(progn
(setq ent (entnext polyline))
(while ent
(setq dxff (entget ent))
(if (= (cdr (assoc 0 dxff)) "VERTEX")
(setq vertices (cons (cdr (assoc 10 dxff)) vertices))
)
(setq ent (entnext ent))
)
)
)
vertices
); function
;; Prompt for selection of objects
(setq ss (ssget '((0 . "LWPOLYLINE,POLYLINE,LINE,ARC"))))
(if ss
(progn
;; Prompt for length of extrusion
(setq len (getreal "\nSpecify length of extrusion: ")); changed to getreal
;; Prompt for direction of extrusion
(setq pt1 (getpoint "\nSpecify start point of direction: "))
(setq pt2 (getpoint pt1 "\nSpecify end point of direction: "))
(setq ang (angle pt1 pt2))
(if (and len pt1 pt2)
(progn
;; Calculate direction vector
(setq dx (- (car pt2) (car pt1)))
(setq dy (- (cadr pt2) (cadr pt1)))
(if (or (not (= dx 0)) (not (= dy 0)))
(progn
;; Loop through selected objects
(setq i 0)
(while (< i (sslength ss))
(setq ent (ssname ss i))
(setq dxff (entget ent))
(setq obj (vlax-ename->vla-object ent))
(cond
;; Handle polylines
((member (cdr (assoc 0 dxff)) '("LWPOLYLINE" "POLYLINE"))
(setq vertices (get-polyline-vertices ent))
(if vertices
(progn
(setq x 0)
(repeat (length vertices)
(setq pt1 (nth x vertices))
(setq pt2 (nth (+ x 1) vertices))
(if (and pt1 pt2)
(progn
(setq pt1o (polar pt1 ang 0.10)); Offset Point 1, cannot be a point on any line
(setq pt11 (polar pt1 ang len))
(setq pt12 (polar pt2 ang len))
(setq pt2o (polar pt2 ang 0.10)); Offset Point 2, cannot be a point on any line
(check_intersection_with_object ss pt1o pt11 1); see if line from pt1o will intersect
; if it does, reposition pt11 before adding line
(command "line" pt1 pt11 "")
(check_intersection_with_object ss pt2o pt12 2); see if line from pt2o will intersect
; if it does, reposition pt12 before adding line
(command "line" pt2 pt12 "")
); progn
); if
(setq x (+ x 1))
); repeat
); progn
); if
); cond
;; Handle lines
((= (cdr (assoc 0 dxff)) "LINE")
(setq pt1 (cdr (assoc 10 dxff)))
(setq pt2 (cdr (assoc 11 dxff)))
(setq pt1o (polar pt1 ang 0.10)); Offset Point 1, cannot be a point on any line
(setq pt11 (polar pt1 ang len))
(setq pt12 (polar pt2 ang len))
(setq pt2o (polar pt2 ang 0.10)); Offset Point 2, cannot be a point on any line
(check_intersection_with_object ss pt1o pt11 1); see if line from pt1o will intersect
; if it does, reposition pt11 before adding line
(command "line" pt1 pt11 "")
(check_intersection_with_object ss pt2o pt12 2); see if line from pt2o will intersect
; if it does, reposition pt12 before adding line
(command "line" pt2 pt12 "")
)
;; Handle arcs
((= (cdr (assoc 0 dxff)) "ARC")
(setq center (cdr (assoc 10 dxff)))
(setq radius (cdr (assoc 40 dxff)))
(setq startAngle (cdr (assoc 50 dxff)))
(setq endAngle (cdr (assoc 51 dxff)))
(setq pt1 (polar center startAngle radius))
(setq pt2 (polar center endAngle radius))
(if (and pt1 pt2)
(progn
(setq pt1o (polar pt1 ang 0.10)); Offset Point 1, cannot be a point on any line
(setq pt11 (polar pt1 ang len))
(setq pt12 (polar pt2 ang len))
(setq pt2o (polar pt2 ang 0.10)); Offset Point 2, cannot be a point on any line
(check_intersection_with_object ss pt1o pt11 1); see if line from pt1o will intersect
; if it does, reposition pt11 before adding line
(command "line" pt1 pt11 "")
(check_intersection_with_object ss pt2o pt12 2); see if line from pt2o will intersect
; if it does, reposition pt12 before adding line
(command "line" pt2 pt12 "")
); progn
); if
); cond
); while
(setq i (1+ i))
); progn
); if
(princ "\nStart and end points are the same. Exiting...")
)
)
(princ "\nInvalid length or points. Exiting...")
)
)
(princ "\nNo valid objects selected.")
)
; Added, reset sys var's
(command "SNAP" "ON")
(setvar "OSMODE" osm)
(setvar "ORTHOMODE" orth)
; End of Added
(princ)
)
(princ "\nType 2Dextrude to run the LISP routine.")
(princ)
```

Cheers

ECCAD

Message 16 of 21

08-07-2024
10:40 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report

08-07-2024
10:40 AM

Sea-Haven,

Thanks, but I'm not familiar with 'wipeout' and didn't want to 'change' the original drawing as far as

converting lines to Plines. OP may not want to change, just add those new vectors.

I notice in your picture, there are (3) extra lines shown in the 2nd valLey area.

ECCAD

Message 17 of 21

08-07-2024
10:42 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report

08-07-2024
10:42 AM

I found that there are up to (4) intersections. So, I just did a check for which one is 'nearest' to start point.

Seems to work fine now.

ECCAD

Message 18 of 21

08-07-2024
11:12 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report

Message 19 of 21

08-07-2024
05:55 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report

08-07-2024
05:55 PM

Another yes must have a pline not lines.

```
(defun c:wow ( / plent obj obj2 co-ords co-ordsxy len ang pt pt2 pt3 intpt oldsnap)
(defun chkdist ( / )
(setq I 0)
(setq co-ordsxy '())
(repeat (/ (length intpt) 3)
(setq xy (list (nth i intpt)(nth (+ I 1) intpt)(nth (+ I 2) intpt) ))
(setq co-ordsxy (cons (list (distance pt xy) xy ) co-ordsxy))
(setq I (+ I 3))
)
(setq co-ordsxy (vl-sort co-ordsxy '(lambda (x y) (< (car x)(car y)))))
(if (= (car (car co-ordsxy)) 0.0)
(setq pt2 (cadr (cadr co-ordsxy)))
(setq pt2 (cadr (car co-ordsxy)))
)
(princ)
)
(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)
(setq plent (entsel "\nPick pline object "))
(setq obj (vlax-ename->vla-object (car plent)))
(setq co-ords (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent)))))
(setq len (getreal "\nlength of lines "))
(setq ang (getreal "\nEnter angle 30 150 210 330 "))
(setq ang (* pi (/ ang 180.0)))
(foreach pt co-ords
(setq pt2 (polar pt ang len))
(setq pt3 (polar pt ang 0.001))
(command "line" pt2 pt3 "")
(setq obj2 (vlax-ename->vla-object (entlast)))
(setq intpt (vlax-invoke obj2 'intersectWith obj acExtendnone))
(vla-delete obj2)
(cond
((= intpt nil)(progn (command "line" pt pt2 "")))
((= (length intpt) 3)(progn (setq pt2 intpt)(command "line" pt pt2 "")))
((> (length intpt) 3)(progn (chkdist)(command "line" pt pt2 "")))
)
)
(command "wipeout" "P" plent "N")
(setvar 'osmode oldsnap)
(princ)
)
(c:wow)
```

Message 20 of 21

08-07-2024
08:09 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report

08-07-2024
08:09 PM

Thanks for the tip. I don't know about the wipeout, I've had problems while plotting with it. Thanks

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Can't find what you're looking for? Ask the community or share your knowledge.