混沌初开 发表于 2013-11-25 19:54:29

快速插入

我有个快速调出dwg档的指令,指令的键入顺序如下图。 源代码在二楼,问题:这个调入程序是先输入de→输入需要的dwg档名称→选择插入位置→调整图元X、Y比例→回车后才能插入图元。想改成:先输入de→输入需要的dwg档名称→出现图元,且跟随鼠标移动→调整图元X、Y比例→点击鼠标左键→图元显示在左键点击处。

混沌初开 发表于 2013-11-25 19:56:36

(defun c:de(/ file dwg pt sx sy)
(setvar "cmdecho" 0)
(setq file (getstring "\n输入待输入的图形文件名:"))
(if (not file)(exit)
    (progn
      (setq dwg(findfile(strcat file ".dwg")))
      (if(not dwg)(exit)
        (progn
          (setq pt(getpoint "\n指定插入点:"))
          (if(not pt)(exit)
          (progn
              (setq sx(getreal "\指定X比例<1>:"))
              (if(not sx)(setq sx 1))
              (setq sy(getreal "\指定Y比例<1>:"))
              (if(not sy)(setq sy 1))
              (command "-insert" dwg pt sx sy "0")
              )
          )
          )
        )
      )
    )
(setvar "cmdecho" 0)
(princ)
)

llsheng_73 发表于 2013-11-25 20:43:04

本帖最后由 llsheng_73 于 2013-11-25 21:26 编辑

(defun c:de(/ file dwg a sx sy)
   (setvar "cmdecho" 0)
   (setq file (getstring "\n输入待输入的图形文件名:"))
   (if (not file)(exit)
   (progn
       (setq dwg(findfile(strcat file ".dwg")))
       (if(not dwg)(exit)
         (progn
           (command "-insert" dwg '(0 0 0) 1 1 "0");;(entmake
           (setq dwg(vl-filename-basedwg))
           (while(/=(car(setq a(grread 4)))3);;;;grread感觉没处理好,不太会这个函数,E文的帮助不能给我提供有效帮助,只能让我头痛
             (command"ERASE"(SSADD(ENTLAST))"");;;改为(entdel(entlast))应该要好些
             (command "-insert" dwg(cadr a)1 1 "0"))
           (setq sx(if(setq sx(getreal "\指定X比例<1>:"))sx 1))
           (setq sy(if(setq sy(getreal "\指定Y比例<1>:"))sy 1))
           (command"ERASE"(SSADD(ENTLAST))"");;;改为(entdel(entlast))应该要好些
           (command "-insert" dwg(cadr a)sx sy "0")
           )
             )
         )
         )
   (setvar "cmdecho" 0)
   (princ)
   )

lsjj 发表于 2013-11-25 20:57:30

做的是基本指令的事,感覺有點多此一舉

混沌初开 发表于 2013-11-25 23:22:24

llsheng_73 发表于 2013-11-25 20:43 static/image/common/back.gif
(defun c:de(/ file dwg a sx sy)
   (setvar "cmdecho" 0)
   (setq file (getstring "\n输入待输入的图 ...

要不您怎重新发一个!

llsheng_73 发表于 2013-11-26 00:08:33

(defun c:de(/ file dwg a sx sy)
    (setvar "cmdecho" 0)
    (setq file (getstring "\n输入待输入的图形文件名:"))
    (if (not file)(exit)
      (progn
      (setq dwg(findfile(strcat file ".dwg")))
      (if(not dwg)(exit)
          (progn
            (command "-insert" dwg '(0 0 0) 1 1 "0");;(entmake
            (setq dwg(vl-filename-basedwg))
            (while(/=(car(setq a(grread 4)))3)
             (entdel(entlast))
             (command "-insert" dwg(cadr a)1 1 "0"))
            (setq sx(if(setq sx(getreal "\指定X比例<1>:"))sx 1))
            (setq sy(if(setq sy(getreal "\指定Y比例<1>:"))sy 1))
            (entdel(entlast))
         (command "-insert" dwg(cadr a)sx sy "0")
            )
            )
            )
          )
    (setvar "cmdecho" 0)
    (princ)
    )

混沌初开 发表于 2013-11-27 23:46:13

llsheng_73 发表于 2013-11-26 00:08 static/image/common/back.gif
(defun c:de(/ file dwg a sx sy)
    (setvar "cmdecho" 0)
    (setq file (getstring "\n输入待输入的 ...

这个程序当鼠标移动过快时,所调出的图元跟不上。上一个程序无此现象!另外调出的图元跟在鼠标上,插入某位置时无法锁点。
页: [1]
查看完整版本: 快速插入