疯球 发表于 2019-5-28 21:01:38

求个加前后缀的源码

本帖最后由 疯球 于 2019-5-30 06:59 编辑

要求如图,求哪位大神能做一下

zixuan203344 发表于 2019-5-28 21:01:39

(defun c:tt4 ();;;;
(vl-load-com)
(setq @dclfiledame (vl-filename-mktemp nil nil ".dcl"))
(setq @dclfiled (open @dclfiledame "w"))
(write-line "dzmjjsbdc:dialog {" @dclfiled)
(write-line "    label = \"文本加前后缀\" ;" @dclfiled)
(write-line "    :row {" @dclfiled)
(write-line "      :edit_box {" @dclfiled)
(write-line "            key = \"textaddstring1\" ;" @dclfiled)
(write-line "            label = \"前缀\" ;" @dclfiled)
(write-line "            width = 30;" @dclfiled)
(write-line "      }" @dclfiled)
(write-line "      :edit_box {" @dclfiled)
(write-line "            key = \"textaddstring2\" ;" @dclfiled)
(write-line "            label = \"后缀\" ;" @dclfiled)
(write-line "            width = 30;" @dclfiled)
(write-line "      }" @dclfiled)
(write-line "    }" @dclfiled)
(write-line "      ok_cancel;" @dclfiled)
(write-line "}" @dclfiled)
(close @dclfiled)
;;以下根据情况处理
(setq @dclid (load_dialog @dclfiledame))
(new_dialog "dzmjjsbdc" @dclid)
;;设置控件默认值
(if (and (/= textaddstring1_1 "") (/= textaddstring1_1 nil))
    (set_tile "textaddstring1" textaddstring1_1)
)
(if (and (/= textaddstring2_1 "") (/= textaddstring2_1 nil))
    (set_tile "textaddstring2" textaddstring2_1)
)
(action_tile "accept" "(get_dzmjjsbdc_main)(done_dialog 1)");;;确定
(setq return# (start_dialog))
(cond
    ((= return# 1)
                        (prompt "\n 选择文本<退出>")
                        (if (setq ss (ssget (list (cons 0 "TEXT"))))
                                (repeat (setq k (sslength ss))
                                        (setq ent (ssname ss (setq k (1- k))))
                                        (setq obj (vlax-ename->vla-object ent))
                                        (setq str1 (vla-get-textstring obj))
                                        (vla-put-textstring obj (strcat textaddstring1_1 str1 textaddstring2_1))
                                )                               
                        )                       
    )               
)       
(unload_dialog @dclid)       
(vl-file-delete @dclfiledame)       
(princ)       
)
;;;;;获得对话框值
(defun get_dzmjjsbdc_main ()
        (setq textaddstring1_1   (get_tile "textaddstring1"))
        (setq textaddstring2_1   (get_tile "textaddstring2"))
)

疯球 发表于 2019-5-28 21:02:21

与贱人工具箱的前后缀一样,谁能写个代码,谢谢!!

Kye 发表于 2019-5-29 08:52:36

本帖最后由 Kye 于 2019-5-29 08:54 编辑

http://bbs.mjtd.com/forum.php?mo ... hlight=%BA%F3%D7%BA
虽然此链接的发帖者 非常不厚道,但可以向ssyfeng大侠讨要啊,要来之后 ,如ssyfeng允许 还把代码贴在这个帖子中比较好


建议明总对设置【此贴仅作者可见】的功能收费,支持论坛的生存

疯球 发表于 2019-5-29 10:20:55

帮顶出高手吧

satan421 发表于 2019-5-29 10:30:39

;;entget+assoc得到组码1中的文字内容,多行文字可能需要注意下格式
;;strcat增加前后缀
;;subst替换
;;entmod更新资料
;;还有啥???

疯球 发表于 2019-5-29 19:25:42

请高手,出手!!

疯球 发表于 2019-5-30 09:15:02

继续等!,继续等 !!

疯球 发表于 2019-5-31 12:22:19

高手都在睡觉吗

疯球 发表于 2019-6-1 07:23:47

请各路大神给个指示吧
页: [1] 2 3
查看完整版本: 求个加前后缀的源码