as i said, since its structure is provided, it can be optimized to suit your needs.
please appreciate any afford (ideas, concept, psuedo etc..) not just full code.
try learning :
( setq area ( getreal "\nInput area" ) )
(defun c:aaa1 ( / ang en ep i k l l1 lst n p p1 s )
;;(revision 1) hanhphuc 30.03.2020
(and
(setq s (ssget "_:S:E+." '((0 . "LWPOLYLINE"))))
(setq en (ssname s 0)
p1 (osnap (cadr (grread t 13)) "_nea"))
(setq p (trans p1 1 0)
i (vlax-curve-getparamatpoint en p))
(setq i (fix i)
ep (vlax-curve-getEndParam en))
(>= ep 2)
(setq ang (mapcar '(lambda (x) (angle '(0. 0. 0.) (vlax-curve-getFirstDeriv en x)))
(cond
( (< i 1)(list (1- ep) (1+ i)) )
( (>= i (1- ep)) (list (1- i) 0))
( (list (1- i) (1+ i)) )
)
)
)
(princ "\nStretching segment.. \n")
(while
(and p
(mapcar 'set '(k p) (grread t 13))
(= 5 k)
(setq p1 (trans p 1 0))
)
(redraw)
(if
(vl-some 'not
(setq l (mapcar '(lambda (a b / p )
(list
(setq p (vlax-curve-getPointAtParam en b))
(inters p (polar p a 1.0)
p1 (polar p1 (angle '(0. 0. 0.) (vlax-curve-getFirstDeriv en i)) 1.0 )
nil
)
)
)
ang
(list i (1+ i))
)
l1 (apply 'append l)
n (length l1)
lst (mapcar '(lambda (x)(nth x l1 )) '(0 1 3 2))
)
)
(setq p nil)
(progn
(grvecs
(apply 'append
( mapcar
'( lambda (x)
(cons (car x) (mapcar '(lambda (x) (trans x 0 1)) (cdr x)))
)
(cons
(cons 2 (mapcar 'cadr l))
(mapcar '(lambda (x) (cons 2 x))
l
)
)
)
)
)
(princ (strcat "\rArea = " (rtos (abs (math:area lst )) 2 2)
" M\U+00B2 " )
)
)
)
); while
(entmakex
(vl-list* '(0 . "LWPOLYLINE")
'(100 . "AcDbEntity")
'(100 . "AcDbPolyline")
'(70 . 0)
(cons 90 n )
(setq lst (mapcar '(lambda (x)(cons 10 x)) lst))
)
)
)
(princ)
)
;math formula
; | x1 x2 x3 x4 xn.. |
; 1 | \/ \/ \/ \/ |
;Area= / | /\ /\ /\ /\ |
; 2 | y1 y2 y3 y4 yn.. |
;
(defun math:area (l) ;hanhphuc
(* (apply '-
(mapcar '(lambda (x y)
(apply '+
(mapcar '* (mapcar x l)
(mapcar y (append (cdr l) (list (car l)))))
)
)
'(car cadr)
'(cadr car)
)
)
0.5
)
)
p/s: today start working at home using my engineer's notebook - bricscad v19
not support double quotes lambda ' ' ((x) now changed previous to '(lambda (x)