| 
积分15274明经币 个注册时间2016-1-6在线时间 小时威望 金钱 个贡献 激情  
 | 
 
 发表于 2022-8-28 09:16:14
|
显示全部楼层 
| 画示坡线,短线长可默认,画在那一侧按光标位置
 
 (defun c:spx ( / str ob p1 p2 p3 fx)
 
 (while(setq ob(entsel “\n选择线:”))
 
 (setq p1(cadr ob) ob(car ob))
 
 (if(wcmatch (cdr(assoc 0(entget ob)))”*POLYLINE,LINE,SPLINE,CIRCLE,ARC,ELLIPSE”)
 
 (progn
 
 (setq ob(vlax-ename->vla-object ob))
 
 (setq p1(vlax-curve-getclosestpointto ob p1))
 
 (princ “\n光标位为示坡线方向”)
 
 (setq str “\n指定短线长”)
 
 (if spxdist (setq str(strcat str “<“(rtos spxdist) “>:”)))
 
 (while(cond
 
 ((and (setq p3(getpoint p1 str))(> (setq d(distance p1 p3))0))
 
 (setq spxdist d)nil
 
 )
 
 (spxdist(setq p3(polar p1(angle p1(cadr(grread ‘(2 13)))) spxdist))nil)
 
 ;获取当前光标坐标(cadr(grread ‘(2 13)))或(cadr(grread T 15 0))
 
 (t)
 
 ));可使用默认短线长度spxdist
 
 (setq p2(vlax-curve-getPointAtDist ob (+ spxdist(vlax-curve-getDistAtPoint ob p1))))
 
 (setq fx(- (angle p2 p3)(angle p1 p2)))
 
 (shipoxian ob spxdist (not(or(and(< fx 0)(> fx (- 0 pi)))(> fx pi))))
 
 )
 
 )
 
 )
 
 )
 | 
 |