本帖最后由 77077 于 2014-3-4 21:48 编辑
此程序功能还不够完善,希望大神们来添砖加瓦,程序代码太乱,欢迎修改~~~~~
缺少的函数可以去论坛找来用.
功能演示:
源码:- ;;;功能:属性刷刷刷
- (vl-load-com)
- (defun C:TT (/ SS ID ID2 ENT ENTBLOCK ENTDATA I LST1)
- (if (and (setq SS (entsel "\n点取源对象: "))
- (setq ENT (GetAttributes (car SS)))
- (SSS-MAKE-DCL ENT "d:\\test.dcl")
- (>= (setq ID (load_dialog "d:\\test.dcl")) 0)
- )
- (progn
- (setq LST1 '())
- (new_dialog "BLK_SSS" ID)
- (set_tile "DLG_NAME" (strcat "块属性刷刷刷-测试"))
- (setq ID2 (start_dialog))
- (princ "\n===id2=")
- (princ ID2)
- (setq lst2 (mapcar '(lambda (x) (nth x ENT)) LST1))
- (princ "\n要刷同的是:")
- (princ lst2)
- (if (and (= ID2 1) (> (length LST2) 0))
- (if (setq SS1 (ssget '((0 . "INSERT"))));选择目标块
- (foreach tagname LST2
- (setq value (getattvalue (car SS) tagname));取得源块tag的属性值
- (repeat
- (setq i (sslength SS1));目标块数量
- (setattvalue (ssname SS1 (setq i (1- i))) tagname value);修改目标块tag的属性值
- )
- )
- )
- )
- ;;卸载对话框文件
- (unload_dialog ID)
- (vl-file-delete "d:\\test.dcl")
- )
- )
- (princ)
- )
- ;;;[功能]根据ENT表,生成DCL文件
- (defun SSS-MAKE-DCL (ENT FILENAME / F1 I)
- (if (setq F1 (open FILENAME "w"))
- (progn
- (write-line "BLK_SSS: dialog{ key = "DLG_NAME"; label = "刷刷刷";" F1 )
- (write-line ":boxed_column{label="对象特性:";" F1)
- (setq I 0)
- (foreach N ENT
- (progn
- (write-line (strcat ":toggle{ label="" (vl-princ-to-string N) ""; key = "KEY匹配" (itoa I) ""; width=20; action="(tt-01 " (itoa I) ")";value="0"; }" ) F1 )
- (setq I (1+ I))
- )
- )
- (write-line "}" F1)
- (write-line "ok_only;" F1)
- (write-line "}" F1)
- (close F1)
- t
- )
- )
- )
- ;;;匹配 被修改
- (defun TT-01 (INT)
- (if (= $VALUE "1")
- (setq LST1 (cons INT LST1));将INT添加到表LST1
- (setq LST1 (vl-remove INT LST1))
- )
- )
|