马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
 - ;;; Calculate distance between 2 specified points on curve object
- ;;; Required Subroutines: AT:DrawX
- ;;; Alan J. Thompson, 03.20.10 / 03.28.10
- (defun c:DBP (/ *error* #Obj #Pnt #Pnt2 #D1 #D2 #List #Dist ent)
- (vl-load-com)
- (redraw)
- (setq *error* (lambda (m) (and (= (type #Obj) 'VLA-OBJECT) (vla-highlight #Obj :vlax-false))))
- (and
- (AT:DrawX (setq #Pnt (getpoint "\nSpecify first point on curve: ")) 3)
- (or (setq #Obj
- (ssget "c"
- (polar #Pnt -0.7854 (* 0.01 (getvar 'viewsize)))
- (polar #Pnt 2.3562 (* 0.01 (getvar 'viewsize)))
- '((0 . "ARC,CIRCLE,ELLIPSE,LINE,*POLYLINE,SPLINE"))
- )
- )
- (alert "Point must be on curve!")
- ) ;_ or
- (AT:DrawX (setq #Pnt2 (getpoint #Pnt "\nSpecify next point on curve: ")) 3)
- (or (and
- (setq #Obj
- (ssget "c"
- (polar #Pnt2 -0.7854 (* 0.01 (getvar 'viewsize)))
- (polar #Pnt2 2.3562 (* 0.01 (getvar 'viewsize)))
- '((0 . "ARC,CIRCLE,ELLIPSE,LINE,*POLYLINE,SPLINE"))
- )
- )
- (vl-some (function
- (lambda (x)
- (and (setq ent x)
- (vlax-curve-getdistatpoint x (trans #Pnt 1 0))
- (vlax-curve-getdistatpoint x (trans #Pnt2 1 0))
- )
- )
- )
- (vl-remove-if 'listp (mapcar 'cadr (ssnamex #Obj)))
- )
- (setq #D2 (vlax-curve-getDistAtPoint (setq #Obj (vlax-ename->vla-object ent)) (trans #Pnt2 1 0)))
- (setq #D1 (vlax-curve-getDistAtPoint #Obj (trans #Pnt 1 0)))
- (not (vla-highlight #Obj :vlax-true))
- ) ;_ and
- (alert "Points must be on curve!")
- ) ;_ or
- (progn
- (setq #Dist (car (setq #List (vl-sort (list #D1 #D2) '<))))
- (while (< #Dist (- (cadr #List) (/ (cadr #List) 100.)))
- (grdraw
- (trans (vlax-curve-getPointAtDist #Obj #Dist) 0 1)
- (trans (vlax-curve-getPointAtDist #Obj (setq #Dist (+ (/ (cadr #List) 100.) #Dist))) 0 1)
- 1
- ) ;_ grdraw
- ) ;_ while
- (princ)
- (alert (strcat "Distance between points on curve: "
- (rtos (abs (- #D1 #D2)) (getvar 'lunits) (getvar 'luprec))
- ) ;_ strcat
- ) ;_ alert
- ) ;_ progn
- ) ;_ and
- (*error* nil)
- (princ)
- ) ;_ defun
- ;;; Draw and "X" vector at specified point
- ;;; P - Placement point for "X"
- ;;; C - Color of "X" (must be integer b/w 1 & 255)
- ;;; Alan J. Thompson, 10.31.09 / 03.26.10
- (defun AT:DrawX (P C / d n)
- (if (and (vl-consp P)
- (setq d (* (getvar "VIEWSIZE") 0.02))
- ) ;_ and
- (progn (grvecs (cons C
- (mapcar
- (function (lambda (#) (polar P (* # pi) d) ))
- '(0.25 1.25 0.75 1.75)
- ) ;_ mapcar
- ) ;_ cons
- ) ;_ grvecs1
- P
- ) ;_ progn
- ) ;_ if
- ) ;_ defun
|