- (defun c:ccc()
- (if (progn
- (progn "\n请选择多段线: ")
- (setq EntSsa (ssget ":S" '((0 . "lwpolyline"))))
- )
- (progn
- (mapcar 'set '(pai Ent pan PPt) (car (ssnamex EntSsa)))
- (setq PPt (cadr PPt)) ;选择多段线时的拾取点
- (If (setq Pt (getpoint PPt "\n请指定构造线通过点: "))
- (progn
- (setq OBj (vlax-ename->vla-object Ent))
- ;多段线上距拾取点最近的点
- (setq Pt0 (vlax-curve-getclosestpointto OBj PPt))
- (setq par (vlax-curve-getParamAtPoint OBj Pt0))
- (setq pai (fix par))
- (setq pan (vlax-curve-getendparam Obj))
- ;拾取点所在子段的凸度(等于0为直线段,否则为圆弧段)
- (setq bul (vla-GetBulge OBj pai))
- (if (and (or (not (equal pai 0 1e-6)) ;不是起点
- (not (equal pai pan 1e-6)) ;不是止点
- )
- (equal bul 0 1e-6) ;子段不是圆弧
- )
- (progn
- ;过Pt0点的切线方向向量
- (setq ptv (vlax-curve-getFirstDeriv Obj par))
- ;; 创建构造线
- (entmake (list '(0 . "XLINE")
- '(100 . "AcDbEntity")
- '(100 . "AcDbXline")
- (cons 10 Pt)
- (cons 11 Ptv)
- )
- )
- )
- )
-
- )
- )
- )
- )
- )
|