本帖最后由 llsheng_73 于 2024-12-21 18:14 编辑
- (defun makedcl(str_lst / dclfile fileID dclHandle)
- (setq dclfile(vl-filename-mktemp nil nil ".dcl")fileID(open dclfile "w"))
- (write-line(apply'strcat str_lst)fileID)
- (close fileID)
- (setq dclHandle(load_dialog dclfile))
- (vl-file-delete dclfile)
- dclHandle)
- (defun c:TT(/ dcl blocks e dist d a jl l km *model)
- (vl-load-com)
- (setq dcl(makedcl'("DFX:dialog{label=\"等分线\";key=\"AAA\";"
- ":column{:popup_list{label=\"块名\";key=\"KM\";width=20;}:row{:button{key = \"SE\";label=\"...\";}:edit_box{label=\"缩放比例\";key=\"BL\";}}"
- ":edit_box{label=\"插入间距\";key=\"JL\";}:edit_box{label=\"偏距(左+右-)\";key=\"D\";}"
- ":row{:button{key = \"ESC\";label = \"放弃\";is_cancel = true;}:button{key = \"DO\";label=\"执行\";}}}}"))
- *model(vlax-get-property(vlax-get-property(vlax-get-acad-object)'activedocument)'modelspace)
- ctl 4)
- ((lambda(/ a)(While(SetQ a(TblNext "block"(not blocks)))(SetQ blocks(Cons(Cdr(Assoc 2 a))blocks)))))
- (vl-every(function(lambda(a b)(set(read a)b)))(setq keys'("KM""BL""JL""D"))(vlax-ldata-get"上次记忆""参数"))
- (while(> ctl 1)
- (new_dialog"DFX"dcl)
- (start_list"KM")(vl-every(function add_list)blocks)(end_list)
- (set_tile"LH"(if l(strcat"线长"(rtos l 2 2))"未选择"))
- (and km(set_tile"KM"(itoa(vl-position km blocks))))
- (vl-some(function(lambda(a b)(and b(set_tile a b)nil)))(cdr keys)(list bl jl d))
- (action_tile"SEL""(done_dialog 2)")(action_tile"SE""(done_dialog 2)")
- (action_tile"BL""(IF(or(NOT(DISTOF $VALUE))(<=(DISTOF $VALUE)0))(PROGN(ALERT\"只允许数值且大于0!\")(MODE_TILE\"BL\"2))(setq bl $VALUE))")
- (action_tile"JL""(IF(or(NOT(DISTOF $VALUE))(<=(DISTOF $VALUE)0))(PROGN(ALERT\"只允许数值且大于0!\")(MODE_TILE\"JL\"2))(setq jl $VALUE))")
- (action_tile"D""(IF(NOT(DISTOF $VALUE))(PROGN(ALERT\"只允许数值!\")(MODE_TILE\"D\"2))(setq d $VALUE))")
- (action_tile"DO""(SETQ VALUE(CONS(NTH(ATOI(GET_TILE\"KM\"))blocks)(MAPCAR(function GET_TILE)'(\"BL\"\"JL\"\"D\"))))(done_dialog 1)")
- (cond((= (setq ctl(start_dialog)) 2)
- (prompt"\n点选要插入的参照")
- (and(setq a(ssget":E:S"'((0 . "insert"))))
- (setq a(ssname a 0))
- (setq km(cdr(assoc 2(entget a))))))
- ((= ctl 1)
- (vl-every(function(lambda(a b c)(set(read a)(b c))))keys(list princ distof distof distof)value)
- (vlax-ldata-put"上次记忆""参数"VALUE)
- (while(progn(prompt"\n点选要等分的线")
- (and(setq e(ssget":E:S"'((0 . "*polyline,arc,circle,ellipse,spline"))))
- (setq e(ssname e 0))
- (setq L(-(vlax-curve-getdistatparam e(vlax-curve-getendparam e))(vlax-curve-getdistatparam e(vlax-curve-getstartparam e))))))
- ((lambda(/ p ang)(setq a(- jl))
- (while(<(setq a(+ a jl))l)
- (setq p(vlax-curve-getpointatdist e a)
- ang(angle'(0 0)(vlax-curve-getFirstDeriv e(vlax-curve-getparamatpoint e p)))
- p(polar p(+(* pi 0.5)ang)d))
- (vlax-invoke-method *model'insertblock(vlax-3d-point p)km bl bl 1 ang)))))))
- ))
|