发个不成熟的函数,望高手们帮忙改进~~~~
1.dcl控件不能对齐,不美观~
2.代码程序好像比较累赘,结构也不够合理~
函数:- ;文本型点对表编辑
- ;(editlst '(("标签1" . "值1") ("标签2" . "值2") ("标签3" . "值3") ("标签4" . "值4")))
- (defun editlst (lst / getdata fname F1 I lst1 dclid)
- (defun getdata()
- (setq lst1 NIL I 1)
- (foreach n lst
- (setq LST1 (cons (cons (car n) (get_tile (strcat "KEY" (itoa I)))) LST1)
- I (1+ I)
- )
- )
- )
- (setq fname (vl-filename-mktemp nil nil ".dcl"))
- (setq F1 (open fname "w"))
- (write-line "EditDCL:dialog{label="文本型点对表编辑";" F1)
- (write-line ":boxed_column{ " F1)
- (write-line ":row{\n:column{" F1)
- (setq I 1)
- (foreach n lst
- (write-line
- (strcat ":edit_box{label="" (car n)
- "";value="" (cdr n)
- "";key="KEY" (itoa I) "";}"
- )
- F1
- )
- (if (= (rem i 10) 0) (write-line "}\n:column{" F1))
- (setq I (1+ I))
- )
- (if (/= (rem (1- i) 10) 0) (write-line "}" F1))
- (write-line "}\n}" F1)
- (write-line "ok_cancel;" F1)
- (write-line "}" F1)
- (close F1)
- (setq dclid (load_dialog fname))
- (vl-file-delete fname)
- (new_dialog "EditDCL" dclid)
- (action_tile "accept" "(getdata)(done_dialog 1)")
- (action_tile "cancel" "(done_dialog 0)")
- (start_dialog)
- (unload_dialog dclid)
- (if lst1
- (setq lst (reverse lst1))
- (setq lst lst)
- )
- )
用法示例:- (defun c:xx-tt(/ ENT attlst)
- (prompt "***属性块编辑****")
- (while (setq ENT (CAR(entsel "\n 选择属性块:")))
- (setq attlst(editlst (GetAttributes ent)))
- (SetAttributes ent attlst)
- (princ "继续选择下一属性块")
- )
- (princ)
- );end defun
|