@Tanookh hi,
Here is my advanced version 😀
The program starts with defining some constant values (see lines 75-80)
than goes to collecting data points (see lines 82-85)
than shift points up +2000 [WRKLN (see line 87)]
then sort points by distance from left base point (see line 88) this allows you to pick points in any order
(caution: no check for duplicate points is made)
next the red\yellow lines is drawn (see lines 90-103)
than the base point is advanced up +2000 [WRKLN (see line 105)
than shift points up +450 [DEPTH (see line 106)]
next points are grouped in fours to be prepared to draw the cyan lines (see line 108)
next draw cyan lines (see lines 110-134)
study the beautiful local functions.
i know this is beyond your knowledge but hey to learn to swim you have to head dive 🤣
have more question? i'm here.
Your next challenge would be to get the data points by selecting the horizontal lines with (ssget) instead of picking them with (getpoint)
enjoy
Moshe
(defun c:test2 (/ getPairPoints _shf2wrkln sort_data grp2four ; local functions
WRKLN DEPTH EXTEND OFSET SLOP base points^ i t0 t1 t2 t3 grp4^ p0 p1 p2 p3)
(defun getPairPoints (step bpt / askpoint ; local function
p1 p3)
(defun askpoint (n)
(if (not bpt)
(getpoint (strcat "\nSpecify " step " pt" (itoa n) ": "))
(getpoint bpt (strcat "\nSpecify " step " pt" (itoa n) ": "))
)
); askpoint
(cond
((eq step "first")
(and
(setq p1 (askpoint 1))
(setq base p1)
(setq p3 (askpoint 3))
)
); case
((and
(setq p1 (askpoint 1))
(setq p3 (askpoint 3))
)
); case
); cond
(if (and p1 p3)
(setq points^ (cons p1 points^) points^ (cons p3 points^))
)
); getPairPoints
; anonymous function, shift points to work line
(setq _shf2wrkln (lambda (b v lst) (mapcar (function (lambda (pt) (list (car pt) (+ (cadr b) v) 0.0))) lst)))
; sort points by distance from base
(defun sort_data (t0 l)
(mapcar
(function
(lambda (itm)
(cadr itm)
)
); function
(vl-sort
(mapcar
(function
(lambda (t1)
(list (distance t0 t1) t1)
)
); function
l
); mapcar
(function (lambda (e0 e1) (< (car e0) (car e1)))) ; sort by this function
); vl-sort
); mapcar
); sort_data
; organize points in groups of fours
(defun grp2four (l0 / j l1)
(setq j 0)
(while (<= (+ j 3) (1- (vl-list-length l0)))
(setq l1 (cons (list (nth j l0) (nth (1+ j) l0) (nth (+ j 2) l0) (nth (+ j 3) l0)) l1))
(setq j (+ j 2))
); while
(reverse l1)
); grp2four
; here start test2
(setvar "cmdecho" 0)
(command "._undo" "_begin")
; define some constants
(setq WRKLN 2000) ; work line
(setq DEPTH 450)
(setq EXTEND 300)
(setq OFSET 40)
(setq SLOP 80)
; get points
(if (getPairPoints "first" nil)
(while (getPairPoints "next" base))
); if
(setq points^ (_shf2wrkln base WRKLN (reverse points^))) ; shift point +WRKLN
(setq points^ (sort_data base points^)) ; sort by distance from base
(setq i 0)
(repeat (/ (vl-list-length points^) 2)
(setq t1 (nth i points^))
(setq t3 (nth (1+ i) points^))
(setq t0 (polar t1 (* pi 0.5) DEPTH))
(setq t2 (polar t3 (* pi 0.5) DEPTH))
(command "._line" "_none" t1 "_none" t3 "" "._chprop" "_si" "_Last" "_Color" 1 "")
(command "._line" "_none" t0 "_none" t1 "" "._chprop" "_si" "_Last" "_Color" 2 "")
(command "._line" "_none" t2 "_none" t3 "" "._chprop" "_si" "_Last" "_Color" 2 "")
(setq i (+ i 2))
); repeat
(setq base (list (car base) (+ (cadr base) WRKLN) (caddr base))) ; shift base point +WRKLN
(setq points^ (_shf2wrkln base DEPTH points^)) ; align points +DEPTH
(setq grp4^ (grp2four points^)) ; make groups of four
(setq i -1)
(foreach item grp4^
(setq t0 (car item) t1 (cadr item) t2 (caddr item) t3 (cadddr item))
(setq i (1+ i))
(cond
((= i 0)
(setq p0 (list (- (car t1) EXTEND) (+ (cadr t1) OFSET) (caddr t1)))
); case
( t
(setq p0 (list (- (car t0) EXTEND) (+ (cadr t0) OFSET) (caddr t0)))
); case
); cond
(setq p1 (list (- (car t2) EXTEND SLOP) (+ (cadr t2) OFSET) (caddr t2)))
(setq p2 (list (+ (car p1) SLOP) (+ (cadr p1) OFSET) (caddr p1)))
(setq p3 (list (+ (car t3) EXTEND) (+ (cadr t3) OFSET OFSET) (caddr t3)))
(command "._line" "_none" t1 "_none" t2 "" "._chprop" "_si" "_Last" "_Color" 2 "")
(command "._pline" "_none" p0 "_width" 0 0 "_none" p1 "_none" p2 "_none" p3 "" "_chprop" "_si" "_Last" "_Color" 4 "")
); foreach
; last pline
(setq p1 (list (- (car t2) EXTEND) (+ (cadr t2) OFSET) (caddr t2)))
(setq p2 (list (+ (car t3) EXTEND) (+ (cadr t3) OFSET) (caddr t3)))
(command "._pline" "_none" p1 "_width" 0 0 "_none" p2 "" "_chprop" "_si" "_Last" "_Color" 4 "")
(command "._undo" "_end")
(setvar "cmdecho" 1)
(princ)
); c:test2