本帖最后由 阿然 于 2012-12-8 10:48 编辑
我有个想法,没实践过,获取两条等高线的长度,然后按照等比例步长用(vlax-curve-getPointAtDist curve-objdist)获取在两条等高线的点,然后取这两个点的中点,得到一串点表,根据这些点表绘制polyline
- (vl-load-com)
- (setq *AcadDoc* (vla-get-ActiveDocument (vlax-get-Acad-Object)))
- (setq *MoSpace* (vla-get-ModelSpace *AcadDoc*))
- (defun c:dgx-insert (/ pline1 pline2 len1 len2
- step step1 step2 i pt
- pt1 pt2 ptlist ptlistlen
- ptsafearray elev1 elev2 elev newpline
- )
- (if (setq pline1 (vlax-ename->vla-object
- (car (entsel "\n选择第一条等高线:"))
- )
- )
- (if (setq pline2 (vlax-ename->vla-object
- (car (entsel "\n选择第二条等高线:"))
- )
- )
- (progn
- (setq len1 (vlax-get-property pline1 'length)
- len2 (vlax-get-property pline2 'length)
- elev1 (vlax-get-property pline1 'Elevation )
- elev2 (vlax-get-property pline2 'Elevation )
- elev (/ (+ elev1 elev2) 2)
- )
- (if (setq step (getint "\n请输入内插步长:"))
- (setq step1 (/ len1 step)
- step2 (/ len2 step)
- i 0
- )
- )
- (while (<= i step)
- (setq pt1 (vlax-curve-getPointAtDist pline1 (* i step1))
- pt2 (vlax-curve-getpointatdist pline2 (* i step2))
- )
- (setq pt (mapcar '(lambda (x y) (/ (+ x y) 2.0)) pt1 pt2))
- (setq ptlist (append ptlist pt))
- (setq i (1+ i))
- )
- (setq ptlistlen (1- (length ptlist)))
- (setq ptsafearray
- (vlax-make-safearray
- vlax-vbdouble
- (cons 0 ptlistlen)
- )
- )
- (setq ptsafearray (vlax-safearray-fill ptsafearray ptlist))
- (setq newpline (vla-AddPolyline *mospace* ptsafearray))
- (vlax-put-property newpline 'Elevation elev)
- )
- )
- )
- )
|