Thanks for your time @Grrr1337. Your lisp is throwing me the error: "bad SSGET mode string"
Yes Im using Intellicad even I am fed up with the lisp compatibility of this product. They have poor forum to resolve the issues so I have to be dependent on Autocad forum.
I tired both the lisp first one throwed invalid argument. So I used second one.
(defun C:test ( / pl SS Point i )
(and
(setq pl (car (entsel "\nPick pline: ")))
(setq SS (ssget "_:L-I" '((0 . "CIRCLE"))))
(defun Point (pt)(if pt (entmakex (list (cons 0 "POINT")(cons 10 pt)))))
(repeat (setq i (sslength SS))
(Point (_GetCirclePlineTangentPoint (ssname SS (setq i (1- i))) pl))
)
)
(princ)
)
(defun _GetCirclePlineTangentPoint ( circle pline / cr p L mid tmp dis lc bc seg r )
(and
circle pline
(setq cr (cdr (assoc 40 (entget circle)))) ; circle radius
(setq p (cdr (assoc 10 (entget circle))))
(setq L (_PlineInfo pline))
(setq mid (lambda (p1 p2) (mapcar '(lambda (a b) (* 0.5 (+ a b))) p1 p2)))
(foreach itm (cdr L)
(setq lc (mid (cadr itm) (caddr itm))) ; line center
(setq dis (distance lc p))
(if (setq bc (nth 6 itm)) ; bulge center
(setq dis (min dis (distance bc p)))
)
(and (or (not tmp) (> tmp dis)) (setq tmp dis) (setq seg itm) )
); foreach
); and
(if (setq bc (nth 6 seg))
(setq r (polar bc (angle bc p) (nth 7 seg)))
(setq r (inters (cadr seg) (caddr seg) p (polar p (+ (* 0.5 PI) (angle (cadr seg) (caddr seg))) (distance (cadr seg) (caddr seg))) nil))
); if
; (Point r)
(if (not (equal (distance r p) cr 1e-6))
(prompt "\nThe circle is not tangent ot the pline.")
r
); if
); defun _GetCirclePlineTangentPoint
;; Modified sub, taken from here:
;; http://www.lee-mac.com/lisp/html/PolyInfoV1-3.html
(defun _PlineInfo ( pline / LM:lwvertices LM:bulgeradius LM:bulgecentre )
;; LW Vertices - Lee Mac
;; Returns a list of lists in which each sublist describes
;; the position, starting width, ending width and bulge of the
;; vertex of a supplied LWPolyline
(defun LM:lwvertices ( e )
(if (setq e (member (assoc 10 e) e))
(cons (list (assoc 10 e) (assoc 40 e) (assoc 41 e) (assoc 42 e) ) (LM:lwvertices (cdr e)))
)
)
;; Bulge Radius - Lee Mac
;; p1 - start vertex
;; p2 - end vertex
;; b - bulge
;; Returns the radius of the arc described by the given bulge and vertices
(defun LM:bulgeradius ( p1 p2 b ) (/ (* (distance p1 p2) (1+ (* b b))) 4 (abs b)))
;; Bulge Centre - Lee Mac
;; p1 - start vertex
;; p2 - end vertex
;; b - bulge
;; Returns the centre of the arc described by the given bulge and vertices
(defun LM:bulgecentre ( p1 p2 b ) (polar p1 (+ (angle p1 p2) (- (/ pi 2) (* 2 (atan b)))) (/ (* (distance p1 p2) (1+ (* b b))) 4 b)))
( ; Main
(lambda ( pline / _vl-some enx lst seg flg )
(setq _vl-some ; (_vl-some '(lambda (x) (if (= (* x x) (* 2 x)) x)) '(9 8 7 2 4 6 7 3)) >> 2
(lambda (tf L)
(cond
( (not L) L)
( (apply tf (list (car L))) )
( (_vl-some tf (cdr L)) )
); cond
); lambda
); setq _vl-some
(if
(and
(eq 'ENAME (type pline))
(setq enx (entget pline))
(member '(0 . "LWPOLYLINE") enx)
(setq lst (LM:lwvertices enx))
(setq seg 0)
)
(cons
(append '(SEG START END WIDTH1 WIDTH2 LENGTH)
(if (setq flg (_vl-some '(lambda ( x ) (not (zerop (cdr (assoc 42 x))))) lst))
'(CENTRE RADIUS)
)
)
(mapcar
(function
(lambda ( l1 l2 / b p q )
(setq
p (cdr (assoc 10 l1))
q (cdr (assoc 10 l2))
b (cdr (assoc 42 l1))
)
(append
(list (setq seg (1+ seg))) ; seg #
(list
p ; start
q ; end
)
(list
(cdr (assoc 40 l1)) ; width 1
(cdr (assoc 41 l1)) ; width 2
)
(if (zerop b)
(cons (distance p q) (if flg '(() ()))) ; length
(append
(list (abs (* (LM:bulgeradius p q b) (atan b) 4))) ; bulge-length
(list (LM:bulgecentre p q b)) ; centre
(list (LM:bulgeradius p q b)) ; radius
)
)
)
)
)
lst
(if (= 1 (logand 1 (cdr (assoc 70 enx))))
(append (cdr lst) (list (car lst)))
(cdr lst)
)
)
)
); if
); lambda
pline
)
); defun _PlineInfo
I have attached the dxf file to the thread for reference.