快速绘制台阶轴
首先感谢明经通道,和这个源程序的作者,出自明经忘记作者了,再感谢QQ:2248614534的指点让纯小白也可以修改别人的码来自用
感谢 baitang36 的合并DCL和lsp文件
这个可以快速绘制阶梯轴命令:shaft
;<<<<<<合并DCL和lsp文件baitang36 20220606 >>>>>>
(setq dcl_file (open (setq tmp-dcl-file-name (vl-filename-mktemp nil nil".DCL")) "w"))
(progn
(foreach x
'(
"shaft:dialog{ "
" label=\"常用轴段的设计与绘图\";"
" :boxed_row{ "
" :column { :image{"
" color=5;"
" aspect_ratio=0.7;"
" key=shaft_image;"
" width=35;"
" fixed_height=true;"
" }"
" }"
" :column{ "
" :row{"
" :button{"
" label=\"轴段特征选择...\"; "
" key=\"shaft_type\";"
" }"
" }"
" :boxed_column{ label=\"轴的绘制基准点(起始点):\";"
" :button{ label=\"从图形屏幕选择点<<\"; "
" key=\"pick_point\";"
" }"
" :edit_box{label=\"X轴座标:\"; "
" key=\"start_x\"; "
" edit_width=6;}"
" :edit_box{label=\"Y轴座标:\";"
" key=\"start_y\";"
" edit_width=6;}"
" }"
" } "
" }"
" :boxed_row{"
" :boxed_column{label=\"结构参数输入:\";"
" :row { "
" :edit_box{label=\"轴直径D(mm) \";"
" key=\"shaft_D\";"
" edit_width=6;"
" }"
" :edit_box{label=\"轴长L(mm)\";"
" key=\"shaft_L\";"
" edit_width=6;"
" } "
" }"
" :row{"
" :edit_box{label=\"倒角宽B(mm)\";"
" key=\"cham_B\";"
" edit_width=6;"
" }"
" :edit_box{label=\"键槽宽W\";"
" key=\"key_w\";"
" edit_width=6;"
" }"
" } "
" :row{:edit_box{label=\"距离L2(mm) \";"
" key=\"key_L2\"; "
" edit_width=6;"
" } "
" :edit_box{label=\"键长L1(mm)\";"
" key=\"key_L1\";"
" edit_width=6;"
" }"
" "
" }"
" }"
" }"
" ok_cancel;"
" }"
"/*轴段特征选择对话框*/ "
" stype:dialog{ label=\"轴段特征结构类型\";"
" :boxed_column{ "
" :row{"
" :image_button{color=2;width=22;height=9;key=\"sh1\";}"
" :image_button{color=2;width=22;height=9;key=\"sh2\";}"
" :image_button{color=2;width=22;height=9;key=\"sh3\";}"
" :image_button{color=2;width=22;height=9;key=\"sh4\";}"
" "
" } "
" :row{ "
" :image_button{color=2;width=22;height=9;key=\"sh5\";}"
" :image_button{color=2;width=22;height=9;key=\"sh6\";}"
" :image_button{color=2;width=22;height=9;key=\"sh7\";}"
" :image_button{color=2;width=22;height=9;key=\"sh8\";}"
" "
" } "
" } "
" ok_cancel; "
" }"
) (write-line x dcl_file) )
(setq dcl_file (close dcl_file)))
;;;/*首先编写主调函数,定义程序所需要的局部变量,aug为DCL文件的识别ID标志;
;;;what为隐藏对话框的动作判断变量;shaft_type为轴段类型;d0、L、L1、L2、w
;;;及alph为轴段特征尺寸。*/
(defun c:shaft (/ aug what shaft_type d0 d1 L L1 L2 w alph)
(setq shaft_type
1
d0 0
L1 0
L2 0
w 0
b 2.0
L 0
alph 0
)
(setq ssnil
ss1 nil
)
(setq ss (ssadd))
(setq ss1 (ssadd))
(setq start (list 0.0 0.0))
(setvar "cmdecho" 0)
(command "ltscale" 2)
(if (not (tblsearch "Layer" "1.轮廓粗实线"))
(command "layer" "n" "1.轮廓粗实线" "c" "7" "1.轮廓粗实线" "l" "Continuous" "1.轮廓粗实线" "lw" "0.3" "1.轮廓粗实线" ""));;;创建图层
(if (not (tblsearch "Layer" "2.图形细实线"))
(command "layer" "n" "2.图形细实线" "c" "3" "2.图形细实线" "l" "Continuous" "2.图形细实线" "lw" "0.13" "2.图形细实线" ""));;;创建图层
(if (not (tblsearch "Layer" "3.虚线"))
(command "layer" "n" "3.虚线" "c" "2" "3.虚线" "l" "ACAD_ISO02W100" "3.虚线" "lw" "0.13" "3.虚线" ""));;;创建图层
(if (not (tblsearch "Layer" "4.中心点划线"))
(command "layer" "n" "4.中心点划线" "c" "1" "4.中心点划线" "l" "CENTER2" "4.中心点划线" "lw" "0.13" "4.中心点划线" ""));;;创建图层
(if (not (tblsearch "Layer" "10.标注"))
(command "layer" "n" "10.标注" "c" "94" "10.标注" "l" "Continuous" "10.标注" "lw" "0.13" "10.标注" ""));;;创建图层
(command "osmode" "0")
(shaft_start)
(while (< 0 what)
(shaft_action)
(cond
((= what 2) (shaft_pick) (shaft_set))
((= what 1) (shaft_draw))
)
)
(unload_dialog aug)
(setvar "cmdecho" 1)
)
;-------------------------图案1中间无键------------------------------
(defun feature1 (/ p1 p2 p3 p4 p3b p4b pc1 pc2)
;;;计算轴段的四个顶点坐标,使用polar函数获取相对于start(起始点)的其他点的坐标。
;;;其中alph为旋转角;d为轴径;b为倒角大小;pi为常数,即3.14159226;L为轴段长。
(setq
a (* pi (/ 45.0 180.0))
;;;换算角度为弧度
p3b (polar start alph b)
p4b (polar start alph b)
p3 (polar p3b (+ alph (* 0.5 pi)) (/ d 2.0))
p4 (polar p4b (+ alph (* -0.5 pi)) (/ d 2.0))
p1 (polar p3 (+ alph (+ pi a)) (/ b (cos a)))
p2 (polar p4 (+ alph (- pi a)) (/ b (cos a)))
)
(command "layer" "s" "1.轮廓粗实线" "");;;设置当前图层
;;;设定绘图的图层draw
(command "pline" p3 "w" 0.3 "" p1 p2 p4 "cl")
;;;使用pline命令绘制特征,线宽设定为0.15,并使用"cl"将特征封闭。
(setq ss (ssadd (entlast)))
将绘制的图形赋给选择集ss
(setq p1 (polar p3 alph (- L (* 2.0 b)))
p2 (polar p4 alph (- L (* 2.0 b)))
)
(command "pline" p3 p1 p2 p4 "")
(setq ss (ssadd (entlast) ss))
(setq
p3 (polar p1 (- alph a) (/ b (cos a)))
p4 (polar p2 (+ alph a) (/ b (cos a)))
)
(command "pline" p1 p3 p4 p2 "")
(setq ss (ssadd (entlast) ss))
;;;绘制中心线
(command "layer" "s" "4.中心点划线" "");;;设置当前图层
;;;设定绘图的图层center
(setq pc1 (polar start (+ alph pi) 5.0))
;;;计算中心线的起点坐标
(setq pc2 (polar pc1 alph (+ L 10.0)))
;;;计算中心线终点纵坐标
(command "line" pc1 pc2 "")
;;;绘制中心线
(setq ss1 (ssadd (entlast)))
;;;将绘制的图形赋给选择集ss1
)
;-------------------------图案2中间有键------------------------------
(defun feature2 (/ p1 p2 p3 p4 p3b p4b pc1 pc2)
;;;/*计算轴段的四个顶点坐标,使用polar函数获取相对于start(起始点)的其他点的坐标。
;;;其中alph为旋转角;d为轴径;b为倒角大小;pi为常数,即3.14159226;L为轴段长;L1为键槽长;L2为键槽与轴端的距离。*/
(setq
a (* pi (/ 45.0 180.0))
;;;换算角度为弧度
p3b (polar start alph b)
p4b (polar start alph b)
p3 (polar p3b (+ alph (* 0.5 pi)) (/ d 2.0))
p4 (polar p4b (+ alph (* -0.5 pi)) (/ d 2.0))
p1 (polar p3 (+ alph (+ pi a)) (/ b (cos a)))
p2 (polar p4 (+ alph (- pi a)) (/ b (cos a)))
)
(command "layer" "s" "1.轮廓粗实线" "");;;设置当前图层
(command "pline" p3 "w" 0.3 "" p1 p2 p4 "cl")
(setq ss (ssadd (entlast)))
(setq p1 (polar p3 alph (- L (* 2.0 b)))
p2 (polar p4 alph (- L (* 2.0 b)))
)
(command "pline" p3 p1 p2 p4 "")
(setq ss (ssadd (entlast) ss))
(setq
p3 (polar p1 (- alph a) (/ b (cos a)))
p4 (polar p2 (+ alph a) (/ b (cos a)))
)
(command "pline" p1 p3 p4 p2 "")
(setq ss (ssadd (entlast) ss))
;;;绘制键槽部分(需调整)
(setq pk0 (polar start alph L2)
pk1 (polar pk0 (+ alph (* 0.25 pi)) (* (sqrt 2.0) (/ w 2.0)))
pk2 (polar pk0 (+ alph (* -0.25 pi)) (* (sqrt 2.0) (/ w 2.0)))
pk3 (polar pk1 alph (- L1 w))
pk4 (polar pk2 alph (- L1 w))
pk5 (polar pk0 alph l1)
)
(command "pline"
pk2
"w"
0.3
""
pk4
"arc"
"radius"
(/ w 2.0)
pk5
pk3
"line"
pk1
"arc"
"radius"
(/ w 2.0)
pk0
"cl"
)
(setq ss (ssadd (entlast) ss))
;;;绘制中心线
(command "layer" "s" "4.中心点划线" "");;;设置当前图层
;设定绘图的图层center
(setq pc1 (polar start (+ alph pi) 5.0)) ;计算中心线的起点坐标
(setq pc2 (polar pc1 alph (+ L 10.0))) ;计算中心线终点纵坐标
(command "line" pc1 pc2 "") ;绘制中心线
(setq ss1 (ssadd (entlast))) ;将绘制的图形赋给选择集ss1
)
;-------------------------图案3卧键左------------------------------
(defun feature3 (/ p1 p2 p3 p4 p3b p4b pc1 pc2)
;;;/*计算轴段的四个顶点坐标,使用polar函数获取相对于start(起始点)的其他点的坐标。
;;;其中alph为旋转角;d为轴径;b为倒角大小;pi为常数,即3.14159226;L为轴段长;L1为键槽长;L2为键槽与轴端的距离。*/
(setq
a (* pi (/ 45.0 180.0))
;;;换算角度为弧度
p3b (polar start alph b)
p4b (polar start alph b)
p3 (polar p3b (+ alph (* 0.5 pi)) (/ d 2.0))
p4 (polar p4b (+ alph (* -0.5 pi)) (/ d 2.0))
p1 (polar p3 (+ alph (+ pi a)) (/ b (cos a)))
p2 (polar p4 (+ alph (- pi a)) (/ b (cos a)))
)
(command "layer" "s" "1.轮廓粗实线" "");;;设置当前图层
(command "pline" p3 "w" 0.3 "" p1 p2 p4 "cl")
(setq ss (ssadd (entlast)))
(setq p1 (polar p3 alph (- L b))
p2 (polar p4 alph (- L b))
)
(command "pline" p3 "w" 0.3 "" p1 p2 p4 "")
(setq ss (ssadd (entlast) ss))
;;;绘制键槽部分
(setq pk0 (polar start alph L2)
pk1 (polar pk0 (+ alph (* 0.25 pi)) (* (sqrt 2.0) (/ w 2.0)))
pk2 (polar pk0 (+ alph (* -0.25 pi)) (* (sqrt 2.0) (/ w 2.0)))
pk3 (polar pk1 alph (- L1 w))
pk4 (polar pk2 alph (- L1 w))
pk5 (polar pk0 alph l1)
)
(command "pline"
pk2
"w"
0.3
""
pk4
"arc"
"radius"
(/ w 2.0)
pk5
pk3
"line"
pk1
"arc"
"radius"
(/ w 2.0)
pk0
"cl"
)
(setq ss (ssadd (entlast) ss))
;;;绘制中心线
(command "layer" "s" "4.中心点划线" "");;;设置当前图层
;设定绘图的图层center
(setq pc1 (polar start (+ alph pi) 5.0)) ;计算中心线的起点坐标
(setq pc2 (polar pc1 alph (+ L 10.0))) ;计算中心线终点纵坐标
(command "line" pc1 pc2 "") ;绘制中心线
(setq ss1 (ssadd (entlast))) ;将绘制的图形赋给选择集ss1
)
;-------------------------图案4卧键右------------------------------
(defun feature4 (/ p1 p2 p3 p4 p3b p4b pc1 pc2)
;;;计算轴段的四个顶点坐标,使用polar函数获取相对于start(起始点)的其他点的坐标。
;;;其中alph为旋转角;d为轴径;b为倒角大小;pi为常数,即3.14159226;L为轴段长。
(setq
a (* pi (/ 45.0 180.0))
;;;换算角度为弧度
p3b (polar start alph 0)
p4b (polar start alph 0)
p3 (polar p3b (+ alph (* 0.5 pi)) (/ d 2.0))
p4 (polar p4b (+ alph (* -0.5 pi)) (/ d 2.0))
)
(command "layer" "s" "1.轮廓粗实线" "");;;设置当前图层
(setq p1 (polar p3 alph (- L b))
p2 (polar p4 alph (- L b))
)
(command "pline" p3 p1 p2 p4 "cl")
(setq ss (ssadd (entlast) ss))
(setq
p3 (polar p1 (- alph a) (/ b (cos a)))
p4 (polar p2 (+ alph a) (/ b (cos a)))
)
(command "pline" p1 p3 p4 p2 "")
(setq ss (ssadd (entlast) ss))
;;;绘制键槽部分
(setq pk0 (polar start alph (- L (+ L1 L2)))
pk1 (polar pk0 (+ alph (* 0.25 pi)) (* (sqrt 2.0) (/ w 2.0)))
pk2 (polar pk0 (+ alph (* -0.25 pi)) (* (sqrt 2.0) (/ w 2.0)))
pk3 (polar pk1 alph (- L1 w))
pk4 (polar pk2 alph (- L1 w))
pk5 (polar pk0 alph l1)
)
(command "pline"
pk2
"w"
0.3
""
pk4
"arc"
"radius"
(/ w 2.0)
pk5
pk3
"line"
pk1
"arc"
"radius"
(/ w 2.0)
pk0
"cl"
)
(setq ss (ssadd (entlast) ss))
;;;绘制中心线
(command "layer" "s" "4.中心点划线" "");;;设置当前图层
;;;设定绘图的图层center
(setq pc1 (polar start (+ alph pi) 5.0))
;;;计算中心线的起点坐标
(setq pc2 (polar pc1 alph (+ L 10.0)))
;;;计算中心线终点纵坐标
(command "line" pc1 pc2 "")
;;;绘制中心线
(setq ss1 (ssadd (entlast)))
;;;将绘制的图形赋给选择集ss1
)
;-------------------------图案5通键左------------------------------
(defun feature5 (/ p1 p2 p3 p4 p3b p4b pc1 pc2)
;;;/*计算轴段的四个顶点坐标,使用polar函数获取相对于start(起始点)的其他点的坐标。
;;;其中alph为旋转角;d为轴径;b为倒角大小;pi为常数,即3.14159226;L为轴段长;L1为键槽长;L2为键槽与轴端的距离。*/
(setq
a (* pi (/ 45.0 180.0))
;;;换算角度为弧度
p3b (polar start alph b)
p4b (polar start alph b)
p3 (polar p3b (+ alph (* 0.5 pi)) (/ d 2.0))
p4 (polar p4b (+ alph (* -0.5 pi)) (/ d 2.0))
p1 (polar p3 (+ alph (+ pi a)) (/ b (cos a)))
p2 (polar p4 (+ alph (- pi a)) (/ b (cos a)))
p5 (polar p3b (+ alph (* 0.5 pi)) (/ w 2.0))
p6 (polar p4b (+ alph (* -0.5 pi)) (/ w 2.0))
)
(command "layer" "s" "1.轮廓粗实线" "");;;设置当前图层
(command "pline" p5 "w" 0.3 "" p3 p1 p2 p4 p6 "")
(setq ss (ssadd (entlast)))
(setq p1 (polar p3 alph (- L b))
p2 (polar p4 alph (- L b))
)
(command "pline" p3 "w" 0.3 "" p1 p2 p4 "")
(setq ss (ssadd (entlast) ss))
;;;绘制键槽部分
(setq pk0 (polar start alph (- L L1))
pk1 (polar start (+ alph (* 0.5 pi)) (/ w 2.0))
pk2 (polar start (+ alph (* -0.5 pi)) (/ w 2.0))
pk3 (polar pk1 alph (- L1 (/ w 2.0)))
pk4 (polar pk2 alph (- L1 (/ w 2.0)))
pk5 (polar start alph L1)
)
(command "pline"
pk1
"w"
0.3
""
pk3
"arc"
"radius"
(/ w 2.0)
pk0
pk4
"line"
pk2
""
)
(setq ss (ssadd (entlast) ss))
;;;绘制中心线
(command "layer" "s" "4.中心点划线" "");;;设置当前图层
;设定绘图的图层center
(setq pc1 (polar start (+ alph pi) 5.0)) ;计算中心线的起点坐标
(setq pc2 (polar pc1 alph (+ L 10.0))) ;计算中心线终点纵坐标
(command "line" pc1 pc2 "") ;绘制中心线
(setq ss1 (ssadd (entlast))) ;将绘制的图形赋给选择集ss1
)
;-------------------------图案6通键右------------------------------
(defun feature6 (/ p1 p2 p3 p4 p3b p4b pc1 pc2)
;;;/*计算轴段的四个顶点坐标,使用polar函数获取相对于start(起始点)的其他点的坐标。
;;;其中alph为旋转角;d为轴径;b为倒角大小;pi为常数,即3.14159226;L为轴段长;L1为键槽长。 */
(setq
a (* pi (/ 45.0 180.0)) ;换算角度为弧度
p1 (polar start (+ alph (* 0.5 pi)) (/ d 2.0))
p2 (polar start (+ alph (* -0.5 pi)) (/ d 2.0))
p3 (polar p1 alph (- L b))
p4 (polar p2 alph (- L b))
p3b (polar start alph (- L b))
p4b (polar start alph (- L b))
p3b (polar p3b (+ alph (* 0.5 pi)) (/ w 2.0))
p4b (polar p4b (+ alph (* -0.5 pi)) (/ w 2.0))
)
(command "layer" "s" "1.轮廓粗实线" "");;;设置当前图层
(command "pline" p4b "w" 0.3 "" p4 p2 p1 p3 p3b "")
(setq ss (ssadd (entlast)))
(setq
p1 (polar p3 (- alph a) (/ b (cos a)))
p2 (polar p4 (+ alph a) (/ b (cos a)))
)
(command "pline" p3 p1 p2 p4 "")
(setq ss (ssadd (entlast) ss))
;;;计算键槽的特征点并绘制键槽
(setq pk0 (polar start alph (- L L1))
pk1 (polar pk0 (+ alph (* 0.25 pi)) (* (sqrt 2.0) (/ w 2.0)))
pk2 (polar pk0 (+ alph (* -0.25 pi)) (* (sqrt 2.0) (/ w 2.0)))
pk3 (polar pk1 alph (- L1 (/ w 2.0)))
pk4 (polar pk2 alph (- L1 (/ w 2.0)))
)
(command "pline"
pk2
"w"
0.3
""
pk4
pk3
"line"
pk1
"arc"
"radius"
(/ w 2.0)
pk0
"cl"
)
(setq ss (ssadd (entlast) ss))
;;;绘制中心线
(command "layer" "s" "4.中心点划线" "");;;设置当前图层
;;;设定绘图的图层center
(setq pc1 (polar start (+ alph pi) 5.0)) ;计算中心线的起点坐标
(setq pc2 (polar pc1 alph (+ L 10.0))) ;计算中心线终点纵坐标
(command "line" pc1 pc2 "") ;绘制中心线
(setq ss1 (ssadd (entlast))) ;将绘制的图形赋给选择集ss1
)
;-------------------------图案7无键左------------------------------
(defun feature7 (/ p1 p2 p3 p4 p3b p4b pc1 pc2)
;;;/*计算轴段的四个顶点坐标,使用polar函数获取相对于start(起始点)的其他点的坐标。
;;;其中alph为旋转角;d为轴径;b为倒角大小;pi为常数,即3.14159226;L为轴段长;L1为键槽长;L2为键槽与轴端的距离。*/
(setq
a (* pi (/ 45.0 180.0))
;;;换算角度为弧度
p3b (polar start alph b)
p4b (polar start alph b)
p3 (polar p3b (+ alph (* 0.5 pi)) (/ d 2.0))
p4 (polar p4b (+ alph (* -0.5 pi)) (/ d 2.0))
p1 (polar p3 (+ alph (+ pi a)) (/ b (cos a)))
p2 (polar p4 (+ alph (- pi a)) (/ b (cos a)))
)
(command "layer" "s" "1.轮廓粗实线" "");;;设置当前图层
(command "pline" p3 "w" 0.3 "" p1 p2 p4 "cl")
(setq ss (ssadd (entlast)))
(setq p1 (polar p3 alph (- L b))
p2 (polar p4 alph (- L b))
)
(command "pline" p3 "w" 0.3 "" p1 p2 p4 "")
(setq ss (ssadd (entlast) ss))
;;;绘制中心线
(command "layer" "s" "4.中心点划线" "");;;设置当前图层
(setq pc1 (polar start (+ alph pi) 5.0)) ;计算中心线的起点坐标
(setq pc2 (polar pc1 alph (+ L 10.0))) ;计算中心线终点纵坐标
(command "line" pc1 pc2 "") ;绘制中心线
(setq ss1 (ssadd (entlast))) ;将绘制的图形赋给选择集ss1
)
;-------------------------图案8无键右------------------------------
(defun feature8 (/ p1 p2 p3 p4 p3b p4b pc1 pc2)
;;;计算轴段的四个顶点坐标,使用polar函数获取相对于start(起始点)的其他点的坐标。
;;;其中alph为旋转角;d为轴径;b为倒角大小;pi为常数,即3.14159226;L为轴段长。
(setq
a (* pi (/ 45.0 180.0))
;;;换算角度为弧度
p3b (polar start alph 0)
p4b (polar start alph 0)
p3 (polar p3b (+ alph (* 0.5 pi)) (/ d 2.0))
p4 (polar p4b (+ alph (* -0.5 pi)) (/ d 2.0))
)
(command "layer" "s" "1.轮廓粗实线" "");;;设置当前图层
(setq p1 (polar p3 alph (- L b))
p2 (polar p4 alph (- L b))
)
(command "pline" p3 p1 p2 p4 "cl")
(setq ss (ssadd (entlast) ss))
(setq
p3 (polar p1 (- alph a) (/ b (cos a)))
p4 (polar p2 (+ alph a) (/ b (cos a)))
)
(command "pline" p1 p3 p4 p2 "")
(setq ss (ssadd (entlast) ss))
;;;绘制中心线
(command "layer" "s" "4.中心点划线" "");;;设置当前图层
;;;设定绘图的图层center
(setq pc1 (polar start (+ alph pi) 5.0))
;;;计算中心线的起点坐标
(setq pc2 (polar pc1 alph (+ L 10.0)))
;;;计算中心线终点纵坐标
(command "line" pc1 pc2 "")
;;;绘制中心线
(setq ss1 (ssadd (entlast)))
;;;将绘制的图形赋给选择集ss1
)
;;;/*shaft_action()为控件动作函数*/
(defun shaft_action ()
(action_tile "shaft_type" "(shaft_stype)")
(action_tile "shaft_D" "(shaft_input)")
(action_tile "shaft_L" "(shaft_input)")
(action_tile "key_w" "(shaft_input)")
(action_tile "cham_B" "(shaft_input)")
(action_tile "key_L1" "(shaft_input)")
(action_tile "key_L2" "(shaft_input)")
(action_tile "pick_point" "(shaft_input) (done_dialog 2)")
(action_tile "start_x" "(shaft_input)")
(action_tile "start_y" "(shaft_input)")
(action_tile "accept" "(shaft_input) (done_dialog 1)")
(setq what (start_dialog))
)
;;;/*设定各控件状态的函数*/
(defun shaft_set ()
(new_dialog "shaft" aug)
(shaft_vslide
"shaft_image"
(strcat "sha" (itoa shaft_type))
0
)
(set_tile "shaft_D" (rtos d 2 1))
(set_tile "shaft_L" (rtos L 2 1))
(set_tile "key_w" (rtos w 2 1))
(set_tile "cham_B" (rtos b 2 1))
(set_tile "key_L1" (rtos L1 2 1))
(set_tile "key_L2" (rtos L2 2 1))
(set_tile "start_x" (rtos (car start) 2 1))
(set_tile "start_y" (rtos (cadr start) 2 1))
)
;;;/*初始化轴的对话框函数*/
(defun shaft_start ()
(setq what 5)
(setq aug (load_dialog tmp-dcl-file-name))
(if (not (new_dialog "shaft" aug))
(exit)
)
(shaft_vslide "shaft_image" "sha1" 0)
(set_tile "start_x" (rtos (car start) 2 1))
(set_tile "start_y" (rtos (cadr start) 2 1))
(mode)
)
;;;/*设定各控件的可操作状态为enable(0)或disable(1)*/
(defun mode ()
(mode_tile "key_w"
(if (or (= shaft_type 2) (= shaft_type 3) (= shaft_type 4) (= shaft_type 5) (= shaft_type 6) (= shaft_type 9) (= shaft_type 10))
0
1
)
)
(mode_tile "key_L1"
(if (or (= shaft_type 2) (= shaft_type 3) (= shaft_type 4) (= shaft_type 5) (= shaft_type 6))
0
1
)
)
(mode_tile "key_L2"
(if (or (= shaft_type 2) (= shaft_type 3) (= shaft_type 4))
0
1
)
)
(mode_tile "cham_B"
(if (or (= shaft_type 1) (= shaft_type 2) (= shaft_type 3) (= shaft_type 4) (= shaft_type 5) (= shaft_type 6) (= shaft_type 7) (= shaft_type 8) (= shaft_type 9) (= shaft_type 10) (= shaft_type 11) (= shaft_type 12))
0
1
)
)
)
;;;/*在对话框上显示幻灯片的函数*/
(defun shaft_vslide (key s_name n / x y)
(setq x (dimx_tile key))
(setq y (dimy_tile key))
(start_image key)
(fill_image n 0 x y 2)
(slide_image n 0 x y s_name)
(end_image)
)
;;;/*选择轴段特征结构函数*/
(defun shaft_stype (/ what1)
(if (not (new_dialog "stype" aug))
(exit)
)
(shaft_vslide "sh1" "sha1" 0)
(shaft_vslide "sh2" "sha2" 0)
(shaft_vslide "sh3" "sha3" 0)
(shaft_vslide "sh4" "sha4" 0)
(shaft_vslide "sh5" "sha5" 0)
(shaft_vslide "sh6" "sha6" 0)
(shaft_vslide "sh7" "sha7" 0)
(shaft_vslide "sh8" "sha8" 0)
(action_tile "sh1" "(setq shaft_type 1)")
(action_tile "sh2" "(setq shaft_type 2)")
(action_tile "sh3" "(setq shaft_type 3)")
(action_tile "sh4" "(setq shaft_type 4)")
(action_tile "sh5" "(setq shaft_type 5)")
(action_tile "sh6" "(setq shaft_type 6)")
(action_tile "sh7" "(setq shaft_type 7)")
(action_tile "sh8" "(setq shaft_type 8)")
(action_tile "accept" "(done_dialog 0)")
(setq what1 (start_dialog))
(shaft_vslide
"shaft_image"
(strcat "sha" (itoa shaft_type))
0
)
(mode)
)
;;;/*初始化输入的数据的主调函数*/
(defun shaft_input ()
(setq d (atof (get_tile "shaft_D")))
(setq L (atof (get_tile "shaft_L")))
(setq w (atof (get_tile "key_w")))
(setq b (atof (get_tile "cham_B")))
(setq L1 (atof (get_tile "key_L1")))
(setq L2 (atof (get_tile "key_L2")))
(setq start (list (atof (get_tile "start_x"))
(atof (get_tile "start_y"))
)
)
)
;;;/*从屏幕上获取轴的起始点的函数*/
(defun shaft_pick ()
(command "snap" "1")
(setq start (getpoint "\n 输入轴的起始点:"))
)
;;;/*调用绘图函数的主调函数*/
(defun shaft_draw ()
(cond
((= shaft_type 1) (feature1))
((= shaft_type 2) (feature2))
((= shaft_type 3) (feature3))
((= shaft_type 4) (feature4))
((= shaft_type 5) (feature5))
((= shaft_type 6) (feature6))
((= shaft_type 7) (feature7))
((= shaft_type 8) (feature8))
)
(shaft_start)
)
感谢分享感谢分享
页:
[1]