Jimmy Sean 发表于 2022-7-6 06:26:07

区域lisp帮助

我有我们的工程师使用的lisp例程。我过去曾对其进行过调整,但现在我无法确定它失败的原因。如果有比我更熟练的人帮助我确定问题以及如何纠正,我将不胜感激。该例程应允许选择多段线,然后放置显示平方英尺的多行文字字段。在字段放置的选择点之后失败。它不会出错,但也不会显示文本。
 
(defun c:arl64 ()
(vl-load-com)
;;get a reference to model space
(setvar "textsize" 0.09375)
(setvar "luprec" 0)
(setq *model-space*
       (vla-get-ModelSpace
   (vla-get-ActiveDocument (vlax-get-acad-object))
       )
)
;;pass this function an entity and a point
(defun LinkedArea (ent pt / obj objID ip width str)
;;convert the entity to an object
(setq ar2 (car (entsel "\nSelect Area Boundary: ")))
(setq objID (vlax-invoke-method (vla-get-Utility (vla-get-activedocument (vlax-get-acad-object))) "GetObjectIdString" (vlax-ename->vla-object ar2) :vlax-False))

(setq    ;;convert the point
    ip    (vlax-3D-Point pt)
    ;;set the width for the MTEXT
    width 0.0
)
    ;;set the string - this creates the field
(setq str (strcat "%<\\AcObjProp Object(%<\\_ObjId " objID ">%).Area \\f \"%pr0%lu2%ct4%qf1 SQ. FT.\">%"))
   
;;Create the MTEXT entity containing the field.
(vla-addMText *model-space* ip width str)
)

;; Set A = the entity and set B = Point for text
(setq a (car (entsel)) b (getpoint "\n Select Text Insertion Point: "))
;;Call the function
(linkedarea a b)
(princ)
)s
 
谢谢
肖恩

neophoible 发表于 2022-7-6 07:48:15

这对我很有效。嗯,我做了两个MOD。首先,始终避免使用任何LISP项作为变量。因此,我将str重命名为strg。另外,文件末尾的“s”是用来做什么的?
页: [1]
查看完整版本: 区域lisp帮助