;; EllipseToPolyline
;; Returns a polyline (vla-object) which is an approximation of the ellipse (or elliptical arc)
;;
;; Argument : an ellipse (vla-object)
(defun EllipseToPolyline
(el
/ cl norm cen elv pt0 pt1 pt2 pt3 pt4 ac0
ac4 a04 a02 a24 bsc0 bsc2 bsc3 bsc4 plst blst spt spa
fspa srat ept epa fepa erat n
)
cen (3dTo2dPt cen)
bsc0 (/ (ang<2pi (- a02 ac4)) 2.)
bsc2 (/ (ang<2pi (- a04 a02)) 2.)
bsc3 (/ (ang<2pi (- a24 a04)) 2.)
bsc4 (/ (ang<2pi (- (+ ac0 pi) a24)) 2.)
(polar pt0
(+ ac0
(/ pi
2.
) bsc0
) 1.
) pt2
(polar pt2
(+ a02 bsc2
) 1.
) nil
)
(polar pt2
(+ a04 bsc3
) 1.
) pt4
(polar pt4
(+ a24 bsc4
) 1.
) nil
)
plst
(list pt4 pt3 pt2 pt1 pt0
) (list bsc4 bsc3 bsc2 bsc0
) )
)
)
)
plst
)
)
)
plst
)
)
)
'AddLightWeightPolyline
plst
)
)
)
)
)
)
'(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16)
blst
)
n 0
)
(setq plst
(sublist plst
0 (1+ fepa
)) blst
(sublist blst
0 (1+ fepa
)) )
)
)
)
)
(list (k
*bulge
(nth fepa blst
) erat
)) )
)
)
)
(setq plst
(sublist plst fspa
nil) blst (sublist blst fspa nil)
)
)
)
)
(sublist plst
(1+ fspa
) nil) )
blst
(cons (k
*bulge
(nth fspa blst
) srat
) (sublist blst
(1+ fspa
) nil) )
)
)
)
(T
)
)
)
)
)
)
)
(sublist plst fspa nil)
(sublist plst
(1+ fspa
) nil) )
)
(cdr (sublist plst
0 (1+ fepa
))) )
)
(sublist blst fspa nil)
(k
*bulge
(nth fspa blst
) srat
) (sublist blst
(1+ fspa
) nil) )
)
(sublist blst 0 fepa)
(list (k
*bulge
(nth fepa blst
) erat
)) )
)
)
(sublist plst fspa
(1+ (- fepa fspa
))) (sublist plst
(1+ fspa
) (- fepa fspa
)) )
)
)
(sublist blst fspa (- fepa fspa))
(k
*bulge
(nth fspa blst
) srat
) (sublist blst
(1+ fspa
) (- fepa fspa
)) )
)
(list (k
*bulge
(nth fepa blst
) erat
)) )
)
)
)
)
)
)
)
)
pl
)
;; Ang<2pi
;; Returns the angle expression betweem 0 and 2*pi
(if (and (<= 0 ang
) (< ang
(* 2 pi
))) ang
(ang
<2pi
(rem (+ ang
(* 2 pi
)) (* 2 pi
))) )
)
;; 3dTo2dPt
;; Returns the 2d point (x y) of a 3d point (x y z)
;; Tan
;; Returns the angle tangent
;; SUBLIST
;; Returns a sub list
;;
;; Arguments
;; lst : a list
;; start : start index (first item = 0)
;; leng : the sub list length (number of items) or nil
(defun sublist
(lst start leng
/ n r
) )
)
)
;; K*BULGE
;; Returns the proportinal bulge to the référence bulge
;; Arguments :
;; b : the bulge
;; k : the proportion ratio (between angles or arcs length)
(/ (sin (* k a
)) (cos (* k a
))) )
;; EL2PL
;; Converts ellipses and elliptcal arcs into polylines
(defun c:el2pl
(/ *error* fra acdoc ss
) (if (and (/= msg
"Fonction annulée") (/= msg "Function cancelled")
)
"\nErreur: "
"\Error: "
)
msg
)
)
)
)
(EllipseToPolyline e)
)
)
)
)
;; PELL
;; Draws an ellipse or an elliptical arc approximation (polyline) on the fly
(defun c:pell
(/ *error* ec pe old ent
) (/= msg "Fonction annulée")
(/= msg "Function cancelled")
)
"\nErreur: "
"\Error: "
)
msg
)
)
)
)
)
)
)
)
(*error* nil)
)