你好,motee-z,给你:
- (defun c:proftodist (/ sourcepl targetpl vlpl polydata verli hdist cnt pointlst)
- (vl-load-com)
- (setq sourcepl (car (entsel "\nSelect source polyline: ")) ; Get source polyline
- targetpl (car (entsel "\nSelect target polyline: ")) ; Get target polyline
- vlpl (vlax-ename->vla-object targetpl)
- ; Convert target polyline data to vla-object
- polydata (entget sourcepl) ; Get source polyline data
- verli (list) ; Define an empty list for vertices
- )
- (foreach v polydata ; Append vertices from source polyline
- (if (= 10 (car v))
- (setq verli (append verli (list (cdr v))))
- )
- )
- (setq verli (vl-sort verli
- (function (lambda (x1 x2) (< (car x1) (car x2))))
- ) ; Sort vertices in ascending order on x axis
- hdist (list) ; Create an empty list for horizontal distances
- cnt 0
- ) ; Set up a counter
- (while (/= cnt (1- (length verli))) ; Append cumulated horizontal distances
- (if (= cnt 0)
- (setq
- hdist (append hdist
- (list (- (car (nth (1+ cnt) verli)) (car (nth cnt verli))))
- )
- )
- (setq hdist (append hdist
- (list
- (+ (- (car (nth (1+ cnt) verli)) (car (nth cnt verli)))
- (last hdist)
- )
- )
- )
- )
- )
- (setq cnt (1+ cnt))
- )
- (setq pointlst (list)) ; Create an emplty list for the resulting vertices
- (foreach d hdist
- (setq pointlst (append pointlst (list (vlax-curve-GetpointatDist vlpl d))))
- )
- (foreach p pointlst ; Create the points along the target polyline
- (entmake
- (list
- '(0 . "POINT")
- '(100 . "AcDbEntity")
- '(62 . 256)
- (cons 8 "markchainage")
- '(100 . "AcDbPoint")
- (cons 10 p)
- )
- )
- )
- (princ)
- )
如果这是你要找的,请告诉我!
关于CAD89 |