- UID
- 483225
- 积分
- 28
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2006-8-27
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
小弟最近写了一个关于使用当前块(文字)属性刷到其它块(文字),作完后发现只能对无属性的块有效,有属性的块则不能对其属性文字有效.以下是源代码,,请高手指教..
(VL-LOAD-COM)
(defun c:mac (/ sel na ent lx sjlst)
(hb_start 1)
(setq sjlst (HB_REG (list (cons "bili" "1")
(cons "jiaodu" "1")
(cons "duiqi" "1")
(cons "xuanzhuan" "1")
(cons "gaodu" "1")
(cons "kuandu" "1")
(cons "qunxie" "1")
(cons "all" "0")
)
"mablock"
1
)
)
(setq msg "\n请选择刷子物体:[(Set)内容设置]")
(while (or (not sel) (= sel "s") (= sel "set"))
(initget "Set _set")
(setq sel (entsel msg))
(if (or (= sel "s") (= sel "set"))
(setq sjlst (mab_dlg sjlst))
)
)
(setq na (nth 0 sel)
ent (entget na)
lx (cdr (assoc 0 ent))
)
(if (= lx "INSERT")
(mab_block ent sjlst)
(mab_text ent sjlst)
)
(hb_reg sjlst "mablock" nil)
(hb_start nil)
(princ)
)
(defun mab_block (ment mlst / bl jd ss n na ent al)
(setq bl (cdr (assoc "bili" mlst))
jd (cdr (assoc "jiaodu" mlst))
al (cdr (assoc "all" mlst))
)
(prompt "\n请选择需要刷的块:")
(setq ss (ssget '((0 . "insert"))))
(if ss
(progn
(setq n 0)
(repeat (sslength ss)
(setq na (ssname ss n)
ent (entget na)
)
(if (= bl "1")
(setq ent (subst (assoc 41 ment) (assoc 41 ent) ent)
ent (subst (assoc 42 ment) (assoc 42 ent) ent)
ent (subst (assoc 43 ment) (assoc 43 ent) ent)
)
)
(if (= jd "1")
(setq ent (subst (assoc 50 ment) (assoc 50 ent) ent))
)
(if (= al "1")
(setq ent (MAB_SHUA ment ent (list 6 8 48 62)))
)
(entmod ent)
(setq n (+ n 1))
)
)
)
)
(defun mab_text (ment mlst / ss n na ent dq xz gd kd qx)
(setq dq (cdr (assoc "duiqi" mlst))
xz (cdr (assoc "xuanzhuan" mlst))
gd (cdr (assoc "gaodu" mlst))
kd (cdr (assoc "kuandu" mlst))
qx (cdr (assoc "qunxie" mlst))
)
(prompt "\n请选择需要刷的文字:")
(setq ss (ssget '((0 . "text"))))
(if ss
(progn
(setq n 0)
(repeat (sslength ss)
(setq na (ssname ss n)
ent (entget na)
)
(if (= gd "1")
(setq ent (subst (assoc 40 ment) (assoc 40 ent) ent))
)
(if (= kd "1")
(setq ent (subst (assoc 41 ment) (assoc 41 ent) ent))
)
(if (= xz "1")
(setq ent (subst (assoc 50 ment) (assoc 50 ent) ent))
)
(if (= qx "1")
(setq ent (subst (assoc 51 ment) (assoc 51 ent) ent))
)
(if (= dq "1")
(setq ent (subst (assoc 72 ment) (assoc 72 ent) ent)
ent (subst (assoc 73 ment) (assoc 73 ent) ent)
)
)
(if (= al "1")
(setq ent (MAB_SHUA ment ent (list 6 8 48 62)))
)
(entmod ent)
(setq n (+ n 1))
)
)
)
)
(defun mab_dlg (lst / bl jd dq xz gd kd
qx dlgLoaded dlgShow dcl_id rel
UserClick a b
)
(setq a "1"
b "0"
)
(setq bl (cdr (assoc "bili" lst))
jd (cdr (assoc "jiaodu" lst))
dq (cdr (assoc "duiqi" lst))
xz (cdr (assoc "xuanzhuan" lst))
gd (cdr (assoc "gaodu" lst))
kd (cdr (assoc "kuandu" lst))
qx (cdr (assoc "qunxie" lst))
al (cdr (assoc "all" lst))
dlgLoaded T
dlgShow T
)
(if (= -1 (setq dcl_id (LOAD_DIALOG "mab_dlg")))
(progn
(princ "\nmab_dlg.dcl文件无法加载。")
(setq dlgLoaded nil)
)
)
(if (and dlgLoaded (not (new_dialog "mabdlg" dcl_id)))
(progn
(princ "\n无法显示该对话框。")
(setq dlgShow nil)
)
)
(if (and dlgLoaded dlgShow)
(progn
(set_tile "mab_bl" bl)
(set_tile "mab_jd" jd)
(set_tile "mab_dq" dq)
(set_tile "mab_xz" xz)
(set_tile "mab_gd" gd)
(set_tile "mab_kd" kd)
(set_tile "mab_qx" qx)
(set_tile "mab_al" al)
(action_tile
"mab_bl"
"(if (= bl a) (setq bl b) (setq bl a))"
)
(action_tile
"mab_jd"
"(if (= jd a) (setq jd b) (setq jd a))"
)
(action_tile
"mab_dq"
"(if (= dq a) (setq dq b) (setq dq a))"
)
(action_tile
"mab_xz"
"(if (= xz a) (setq xz b) (setq xz a))"
)
(action_tile
"mab_kd"
"(if (= kd a) (setq kd b) (setq kd a))"
)
(action_tile
"mab_gd"
"(if (= gd a) (setq gd b) (setq gd a))"
)
(action_tile
"mab_qx"
"(if (= qx a) (setq qx b) (setq qx a))"
)
(action_tile
"mab_al"
"(if (= al a) (setq al b) (setq al a))"
)
(action_tile "cancel" "(done_dialog) (setq UserClick nil)")
(action_tile
"accept"
"(done_dialog) (setq UserClick T))"
)
(start_dialog)
(unload_dialog dcl_id)
(if UserClick
(progn
(setq rel (list (cons "bili" bl)
(cons "jiaodu" jd)
(cons "duiqi" dq)
(cons "xuanzhuan" xz)
(cons "gaodu" gd)
(cons "kuandu" kd)
(cons "qunxie" qx)
(cons "all" al)
)
)
)
(setq rel lst)
)
)
)
rel
)
(defun mab_shua (new old lst / n x rel)
(setq n 0)
(setq rel old)
(repeat (length lst)
(setq x (nth n lst))
(if (assoc x new)
(if (assoc x rel)
(setq rel (subst (assoc x new) (assoc x rel) rel))
(setq rel (cons (assoc x new) rel))
)
)
(setq n (+ n 1))
)
rel
)
(defun hb_Reg (lst keyWz isRead / key mykey n na rd rel)
(setq key (vlax-product-key)
mykey (strcat "HKEY_CURRENT_USER\\" key "\\HbSet\\" keyWz)
)
(setq n 0)
(if isRead
(repeat (length lst)
(setq na (nth n lst))
(setq rd (VL-REGISTRY-READ mykey (car na)))
(if rd
(setq rel (cons (cons (car na) rd) rel))
(setq rel (cons na rel))
)
(setq n (+ n 1))
)
(repeat (length lst)
(setq na (nth n lst))
(VL-REGISTRY-WRITE mykey (car na) (cdr na))
(setq n (+ n 1))
)
)
rel
)
;;环境初始化函数
(defun hb_start (is /)
(if is
(progn
(setvar "cmdecho" 0)
(command "undo" "begin")
(setq *error* hb_error)
)
(progn
(command "undo" "end")
(setvar "cmdecho" 1)
(setq *error* olderr)
)
)
)
;;;自定义出错函数
(defun hb_error (a /)
(princ a)
(command "undo" "end")
(setvar "cmdecho" 1)
(setq *error* olderr)
)
;;;三维点转二维点
(defun hb_3dpto2dp (point / rel)
(list (car point) (cadr point))
)
;;;获得当前UCS相对于WCS的角度
(defun hb_ucsAng (/ rel)
(ANGLE (trans '(0 0) 1 0) (trans '(1 0) 1 0))
)
(princ "\n图块文字格式刷强化版已加载!(MAB)")
附上对话框文件: |
|