iCAx开思网
标题:
自写一个中心线命令.
[打印本页]
作者:
tonmy1999
时间:
2006-2-5 17:46
标题:
自写一个中心线命令.
此命令能群选目标, 程式能自动判断那些是圆。 当单个选取弧时,能画弧的中心线
使用方法:新建一个文件为acad.lsp ,将如下代码贴入,将此文件acad.lsp复制到autocad安装目录下的support目录中;点击CAD菜单: 工具\选项 \系统页 选中 (每个图都装载 acad.lsp 或者 load acad.lsp with every drawing)前的勾.
此命令自动将绘制的中心线放入cen层,如觉得线型不对,需要改下cen层的参数.
这是我命令的冰山一角,还有很多其它的命令。此处因为时间关系不详细贴出。日后再贴。
(DEFUN C:ce ()
(prompt "请选择圆或圆弧\n")
(setq s_obj1 nil)
(setq SystemLineScale(getvar "LTSCALE"))
(setq s_obj1(ssget))
(if (/= s_obj1 nil)
(progn
(SETQ S_Obj1_Total (SSLENGTH s_obj1))
(SETQ S_Obj1_Count 0)
(WHILE (< S_Obj1_Count S_Obj1_Total)
(SETQ Obj1_Count_List (ENTGET (SSNAME S_Obj1 S_Obj1_Count)))
(setq Obj1_Count_Type(CDR (ASSOC 0 Obj1_Count_List)))
(if (= Obj1_Count_Type "ARC")
(progn
(setq ArcStartAng(CDR (ASSOC 50 Obj1_Count_List)))
(setq ArcEndAng(CDR (ASSOC 51 Obj1_Count_List)))
(setq ArcNipAngle(NipAngle_Fun ArcStartAng ArcEndAng))
(setq ArcDrawFlag (if(>= ArcNipAngle PI) 1 0))
(if (= S_Obj1_Total 1)
(progn
(Setq ArcDrawFlag 1)
)
)
)
)
(IF (OR (= Obj1_Count_Type "CIRCLE") (and (= ArcDrawFlag 1) (= Obj1_Count_Type "ARC")))
(PROGN
(SETQ Center_Point(CDR (ASSOC 10 Obj1_Count_List)))
(SETQ Radius (CDR (ASSOC 40 Obj1_Count_List)))
(setq Cons_210(nth 2 (cdr(assoc 210 Obj1_Count_List))))
(if (< Cons_210 0)
(progn
(setq Center_Point_x(nth 0 Center_Point))
(setq Center_Point_x_New(* Cons_210 Center_Point_X))
(setq Center_Point(subst Center_Point_x_New Center_Point_x Center_Point))
)
)
(SETQ New_Dis (* Radius 1.2))
(setq New_Hor_SP(POLAR Center_Point 0 New_Dis))
(setq New_Hor_EP(POLAR Center_Point PI New_Dis))
(setq New_Ver_SP(POLar Center_Point (* PI 1.5) New_Dis))
(setq New_Ver_EP(POLar Center_Point (* PI 0.5) New_Dis))
(setq New_Line_Scale(/ Radius 50 SystemLineScale))
(setq Line_Hor_List(List (cons 0 "LINE") (cons 8 "CEN") (cons 10 New_Hor_SP) (cons 11 New_Hor_EP) (cons 48 New_Line_Scale)))
(setq Line_Ver_List(List (cons 0 "LINE") (cons 8 "CEN") (cons 10 New_Ver_SP) (cons 11 New_Ver_EP) (cons 48 New_Line_Scale)))
(entmake Line_Hor_List)
(entmake Line_Ver_List)
(entmod Line_Hor_List)
(entmod Line_Ver_List)
)
)
(SETQ S_Obj1_Count (1+ S_Obj1_Count))
)
)
);end if (/= s_obj1 nil)
)
欢迎光临 iCAx开思网 (https://www.icax.org/)
Powered by Discuz! X3.3