Lee Mac 发表于 2022-7-6 15:14:47

版本兼容性问题。。

大家好,
 
希望你们今天过得愉快,不要工作过度(只够勉强应付)。
 
只是一个简单的问题-我相信这里有人能够回答-如果没有,不用担心。
 
关于此线程:
 
http://www.cadtutor.net/forum/showthread.php?t=31790
 
我发布了以下LISP以响应上面线程中发布的绘图示例:
 

; Diamond ~ by Lee McDonnel

; Places a Diamond Block at the Intersection of a LWPolyline

;

;

(defun c:diamond (/ ss lEnt eLst sLin eLin pvert i int intLst)
(vl-load-com)
(if (and (setq ss (ssget '((0 . "LWPOLYLINE"))))
      (setq lEnt (car (entsel "\nSelect Intersecting Line > ")))
      (eq (cdr (assoc 0 (entget lEnt))) "LINE"))
   (progn
   (setq eLst (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
       sLin (cdr (assoc 10 (entget lEnt)))
       eLin (cdr (assoc 11 (entget lEnt))))
   (foreach ent eLst
   (setq pVert (mapcar 'cdr (vl-remove-if '(lambda (x) (/= 10 (car x))) (entget ent))))
   (if (eq (setq i (length pVert)) 4)
   (progn
       (while (not (zerop (setq i (1- i))))
         (if (setq int (inters sLin eLin (nth i pVert) (nth (1- i) pVert)))
       (setq intLst (cons int intLst))))
       (setq intLst (vl-sort intLst '(lambda (x1 x2) (< (car x1) (car x2)))))
       (SetBlkTF "3ANSYMB")
       (entmake (list (cons 0 "INSERT") (cons 2 "3ANSYMB") (cons 10 (cadr intLst))))
       (entmake (list (cons 0 "INSERT") (cons 2 "3ANSYMB") (cons 10 (cons (- (caar intLst) 6.5515) (cdar intLst))))))))
   (entdel lEnt))
   (princ "\n<!> No Line Selected, or this isn't a Line! <!>"))
(princ))

(defun SetBlkTF    (n)
   (cond ((not (snvalid n))
      (princ "\nInvalid Block Name - " n)
      (exit))
   ((tblsearch "BLOCK" n))
   ((findfile (strcat n ".DWG"))
      (command "_.INSERT" n)
      (command))
   (T ; If all else fails....
      (entmake (list (cons 0 "BLOCK") (cons 2 n) (cons 10 (list 0 0 0)) (cons 70 0)))
      (entmake (list (cons 0 "TEXT")
             (cons 1 (strcat "BLOCK PLACECARD - " n))
             (cons 7 (cdr (assoc 2 (tblnext "STYLE" T))))
             (cons 8 "0")
             (cons 10 (list 0 0 0))
             (cons 11 (list 0 0 0))
             (cons 40 (max 1 (getvar "TEXTSIZE")))
             (cons 72 4)))
      (entmake (list (cons 0 "ENDBLK") (cons 8 "0")))))n)


 
但是,由于一些未知的原因(记录在链接线程中),LISP似乎在我的机器上运行,运行ACAD'04,但在OP的机器上运行'07。
 
我想不出发生这种情况的原因,因为在LISP中,我没有使用任何“命令”函数(消除了提示顺序不同的可能性),而且我认为AutoLISP在3年内没有发生如此大的变化。
 
最后,Fixo发布了该问题的另一个解决方案,使用类似的方法插入所需的块,但是他的代码在2007年正确运行。
 
如果有人能提供更多信息,说明为什么我的帖子在07年没有成功,但在04年成功,我将不胜感激。
 
谢谢你花时间阅读这篇文章,如果你还没有这样做,祝你度过愉快的一天。
 
干杯
 

ReMark 发表于 2022-7-6 15:42:00

可能是对AutoCAD系统变量的更改?
 
http://www.hyperpics.com/system_variables/

Lee Mac 发表于 2022-7-6 15:56:15

非常感谢您的链接评论,但我不认为我篡改了LISP中的任何系统变量-但感谢您的建议。
 
已将该页面添加为书签以供以后参考-谢谢

ReMark 发表于 2022-7-6 16:09:50

错误检查?常规程序得到的是一个它无法识别或预期的响应,因此它会爆炸?

Lee Mac 发表于 2022-7-6 16:20:09

显然,根据杰克·奥尼尔(Jack O'Neill)的说法,没有发生任何错误——例程在修改一个实体后就完成了——似乎“foreach”没有遍历实体列表,或者ssnamex没有返回完整的实体名称列表。。。但很明显,这些在04年起作用,那么为什么他们不应该在07年。。。。
页: [1]
查看完整版本: 版本兼容性问题。。