画示坡线,效果不错 CAD插件

画示坡线,效果不错 CAD插件

大多数的工作不需要另外加装很多线型
有时把图发出去,对方可能看不全

临时做个边坡设计,写了个画示坡线.lsp
说明及完整程序的见下载文件

主函数也方便改造成画其他线型—实际是线性阵列变种

;画示坡线,短线长可默认,画在那一侧按光标位置
(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))))
)
)
)
)

分享到 :