本帖最后由 greatvictory 于 2016-10-7 22:53 编辑
不知为什么调用个自己写的函数就失灵,篇幅缘故弄了test示意一下,要用到两个参数,当前点的位置,悬停图元的码表,返回一个字符串,在动态里显示,大概就是这么个功能,求问为啥一用函数就失灵呢?就拿贴主的演示代码,第7行保存了个当前点,42行调用了下test函数,53行后面是test的内容,求指导啊!
- ;;;*********************************************************************;;;Example 1: shows how to display the infomation of an entity and the
- ;;;position of cursor,and its current osnap mode.
- ;;;*********************************************************************
- (defun c:Info (/ ret)
- (defun InfoCallback (dynpt / txt elist osmod NNest dat)
- (setq txt (vl-princ-to-string (mapcar 'rtos dynpt)))
- (setq p txt)
- (setq txt (strcat "The coordinate is: " txt))
- (setq elist (HFB_GetAperture)) ; Aperture Entities
- (setq osmod (HFB_GetOSMode)) ; current osnap modes
- (setq NNest (HFB_GetNested)) ; nested Aperture Entities
- (if (> osmod 0)
- (progn
- (princ "\nThe osnap mode is: ")
- (princ (cdar (vl-member-if
- '(lambda (x) (/= (logand osmod (car x)) 0))
- '((1 . "Endpoint")
- (2 . "Midpoint")
- (4 . "Center")
- (8 . "Node")
- (16 . "Quadrant")
- (32 . "Intersection")
- (64 . "Insert")
- (128 . "Perpendicular")
- (256 . "Tangent")
- (512 . "Nearest")
- (1024 . "Apparent intersection")
- (2048 . "Parallel")
- (4096 . "Extension")
- )
- )
- )
- )
- )
- )
- ;;If there are entities nearby the cursor,then display the infomation
- ;;about the first one.
- (if elist
- (progn
- (setq dat (entget (car elist)))
- (strcat txt "\nThe type of aperture Entity is: " (test dat p)))
- )
- txt
- )
- )
- (setq ret (HFB_PointMonitor "InfoCallback"))
- (prompt "\nIf you want to turn off the monitor,please use (HFB_PointMonitor) or command \"IPMOFF\".")
- (princ)
- )
- (defun test (e p)
- (strcat (cdr (assoc 1 e)) (rtos (car p) 2))
- )
|