xgr 发表于 2012-6-10 20:19:09

选择的问题

用OPENDCL 制作了个面板控件,从面板切换到CAD选择是总是提示
无法重复进入 LISP。
*无效选择*
需要单个对象。
不知道问题出在哪里?
程序如下:

(defun C:Point_Repair ()
;;确保加载ObjectDcl动态连接库
(if (not (member "OpenDCL.16.arx" (arx)))
    (arxload "C:\\Program Files\\徐光工具\\system\\OpenDCL.16.arx")
    ("加载OpenDCL.16.arx 失败.")
)
;;加载对话框odc文件
(dcl_Project_Load "PointRepair.odcl")
;;显示DclForm1对话框
(dcl_Form_Show PointRepair_Form1)
(princ)
)


(defun c:PointRepair_Form1_TextButton1_OnClicked (/)
(setq ent (ssget "x" '((0 . "INSERT")(2 . "Point_mk"))))
(setq n 0)
(repeat (sslength ent)
    (setq ent1(entget (ssname ent n)))
    (setq ss (entget (ssname ent n) (list "US_XGGJ"))) ;取实体数据表US_XGGJ
    ;;点号
    (if(/= (assoc -3 ss) nil)
      (progn (setq dm (cdr (nth 2 (cadr (assoc -3 ss)))))
       (if (= dm nil)
         (setq dm " ")
       )
      )
      (setq dm " ")
    )
    ;;X坐标
    (setq coordinates_x(rtos (nth 0 (trans (cdr(assoc 10 ent1)) 0 1)) 2 3))
    ;;y坐标
    (setq coordinates_y(rtos (nth 1 (trans (cdr(assoc 10 ent1)) 0 1)) 2 3))
   ;;y坐标
    (setq coordinates_z(rtos (nth 2 (trans (cdr(assoc 10 ent1)) 0 1)) 2 3))
    (setq n (1+ n))
    (setq str (strcat (itoa n) "\t" dm "\t" coordinates_x "\t" coordinates_y "\t" coordinates_z))
    (dcl_Grid_AddString PointRepair_Form1_格1 str)
)
(alert (strcat "共读入测量点数据" (itoa n) "个"))
)

;;双击将选择的点名称文字加入到扩展数据
(defun PointRepair_Form1_格1_OnDblClicked (Row Column /)
(setq mm (dcl_Grid_GetCurCell PointRepair_Form1_格1))
(setq l (getvar "ltscale"))
(if (= (cadr mm) -1)
    (progn (dcl_Control_SetKeepFocus PointRepair_Form1 False)
   (setq x (dcl_Grid_GetCellText PointRepair_Form1_格1 (car mm) 2))
   (setq y (dcl_Grid_GetCellText PointRepair_Form1_格1 (car mm) 3))
   (setq coord (list (atof x) (atof y)))
   (command "zoom" "c" coord (* 20 l))
   (setq p1 (polar (polar coord (UcsRotationAngle) (* l 0.5))
         (+ (/ pi 2) (UcsRotationAngle))
         (* l 0.5)
      )
   )
   (setq p2 (polar p1 (+ pi (UcsRotationAngle)) (* l 1)))
   (setq p3 (polar p2 (+ (/ (* pi 3) 2) (UcsRotationAngle)) (* l 1)))
   (setq p4 (polar p3 (UcsRotationAngle) (* l 1)))
   (grdraw p1 p2 1)
   (grdraw p2 p3 1)
   (grdraw p3 p4 1)
   (grdraw p4 p1 1)
   ;;在ENT选择集里查找对象
   (setq coordinates_x ""
   coordinates_y ""
   n 0
   )
   (while (and (/= x coordinates_x) (/= y coordinates_y) (< n (sslength ent)))
       (setq ent1 (entget (ssname ent n)))
       (setq ent1_name (cdr (assoc -1 ent1)))
       (setq coordinates_x (rtos (nth 1 (assoc 10 ent1)) 2 3))
       (setq coordinates_y (rtos (nth 2 (assoc 10 ent1)) 2 3))
       (setq n (1+ n))
   )
   (setq ss (ssadd ent1_name))
   (sssetfirst ss ss)
   (setq en (nentselp "\n请选择为该点名称的文字或多行文字:"))
   (setq stbmx (itoa 510001))
   (setq pb (entget ent1_name))
   (setq xb
      (append
      pb
      (list
          (list '-3
          (list "US_XGGJ" (cons 1000 stbmx) (cons 1000 (cdr (assoc 1 (entget (car en))))))
          )
      )
      )
   )
   (entmod xb)
   (dcl_Grid_SetCellText PointRepair_Form1_格1 (car mm) 1 (cdr (assoc 1 (entget (car en)))))
   (prompt "\n 已经把点名加入了扩展数据!")
   (dcl_Control_SetKeepFocus PointRepair_Form1 true)
    )
)
(princ)
)

;;关闭窗口
(defun c:PointRepair_Form1_TextButton3_OnClicked (/)
(dcl_Form_Close PointRepair_Form1)
)

(defun c:PointRepair_Form1_格1_OnMouseUp (Button Flags X Y /)
(dcl_Control_SetText PointRepair_Form1_TextBox1 "双击序号列可以进入点编辑状态")
)
ODCL文件



请看动画里命令行提示,不知道错误到底出在那儿。

xgr 发表于 2012-6-11 00:24:58

谁见过这样的文字

bluelisp 发表于 2012-6-16 11:19:16

我见过
我的问题原因是:LISP提请等待用户输入过程中,无法执行其他任何LISP函数,直到用户输入完毕。
例如:点击ODCL后,执行getpoint函数,当鼠标从ODCL移到绘图区时,该动作会触发MouseMovedOff事件,事件响应函数OnMouseMovedOff中肯定需要用AutoLISP定义一些动作,如(princ),此时会出现“无法重复进入 LISP”错误。解决办法:去除ODCL中MouseMovedOff事件
希望对你是否有帮助

xgr 发表于 2012-6-16 14:52:37

谢谢,我知道了什么原因,程序没有问题,是鼠标的左键有点问题。单击左键有时候会出现双击的现象。

一克拉沙 发表于 2014-1-6 13:05:31

遇到了类似问题载入程序后,单击按钮调用外部LISP文件,提示“无法重复进入 LISP”。
页: [1]
查看完整版本: 选择的问题