品茗新秀
发表于 2012-10-20 13:31:13
【KAIXIN】 发表于 2012-10-20 07:36 static/image/common/back.gif
文本编辑修改,论坛有很多类似的源码,不知楼主要怎么样的
即预设文字样子,即为标准,以后遇不同的文字,即用格式刷刷一下即可。
puzb2001
发表于 2012-10-20 17:01:08
请楼主明示,想了半天没有明白
wudechao
发表于 2012-10-21 18:31:48
本帖最后由 wudechao 于 2012-10-21 18:43 编辑
(defun ef:undobegin ()
(setvar "CMDECHO" 0)
(command "_.undo" "_group")
(princ)
)
(defun ef:undoend ()
(setvar "CMDECHO" 0)
(command "_.undo" "_end")
(princ)
)
(defun c:qm (/ dcl_id1 oba ob1 obn obt ptn otxt txt sty styno lay cyn layno hig wid ang col cnu etlst style layer n2 ent index)
(vl-load-com)
(setvar "cmdecho" 0)
(graphscr)
(ef:undobegin)
(setq olderr *error*)
(defun *error* (msg)
(princ "\n*ERROR*...")
(princ msg)
(princ)
)
(defun set_color (conm / costr)
(defun map_color (ckey mno)
(start_image ckey)
(fill_image 0 0 (dimx_tile ckey) (dimy_tile ckey) mno)
(end_image)
)
(cond
((= 0 conm)
(setq costr "Byblock")
)
((= 1 conm)
(setq costr "Red")
)
((= 2 conm)
(setq costr "Yellow")
)
((= 3 conm)
(setq costr "Green")
)
((= 4 conm)
(setq costr "Cyan")
)
((= 5 conm)
(setq costr "Bule")
)
((= 6 conm)
(setq costr "Magenta")
)
((= 7 conm)
(setq costr "color")
)
((= 256 conm)
(setq costr "Bylayer")
)
(t
(setq costr "")
)
)
(cond
((= 0 col)
(map_color "col" 7)
)
((= 256 col)
(map_color "col" (cdr (assoc 62 (tblsearch "layer" lay))))
)
(t
(map_color "col" conm)
)
)
(if (= 256 conm)
(set_tile "cnu" (strcat " 颜色:< " (itoa (cdr (assoc 62 (tblsearch "layer" lay)))) " > " costr))
(set_tile "cnu" (strcat " 颜色:< " (itoa conm) " > " costr))
)
)
(defun map_keylist (key keylst)
(start_list key)
(mapcar
'add_list
keylst
)
(end_list)
)
(defun style_get_all (/ sty style sty_list)
(setq sty_list nil
sty (tblnext "style" t)
)
(setq style (cdr (assoc 2 sty)))
(while style
(if (/= "" style)
(setq sty_list (append
sty_list
(list style)
)
)
)
(setq sty (tblnext "style"))
(setq style (cdr (assoc 2 sty)))
)
(setq sty_list (acad_strlsort sty_list))
sty_list
)
(defun set_error (str)
(set_tile "error" str)
)
(defun sub_mtext (color entlist / ei newlist)
(setq ei 0
newlist nil
)
(while (< ei (length entlist))
(setq newlist (cons (nth ei entlist) newlist))
(if (= 8 (car (nth ei entlist)))
(setq newlist (cons (cons 62 color) newlist))
)
(setq ei (1+ ei))
)
(reverse newlist)
)
(setq ob1 (entsel "\n选择文本所在的图层:"))
(setq obn (car ob1)
ptn (car (cdr ob1))
)
(setq obt (car (nentselp ptn)))
(setq oba (cdr (assoc 0 (entget obt))))
(if (or
(= oba "TEXT")
(= oba "MTEXT")
(= oba "TCH_TEXT")
(= oba "TCH_MTEXT")
)
(setq otxt (cdr (assoc 1 (entget obt))))
)
(if otxt
(progn
(setq sty (cdr (assoc 7 (entget obt)))
lay (cdr (assoc 8 (entget obn)))
hig (cdr (assoc 40 (entget obt)))
ang (cdr (assoc 50 (entget obt)))
)
(if (or
(= oba "TEXT")
(= oba "MTEXT")
(= oba "ATTRIB")
)
(progn
(setq col (cdr (assoc 62 (entget obt))))
(setq wid (cdr (assoc 41 (entget obt))))
)
)
(setq ang (* 180 (/ ang pi)))
(if (or
(= oba "TEXT")
(= oba "MTEXT")
)
(progn
(if (null col)
(progn
(setq cyn 0)
(setq col 256)
)
(setq cyn 1)
)
)
)
(setq style (style_get_all))
(setq styno (- (length style) (length (member sty style))))
(setq layno (- (length layer) (length (member lay layer))))
(if (or
(= oba "TEXT")
(= oba "MTEXT")
)
(progn
(setq dclname (cond
((setq tempname (vl-filename-mktemp "tt-dcl-tmp.dcl")
filen (open tempname "w")
)
(foreach stream '(
"\n"
"文字修改:dialog {\n"
" label = \"文字编辑器...\";\n"
" : boxed_radio_column {\n"
" label = \"文字编辑...\";\n"
" : row {\n"
" : popup_list {\n"
" label=\"样式:\";\n"
" key = \"sty\";\n"
" edit_width = 13;\n"
" fixed_width = true;\n"
" }\n"
" : edit_box {\n"
" label=\"高度:\";\n"
" key = \"hig\";\n"
" edit_width = 7;\n"
" fixed_width = true;\n"
" }\n"
" : edit_box {\n"
" label=\"宽度:\";\n"
" key = \"wid\";\n"
" edit_width = 7;\n"
" fixed_width = true;\n"
" }\n"
" }\n"
" : row {\n"
" : text_part {\n"
" key = \"cnu\";\n"
" width= 10;\n"
" fixed_width = fake;\n"
" }\n"
" : image_button {\n"
" key = \"col\";\n"
" width= 4;\n"
" aspect_ratio = 0.75;\n"
" fixed_width = fake;\n"
" }\n"
" : edit_box {\n"
" label=\"角度:\";\n"
" key = \"ang\";\n"
" edit_width = 7;\n"
" fixed_width = true;\n"
" }\n"
" }\n"
" spacer_1;\n"
" }\n"
" : row {\n"
" alignment = right;\n"
" : spacer {\n"
" width = 1;\n"
" fixed_width = true;\n"
" }\n"
" ok_cancel;\n"
" }\n"
" errtile;\n"
"}\n"
)
(princ stream filen)
)
(close filen)
tempname
)
)
)
)
(progn
(setq dclname (cond
((setq tempname (vl-filename-mktemp "tt-dcl-tmp.dcl")
filen (open tempname "w")
)
(foreach stream '(
"\n"
"文字修改:dialog {\n"
" label = \"文字编辑器...\";\n"
" : boxed_radio_column {\n"
" label = \"文字编辑...\";\n"
" : row {\n"
" : popup_list {\n"
" label=\"样式:\";\n"
" key = \"sty\";\n"
" edit_width = 13;\n"
" fixed_width = true;\n"
" }\n"
" : edit_box {\n"
" label=\"高度:\";\n"
" key = \"hig\";\n"
" edit_width = 7;\n"
" fixed_width = true;\n"
" }\n"
" }\n"
" : row {\n"
" : edit_box {\n"
" label=\"角度:\";\n"
" key = \"ang\";\n"
" edit_width = 7;\n"
" fixed_width = true;\n"
" }\n"
" }\n"
" spacer_1;\n"
" }\n"
" : row {\n"
" alignment = right;\n"
" : spacer {\n"
" width = 1;\n"
" fixed_width = true;\n"
" }\n"
" ok_cancel;\n"
" }\n"
" errtile;\n"
"}\n"
)
(princ stream filen)
)
(close filen)
tempname
)
)
)
)
)
(setq dcl_id1 (load_dialog dclname))
(if (not (new_dialog "文字修改" dcl_id1))
(exit)
)
(if (or
(= oba "TEXT")
(= oba "MTEXT")
)
(progn
(set_color col)
(set_tile "wid" (rtos wid 2 3))
(action_tile "wid" "(setq wid (distof $value))(if (>= 0 wid)(progn (mode_tile \"wid\" 3)(mode_tile \"wid\" 2)(set_error \"Input error ! \"))(set_error \"\"))")
(action_tile "col" "(if (setq cnu (ACAD_ColorDlg col))(progn (setq col cnu)(set_color col)))")
)
)
(set_tile "hig" (rtos hig 2 2))
(set_tile "ang" (rtos ang 2 2))
(map_keylist "sty" style)
(set_tile "sty" (itoa styno))
(action_tile "sty" "(setq styno (atoi $value))")
(action_tile "hig" "(setq hig (distof $value))(if (>= 0 hig)(progn (mode_tile \"hig\" 3)(mode_tile \"hig\" 2)(set_error \"Input error ! \"))(set_error \"\"))")
(action_tile "ang" "(setq ang (distof $value))")
(action_tile "accept" "(done_dialog 1)")
(action_tile "cancel" "(done_dialog 0)")
(if (= 1 (start_dialog))
(if styno
(progn
(setq sty (nth styno style))
(setq ang (* (/ ang 180) pi))
(setq ss (ssget "X" (list (cons 8 lay))))
(setq n2 (sslength ss)
index 0
)
(repeat n2
(setq ent (ssname ss index))
(setq etlst (entget ent))
(setq etlst (subst
(cons 7 sty)
(assoc 7 etlst)
etlst
)
)
(setq etlst (subst
(cons 40 hig)
(assoc 40 etlst)
etlst
)
)
(setq etlst (subst
(cons 50 ang)
(assoc 50 etlst)
etlst
)
)
(if (or
(= oba "TEXT")
(= oba "MTEXT")
)
(progn
(setq etlst (subst
(cons 41 wid)
(assoc 41 etlst)
etlst
)
)
(if (= 1 cyn)
(setq etlst (subst
(cons 62 col)
(assoc 62 etlst)
etlst
)
)
(if (= "MTEXT" oba)
(setq etlst (sub_mtext col etlst))
(setq etlst (cons (cons 62 col) etlst))
)
)
)
)
(entmod etlst)
(entupd obt)
(entupd obn)
(setq index (+ index 1))
)
)
)
)
(if (= 11 (start_dialog))
(command "_help")
)
)
)
(setq *error* olderr)
(ef:undoend)
(unload_dialog dcl_id1)
(vl-file-delete dclname)
(setvar "cmdecho" 1)
(princ)
)
wudechao
发表于 2012-10-21 18:35:05
本帖最后由 wudechao 于 2012-10-21 18:42 编辑
(defun ef:undobegin ()
(setvar "CMDECHO" 0)
(command "_.undo" "_group")
(princ)
)
(defun ef:undoend ()
(setvar "CMDECHO" 0)
(command "_.undo" "_end")
(princ)
)
(defun c:qm (/ dcl_id1 oba ob1 obn obt ptn otxt txt sty styno lay cyn layno hig wid ang col cnu etlst style layer n2 ent index)
(vl-load-com)
(setvar "cmdecho" 0)
(graphscr)
(ef:undobegin)
(setq olderr *error*)
(defun *error* (msg)
(princ "\n*ERROR*...")
(princ msg)
(princ)
)
(defun set_color (conm / costr)
(defun map_color (ckey mno)
(start_image ckey)
(fill_image 0 0 (dimx_tile ckey) (dimy_tile ckey) mno)
(end_image)
)
(cond
((= 0 conm)
(setq costr "Byblock")
)
((= 1 conm)
(setq costr "Red")
)
((= 2 conm)
(setq costr "Yellow")
)
((= 3 conm)
(setq costr "Green")
)
((= 4 conm)
(setq costr "Cyan")
)
((= 5 conm)
(setq costr "Bule")
)
((= 6 conm)
(setq costr "Magenta")
)
((= 7 conm)
(setq costr "color")
)
((= 256 conm)
(setq costr "Bylayer")
)
(t
(setq costr "")
)
)
(cond
((= 0 col)
(map_color "col" 7)
)
((= 256 col)
(map_color "col" (cdr (assoc 62 (tblsearch "layer" lay))))
)
(t
(map_color "col" conm)
)
)
(if (= 256 conm)
(set_tile "cnu" (strcat " 颜色:< " (itoa (cdr (assoc 62 (tblsearch "layer" lay)))) " > " costr))
(set_tile "cnu" (strcat " 颜色:< " (itoa conm) " > " costr))
)
)
(defun map_keylist (key keylst)
(start_list key)
(mapcar
'add_list
keylst
)
(end_list)
)
(defun style_get_all (/ sty style sty_list)
(setq sty_list nil
sty (tblnext "style" t)
)
(setq style (cdr (assoc 2 sty)))
(while style
(if (/= "" style)
(setq sty_list (append
sty_list
(list style)
)
)
)
(setq sty (tblnext "style"))
(setq style (cdr (assoc 2 sty)))
)
(setq sty_list (acad_strlsort sty_list))
sty_list
)
(defun set_error (str)
(set_tile "error" str)
)
(defun sub_mtext (color entlist / ei newlist)
(setq ei 0
newlist nil
)
(while (< ei (length entlist))
(setq newlist (cons (nth ei entlist) newlist))
(if (= 8 (car (nth ei entlist)))
(setq newlist (cons (cons 62 color) newlist))
)
(setq ei (1+ ei))
)
(reverse newlist)
)
(setq ob1 (entsel "\n选择文本所在的图层:"))
(setq obn (car ob1)
ptn (car (cdr ob1))
)
(setq obt (car (nentselp ptn)))
(setq oba (cdr (assoc 0 (entget obt))))
(if (or
(= oba "TEXT")
(= oba "MTEXT")
(= oba "TCH_TEXT")
(= oba "TCH_MTEXT")
)
(setq otxt (cdr (assoc 1 (entget obt))))
)
(if otxt
(progn
(setq sty (cdr (assoc 7 (entget obt)))
lay (cdr (assoc 8 (entget obn)))
hig (cdr (assoc 40 (entget obt)))
ang (cdr (assoc 50 (entget obt)))
)
(if (or
(= oba "TEXT")
(= oba "MTEXT")
(= oba "ATTRIB")
)
(progn
(setq col (cdr (assoc 62 (entget obt))))
(setq wid (cdr (assoc 41 (entget obt))))
)
)
(setq ang (* 180 (/ ang pi)))
(if (or
(= oba "TEXT")
(= oba "MTEXT")
)
(progn
(if (null col)
(progn
(setq cyn 0)
(setq col 256)
)
(setq cyn 1)
)
)
)
(setq style (style_get_all))
(setq styno (- (length style) (length (member sty style))))
(setq layno (- (length layer) (length (member lay layer))))
(if (or
(= oba "TEXT")
(= oba "MTEXT")
)
(progn
(setq dclname (cond
((setq tempname (vl-filename-mktemp "tt-dcl-tmp.dcl")
filen (open tempname "w")
)
(foreach stream '(
"\n"
"文字修改:dialog {\n"
" label = \"文字编辑器...\";\n"
" : boxed_radio_column {\n"
" label = \"文字编辑...\";\n"
" : row {\n"
" : popup_list {\n"
" label=\"样式:\";\n"
" key = \"sty\";\n"
" edit_width = 13;\n"
" fixed_width = true;\n"
" }\n"
" : edit_box {\n"
" label=\"高度:\";\n"
" key = \"hig\";\n"
" edit_width = 7;\n"
" fixed_width = true;\n"
" }\n"
" : edit_box {\n"
" label=\"宽度:\";\n"
" key = \"wid\";\n"
" edit_width = 7;\n"
" fixed_width = true;\n"
" }\n"
" }\n"
" : row {\n"
" : text_part {\n"
" key = \"cnu\";\n"
" width= 10;\n"
" fixed_width = fake;\n"
" }\n"
" : image_button {\n"
" key = \"col\";\n"
" width= 4;\n"
" aspect_ratio = 0.75;\n"
" fixed_width = fake;\n"
" }\n"
" : edit_box {\n"
" label=\"角度:\";\n"
" key = \"ang\";\n"
" edit_width = 7;\n"
" fixed_width = true;\n"
" }\n"
" }\n"
" spacer_1;\n"
" }\n"
" : row {\n"
" alignment = right;\n"
" : spacer {\n"
" width = 1;\n"
" fixed_width = true;\n"
" }\n"
" ok_cancel;\n"
" }\n"
" errtile;\n"
"}\n"
)
(princ stream filen)
)
(close filen)
tempname
)
)
)
)
(progn
(setq dclname (cond
((setq tempname (vl-filename-mktemp "tt-dcl-tmp.dcl")
filen (open tempname "w")
)
(foreach stream '(
"\n"
"文字修改:dialog {\n"
" label = \"文字编辑器...\";\n"
" : boxed_radio_column {\n"
" label = \"文字编辑...\";\n"
" : row {\n"
" : popup_list {\n"
" label=\"样式:\";\n"
" key = \"sty\";\n"
" edit_width = 13;\n"
" fixed_width = true;\n"
" }\n"
" : edit_box {\n"
" label=\"高度:\";\n"
" key = \"hig\";\n"
" edit_width = 7;\n"
" fixed_width = true;\n"
" }\n"
" }\n"
" : row {\n"
" : edit_box {\n"
" label=\"角度:\";\n"
" key = \"ang\";\n"
" edit_width = 7;\n"
" fixed_width = true;\n"
" }\n"
" }\n"
" spacer_1;\n"
" }\n"
" : row {\n"
" alignment = right;\n"
" : spacer {\n"
" width = 1;\n"
" fixed_width = true;\n"
" }\n"
" ok_cancel;\n"
" }\n"
" errtile;\n"
"}\n"
)
(princ stream filen)
)
(close filen)
tempname
)
)
)
)
)
(setq dcl_id1 (load_dialog dclname))
(if (not (new_dialog "文字修改" dcl_id1))
(exit)
)
(if (or
(= oba "TEXT")
(= oba "MTEXT")
)
(progn
(set_color col)
(set_tile "wid" (rtos wid 2 3))
(action_tile "wid" "(setq wid (distof $value))(if (>= 0 wid)(progn (mode_tile \"wid\" 3)(mode_tile \"wid\" 2)(set_error \"Input error ! \"))(set_error \"\"))")
(action_tile "col" "(if (setq cnu (ACAD_ColorDlg col))(progn (setq col cnu)(set_color col)))")
)
)
(set_tile "hig" (rtos hig 2 2))
(set_tile "ang" (rtos ang 2 2))
(map_keylist "sty" style)
(set_tile "sty" (itoa styno))
(action_tile "sty" "(setq styno (atoi $value))")
(action_tile "hig" "(setq hig (distof $value))(if (>= 0 hig)(progn (mode_tile \"hig\" 3)(mode_tile \"hig\" 2)(set_error \"Input error ! \"))(set_error \"\"))")
(action_tile "ang" "(setq ang (distof $value))")
(action_tile "accept" "(done_dialog 1)")
(action_tile "cancel" "(done_dialog 0)")
(if (= 1 (start_dialog))
(if styno
(progn
(setq sty (nth styno style))
(setq ang (* (/ ang 180) pi))
(setq ss (ssget "X" (list (cons 8 lay))))
(setq n2 (sslength ss)
index 0
)
(repeat n2
(setq ent (ssname ss index))
(setq etlst (entget ent))
(setq etlst (subst
(cons 7 sty)
(assoc 7 etlst)
etlst
)
)
(setq etlst (subst
(cons 40 hig)
(assoc 40 etlst)
etlst
)
)
(setq etlst (subst
(cons 50 ang)
(assoc 50 etlst)
etlst
)
)
(if (or
(= oba "TEXT")
(= oba "MTEXT")
)
(progn
(setq etlst (subst
(cons 41 wid)
(assoc 41 etlst)
etlst
)
)
(if (= 1 cyn)
(setq etlst (subst
(cons 62 col)
(assoc 62 etlst)
etlst
)
)
(if (= "MTEXT" oba)
(setq etlst (sub_mtext col etlst))
(setq etlst (cons (cons 62 col) etlst))
)
)
)
)
(entmod etlst)
(entupd obt)
(entupd obn)
(setq index (+ index 1))
)
)
)
)
(if (= 11 (start_dialog))
(command "_help")
)
)
)
(setq *error* olderr)
(ef:undoend)
(unload_dialog dcl_id1)
(vl-file-delete dclname)
(setvar "cmdecho" 1)
(princ)
)
yokees
发表于 2012-10-26 01:31:19
esaysel选择易,楼主去下载吧。如论选择东西,也不能写出比这个更全面的插件了。
但是它只能选,楼主是想选择之后继续进行操作?
如若操作,欲进行什么操作?
yokees
发表于 2012-10-26 01:32:50
本人也是做结构设计,你懂的,本人QQ416574520
品茗新秀
发表于 2012-10-26 22:28:37
wudechao 发表于 2012-10-21 18:35 static/image/common/back.gif
(defun ef:undobegin ()
(setvar "CMDECHO" 0)
(command "_.undo" "_group")
我是初学者,不知输入命令是什么
flytoday
发表于 2012-10-29 00:19:07
预设字体样式这个不行……样主要的是碰到不能被识别的字变成问号什么的…然加载这插件刷一下显示了是吧……
戏男
发表于 2012-10-29 16:45:15
这没什么用啊 用不到
c735023723
发表于 2012-10-30 07:51:56
这个不难吧