asos2000 发表于 2022-7-6 10:33:08

所以
每个部件的用途是什么?
我可以在每个lisp的开头添加这些部分吗?
这一部分用于处理错误消息
但不应该是StartUndoMark
 
在autocad中创建对象的步骤
 
这部分是否允许在modelspace和PaperSpace中绘制对象?

Lee Mac 发表于 2022-7-6 10:35:53

 
如果例程在评估EndUndoMark之前崩溃,则vla EndUndoMark完成撤消对。
 
 
此部分从AutoCAD应用程序对象获取文档对象-请参见帮助中的对象模型结构。
 
 
这只是获取活动空间,无论是模型、纸张还是通过视口的模型。

asos2000 发表于 2022-7-6 10:39:32

我试图添加一个循环,但没有工作,我不知道为什么
 

Lee Mac 发表于 2022-7-6 10:43:04

在您的代码中,整个IF语句需要返回T才能循环,如果返回了,您将无法退出。
 
更容易:
 

(defun c:test (/ *error* DIMOFF P1 P2 P3 P4 SPC TXT UFLAG)
(vl-load-com)

(setq DimOff 400.0) ;; Dimension Offset Distance

(defun *error* (msg)
   (and uFlag (vla-EndUndoMark doc))
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
       (princ (strcat "\n** Error: " msg " **")))
   (princ))

(setq doc (cond (doc) ((vla-get-ActiveDocument
                        (vlax-get-Acad-Object))))

       spc (if (zerop (vla-get-activespace doc))
             (if (= (vla-get-mspace doc) :vlax-true)
               (vla-get-modelspace doc)
               (vla-get-paperspace doc))
             (vla-get-modelspace doc)))         

(while (and (setq p1 (getpoint "\nPick Center Point: "))
             (setq p2 (getpoint "\nPick Corner Point: "))
             (/= "" (setq txt (getstring "\nColumn Number: "))))

   (setq uFlag (not (vla-StartUndoMark doc)))

   (apply (function vla-AddDimRotated)
            (append (list spc)
                  (mapcar
                      (function vlax-3D-point)
                      (list (setqp3 (list (car p1) (cadr p2) (caddr p1))) p2
                            (polar p3 (angle p1 p3) DimOff)))
                  '(0.)))

   (apply (function vla-AddDimRotated)
            (append (list spc)
                  (mapcar
                      (function vlax-3D-point)
                      (list p2 (setqp4 (list (car p2) (cadr p1) (caddr p1)))
                               (polar p4 (angle p1 p4) DimOff)))
                  (list (/ pi 2.))))

   (vla-AddText spc txt
       (vlax-3D-point
         (polar p2 (angle p1 p2) (sqrt (* 2. DimOff Dimoff)))) (getvar "TEXTSIZE"))            

   (setq uFlag (vla-EndUndoMark doc)))

(princ))

asos2000 发表于 2022-7-6 10:44:44

我们可以删除colum吗
 
 
我补充道;靠近线路,但环路不工作

Lee Mac 发表于 2022-7-6 10:48:26

 
因为它是AND语句的一部分。
 
那么,是否也应该没有列文本?

asos2000 发表于 2022-7-6 10:50:20


可以吗
 
有一个问题
如何以与lisp编辑器相同的格式发布lisp?

Lee Mac 发表于 2022-7-6 10:56:08

Asos,
 
使用
tags instead oftags to post code.<p> </p><p>Read here:</p><p></p><p>http://www.cadtutor.net/forum/showthread.php?t=9184</p><p> </p><p>To get the colours of the Visual LISP Editor, I wrote a LISP to read the LISP file and write out code with the colour added. </p>

asos2000 发表于 2022-7-6 10:59:32

你应该把名字改成Lisp MAc而不是Lee MAc

Lee Mac 发表于 2022-7-6 11:02:45

 
哈哈
页: 1 [2]
查看完整版本: 如何添加多个测试