嘿,我用了一些很类似的东西。
- ;;; Draw line perpendicular from selected curve
- ;;; Required Subroutines: AT:Entsel
- ;;; Alan J. Thompson, 09.29.09
- (defun c:LPer (/ *error* #Ent #Obj #Point)
- (setq *error* (lambda (x) (and #Obj (vl-catch-all-apply 'vla-highlight (list #Obj :vlax-false)))))
- (and
- (setq #Ent (AT:Entsel nil "\nSelect curve: " '((0 . "*POLYLINE,ARC,LINE,CIRCLE,ELLIPSE")) nil))
- (setq #Obj (vlax-ename->vla-object (car #Ent)))
- (not (vla-highlight #Obj :vlax-true))
- (while (setq #Point (getpoint "\nSpecify point for line: "))
- (entmake (list '(0 . "LINE")
- (cons 10 (vlax-curve-getclosestpointto (car #Ent) (trans #Point 1 0) T))
- (cons 11 (trans #Point 1 0))
- ) ;_ list
- ) ;_ entmake
- ) ;_ while
- ) ;_ and
- (*error* nil)
- (princ)
- ) ;_ defun
唯一的问题是,使用3DPolyline时,顶点高程将导致导出最近点。它通常会突然到达终点或其他地方。这真的很烦人。这就是为什么在试图获取三维多段线上的点时,必须使用(osnap(cadr ent)“_near”)而不是(vlax curve getclosestpointto(car ent)(cadr ent))。 |