withyou Posted July 15, 2017 Posted July 15, 2017 hello i am looking for a lisp that can create lines or pline by typing point names. i have the points in my autocad file as blocks attribute with name for each point. any idea ? please see attached file Quote
Commandobill Posted July 16, 2017 Posted July 16, 2017 This should do what you ask (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] VLA Block Reference Object ;; tag - [str] Attribute TagString ;; Returns: [str] 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...")) )) ) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.