马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
本帖最后由 newer 于 2018-12-13 19:52 编辑
请在 XDRX API BUILD 2016.12.13 和 通用函数库 2016.12.18以上版本运行。
[sell](defun c:XDTB_TEXT_NUMSFORMULA (/ txtl c:TextFormulaSS_OnClicked c:TextReplaceOk_OnClicked
c:TextFormulaClear_OnClicked c:Cancel_OnClicked
c:MakeFormula_OnClicked $xdob_textNumsFormula_display
c:TextNumsFormula_OnInitialize formula FormulaBox i introw jd n Nums
oldvallist op Operator ss TextFormulaJD TextFormulaOk TextFormulaSS
TextNumsFormula TextNumsFormulaGrid txtl txtl1 txtl2 val vallist x
xd_odcl_textnumsformula
)
(defun XD::String:EscapeCha (str / key1 key2 n str1)
(setq str1 ".,<><()[]{}#?-!+*"
str1 (xdrx_string_regexps "." str1)
)
(foreach n str1
(setq str (xdrx_string_replace str n (strcat "\\" n)))
)
)
(setq xd_odcl_textnumsformula
'("YWt6A0RVAAAgJyLHBuKTJQMSarlrAZmxe+Wmm93bX3RujWu+njHOdXR/LDYc8n9ZDFvJDxO5SKq4"
"OGapUNA6mlQwFFrVy1TW4vRBIrfTLuXaL+3Igv/uVd9uK9b0qtbUVOSs6NoXD1Vkx+vlBISgxaOl"
"4wmZo0UNmUXwJRUQickRCRigwvEHERjj0Rhq5lsFYaq+zQ561J9+knhhfoJEZR5f4PfC2HIknwcW"
"/GjWuqx0+y5yG65y8wYreKXedpFoPHvqPEecPALMYi9vEjkkVaAX+mwCwa+h4txk5e7Mc5fbgip7"
"wC3wmTjNuDQ6OwYr97HqHhP7hiJ7qKr2k+qd4wyCFZzMagzXyUeqLSZw+HGsvkLO57IDrntZn0YI"
"qQZlaCVqjW+ddhr+nU6wTpkCAvajSmilhnUGG4KyuIKC5XzBW44xe4C6EPF2uDXuE5+Zd2kW40kw"
"yqqrwfrbnQ4gvRozG/UPM92ZQ/3dr3nZnl6KXvWjHk+lfWNGLLh4xYtzqo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1m1KErpJFnep5yJ6HGlRR+ua4uyVeBgizkkIDRG+MvAH/ENeb3iWkXA7J2ru8"
"7Ig/sh2vAlELiLJurbJ1ifZKllXt6jOyITokeL9IPWGPWBw6BMkFbE/n81zyNodghg23CgaU/nFr"
"XH2BjI/xQAogY4aSBzGLSI1DRO1nQxDw/3E5TU5e3/CvlRSwW3fwWxGjKkeRM1UGCTS/C83CDfk1"
"YOisCZHWhKEz14BlLZS80xcLBwwkI4IWRNeGoQq9mkG6Zr6rRVRltVBi+f/lLRRyuR56sbe6AZNT"
"SjjXfahmIttMt/u43nS59HTDaZHAOZ1eQDhZGSpEj0H1Y65mRoeQ0STvasKtP4LCT0vdyKF2v0Fo"
"WaFp+MWrpj49rI+BcIwxRO6Trn/zke8gS0Cm2FCKqdWvkOTanYGoijIecgrAhauGLkW0wicjltMt"
"mcTUqjaloNqdoZynVFqR9daVnT1WDaqJr6AkmgPBZBCl2/hkNO30AUR4lMjUz78Y6Etjnb0j8lMD"
"YReh1fjlCdY/AtDB2F5XhwGLIsHERqyzgqVM0RzniaiTrrQOvYjanYGshvaNAXarx4iDUg3cb7Gp"
"USNy6gaJSaT57ZHvyGOkRjIwMNT39/d+kdplj5ARynHsz5oFzhBDpQeF0EKrIyW0wiFkZTREoJde"
"gDmvqNeuP5n/5OvUBSnwFFAzKYvbR7aFDiyMMHm3oFToc3KoaE6BfYulqzYpIyyMwNmET430sITU"
"/wFfnPsnoLo/dK4YQ4W8RSHvmQoPSOnF0JrnGYEBzb2Bf6tTeSQ="
)
)
(defun c:MF-Check1#OnClicked (Value /)
(if (= value 1)
(dcl-Control-SetEnabled MF-After t)
(dcl-Control-SetEnabled MF-After nil)
)
)
(defun c:MF-Check2#OnClicked (Value /)
(if (= value 1)
(dcl-Control-SetEnabled MF-Before t)
(dcl-Control-SetEnabled MF-Before nil)
)
)
(defun c:TextFormulaSS_OnClicked (/ formula jd x)
(setq tf t
str_after ""
str_before ""
)
(if (= 1 (dcl-Control-GetValue MF-Check1))
(progn
(if (= "" (dcl-Control-GetText MF-After))
(progn (dcl-MessageBox "字符之后不能为空.") (setq tf nil))
(setq str_after (dcl-Control-GetText MF-After))
)
)
)
(if (= 1 (dcl-Control-GetValue MF-Check2))
(progn
(if (= "" (dcl-Control-GetText MF-BEFORE))
(progn (dcl-MessageBox "字符之前不能为空.") (setq tf nil))
(setq str_before (dcl-Control-GetText MF-BEFORE))
)
)
)
(if tf
(progn (setq formula (dcl_Control_GetText FormulaBox))
(if (/= "" formula)
(progn (setq jd (dcl_ComboBox_GetEBText TextFormulaJD))
(cond ((= (strlen jd) 1) (setq jd 0))
(t (setq jd (- (strlen jd) 2)))
)
(setq match "[0-9.]+")
(if (/= str_after "")
(setq match (strcat "(?<=" (XD::STRING:ESCAPECHA str_after) ")[0-9.]+"))
)
(if (/= str_before "")
(setq match (strcat match "(?=" (XD::STRING:ESCAPECHA str_before) ")"))
)
(setq txtl2
(mapcar '(lambda (x)
(if (setq old (xdrx_string_regexps match (car x)))
(progn (if (= jd 0)
(progn (setq val
(fix
(+ 0.5
(xdrx_string_evalExpression (strcat (car old) formula))
)
)
)
)
(progn (setq val (xdrx_string_format1
(float
(xdrx_string_evalExpression (strcat (car old) formula))
)
jd
)
val (atof val)
)
)
)
)
)
(setq val (XD::String:Strpad
val
(if (setq a (xdrx_string_regexps "[0-9]+(?=\\.)" (car old)))
(strlen (car a))
(strlen (car old))
)
"0"
jd
)
)
(setq val (xdrx_string_regexpr match (car x) val))
(list (car x) formula val)
)
txtl1
)
)
($xdob_textNumsFormula_display txtl2)
(dcl_Control_SetEnabled TextFormulaOk t)
)
)
)
)
)
(defun c:TextFormulaOk_OnClicked (/ i n)
(dcl_form_close TextNumsFormula)
(setq i 0)
(mapcar '(lambda (x)
(xdrx_setpropertyvalue
(car x)
"textstring"
(last (nth i txtl2))
)
(setq i (1+ i))
)
txtl
)
(princ)
)
(defun c:TextFormulaClear_OnClicked (/)
(dcl_Control_SetText FormulaBox "")
(dcl_Control_SetEnabled TextFormulaOk nil)
(dcl_Control_SetEnabled TextFormulaSS nil)
($xdob_textNumsFormula_display txtl1)
(princ)
)
(defun c:Cancel_OnClicked (/)
(dcl_Form_close TextNumsFormula)
(princ)
)
(defun c:MakeFormula_OnClicked (/ oldvallist op val vallist)
(setq op (dcl_ComboBox_GetEBText Operator)
val (dcl_Control_GetText Nums)
)
(if (/= "" val)
(progn (setq oldvallist (dcl_Control_GetText FormulaBox))
(dcl_Control_SetText
FormulaBox
(setq vallist (strcat oldvallist (strcat op val)))
)
(dcl_Control_SetEnabled TextFormulaSS t)
)
)
(princ)
)
(defun $xdob_textNumsFormula_display (val / introw n)
(dcl_Grid_Clear TextNumsFormulaGrid)
(foreach n val
(if (setq intRow (dcl_Grid_AddString TextNumsFormulaGrid (car n)))
(progn (dcl_Grid_SetCellText
TextNumsFormulaGrid
intRow
1
(nth 1 n)
)
(dcl_Grid_SetCellText
TextNumsFormulaGrid
intRow
2
(nth 2 n)
)
(dcl_Grid_SetCellText
TextNumsFormulaGrid
intRow
3
(nth 3 n)
)
(dcl_Grid_SetCellText
TextNumsFormulaGrid
intRow
4
(nth 4 n)
)
)
)
)
(princ)
)
(defun c:TextNumsFormula#OnInitialize (/)
($xdob_textNumsFormula_display txtl1)
(princ)
)
(xdrx_sysvar_push "osmode" "cmdecho")
(setvar "cmdecho" 0)
(setvar "osmode" 0)
(prompt "\n选取要修改的数字文字<退出>:")
(if (not (setq ss (ssget '((0 . "TEXT")))))
(exit)
)
(mapcar '(lambda (x)
(setq txtl (cons (list x (xdrx_getpropertyvalue x "textstring")) txtl))
)
(xdrx_pickset->ents ss)
)
(setq txtl (reverse txtl))
(setq txtl1 (mapcar '(lambda (x) (list (cadr x) "" "")) txtl))
(if (> (length txtl1) 0)
(progn (if (XD::Doc:AutoLoadOpenDCL)
(progn (dcl-project-import xd_odcl_textnumsformula)
(dcl_Form_Show TextNumsFormula)
)
)
)
(prompt "\n没有发现数字文字。")
)
(xdrx_end)
(xdrx_sysvar_pop)
(princ)
)
[/sell] |