autocad lisp创建线b
你好我正在寻找一个lisp,可以通过键入点名称创建线或pline。
我将autocad文件中的点作为块属性,每个点都有名称。
知道吗?
请参阅附件 没有附加文件。 AUTOCAD文件
For_lisp。图纸 这应该符合你的要求
(defun c:plbtwnpoints (/ blockSS)
;; Get Attribute Value-Lee Mac
;; Returns the value held by the specified tag within the supplied block, if present.
;; blk - VLA Block Reference Object
;; tag - Attribute TagString
;; Returns: Attribute value, else nil if tag is not found.
(defun LM:vl-getattributevalue ( blk tag )
(setq tag (strcase tag))
(vl-some '(lambda ( att ) (if (= tag (strcase (vla-get-tagstring att))) (vla-get-textstring att)))
(vlax-invoke blk 'getattributes)
)
)
(defun Line (p1 p2)
(entmakex (list (cons 0 "LINE")
(cons 10 p1)
(cons 11 p2))))
(if (setq blockSS (ssget "X" (list (cons 0 "INSERT") (cons 2 "CIVIL-0"))))
(progn
(setq nameLatLongList (mapcar '(lambda (x) (list (LM:vl-getattributevalue (vlax-ename->vla-object x) "NAME") (cdr (assoc 10 (entget x))))) (mapcar 'cadr (ssnamex blockSS))))))
(princ "\nDrawing Line...\n")
(setq firstpoint (getstring "Enter the name of the first point: "))
(if (assoc firstpoint nameLatLongList)
(while (not (eq (setq nextpoint (getstring "\nType the name of the next point: ")) ""))
(if (assoc nextpoint nameLatLongList)
(line (cadr (assoc firstpoint nameLatLongList)) (cadr (assoc (setq firstpoint nextpoint) nameLatLongList)))
(princ "\nInvalid point. Try again..."))
))
) 哇!很不错的
我会尽力的
页:
[1]