1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
;22-04-2007
;th. Ma.
;draw the center lines of a pline arc
;dessine les axes d'un arc d'une pline
;CenterLinePline : cpl.lsp
(defun c:cpl(/ axe apoint1 apoint2 orientation mpoint distP1P2 angleP1P2
fleche centre rayon p1 p2 p3 p4 oldlay)
(setq apline (entsel "\nSelect arc of polyline...:"))
(setq apoint (cadr apline))
(setq axe (vlax-ename->vla-object(car apline)))
(setq position (vlax-curve-getClosestPointTo axe apoint))
(setq indexPosition (fix(vlax-curve-getParamAtPoint axe position)))
(setq orientation(* 4 (atan(vla-getbulge axe IndexPosition))))
(setq aPoint1(vlax-safearray->list(vlax-variant-value(vlax-get-property axe 'coordinate indexPosition))))
(setq indexPosition (+ 1 indexPosition))
(if (and(> indexPosition (-(/(length(vlax-get axe 'coordinates)) 2.0)2))
(/= (vlax-get axe 'closed)0)
)
(setq indexPosition 0)
)
(setq aPoint2(vlax-safearray->list(vlax-variant-value(vlax-get-property axe 'coordinate indexPosition))))
(if (= orientation 0.0)
(setq orientation(* 4 (atan(vla-getbulge axe IndexPosition))))
)
(vlax-release-object axe)
(setq mpoint (list
(/ (+(car apoint1)(car apoint2))2)
(/ (+(cadr apoint1)(cadr apoint2))2)
))
(setq distP1P2 (distance apoint1 apoint2))
(setq angleP1P2 (angle apoint1 apoint2))
(setq fleche (/ distP1P2 (* 2(tan (/ orientation 2.0)))))
(setq centre (polar mPoint (+ angleP1P2 (/ pi 2)) fleche))
(setq rayon (* 1.1(distance apoint1 centre)))
(setq p1 (list (car centre)(+(cadr centre)rayon)))
(setq p2 (list (car centre)(-(cadr centre)rayon)))
(setq p3 (list (+(car centre)rayon)(cadr centre)))
(setq p4 (list (-(car centre)rayon)(cadr centre)))
(command "undo" "be")
(setq oldlay (getvar"clayer"))
;(setvar "clayer" "am_7")
(command "line" "none" p1 p2 "")
(command "line" "none" p3 p4 "")
;(setvar "clayer" oldlay)
(command "undo" "E")
(princ)
) |
Partager