本帖最后由 meja 于 2023-6-30 21:14 编辑
若干年前画水面线用的,不过只能画水平的,今年突然想要改成任意方向都可以,而且要连续输入,突然不会了,求大神帮忙!
- ;;学习 ssadd函数 2011.6
- (defun newerr (NE)
- (if (/= NE "Function cancelled")
- (princ (strcat "\nError: " NE))
- )
- (setvar "OSMODE" OM)
- (setvar "CMDECHO" CE)
- (setvar "BLIPMODE" BM)
- (setvar "orthomode" orth)
- (princ)
- )
- (defun c:water
- (/ SP EP HT OM CE BM DX AN NX NU AX PX
- P1 P2 P3 P4 P5 XSP XEP XT tmpep tmpsp ST EN)
- (if (not (tblsearch "LAYER" "water"))
- (command "layer" "m" "water" "c" "1" "" ""))
- (command "layer" "s" "water" "")
- (setvar "ucsfollow" 0)
- (setq OM (getvar "OSMODE"))
- (setq CE (getvar "CMDECHO"))
- (setq BM (getvar "BLIPMODE"))
- (setq orth (getvar "orthomode"))
- (setvar "CMDECHO" 0)
- (setvar "BLIPMODE" 0)
- (setvar "orthomode" 1)
- (setvar "OSMODE" 1)
- (while ; 加入循环
- (setq SP (getpoint "\nPick start point of water: "))
- (setvar "OSMODE" 0)
- (setq EP (getpoint SP "\nPick end point of water: "))
- (setq ST SP)
- (setq EN (polar SP (ANGLE SP EP) (DISTANCE SP EP)))
- (setq XSP (car SP) XEP (car EP))
- (if (> XSP XEP)
- (progn
- (setq tmpsp SP)
- (setq tmpep (list(car EP) (cadr SP)))
- (setq SP tmpep)
- (setq EP tmpsp)
- )
- )
- (setq DX (distance SP EP)
- AN (angle SP EP)
- NU (/ DX 100)
- AX (+ AN (/ pi 2))
- P1 (list (+ 20 (car SP)) (- (cadr SP) 20))
- P2 (list (+ 40 (car SP)) (- (cadr SP) 30))
- P3 (list (+ 60 (car SP)) (- (cadr SP) 30))
- P4 (list (+ 80 (car SP)) (- (cadr SP) 20))
- P5 (polar SP 0 100)
- ss (ssadd) ;;2011.6.27
- )
- (repeat (fix NU)
- (command ".PLINE" SP P1 P2 P3 P4 P5 "")
- (setq ss (ssadd (entlast) ss)) ;;2011.6
- (setq SP P5
- P1 (list (+ 20 (car SP)) (- (cadr SP) 20))
- P2 (list (+ 40 (car SP)) (- (cadr SP) 30))
- P3 (list (+ 60 (car SP)) (- (cadr SP) 30))
- P4 (list (+ 80 (car SP)) (- (cadr SP) 20))
- P5 (polar SP 0 100)
- )
- )
- (setq ss (ssadd (entlast) ss)) ;;2011.6.27
- (command ".pedit" "m" ss "" "J" 0 "" )
- ) ;ebd while 结束循环
- (setvar "OSMODE" OM)
- (setvar "CMDECHO" CE)
- (setvar "BLIPMODE" BM)
- (setvar "orthomode" orth)
- (princ)
- );end
|