; PUT.LSP - Inserts a user-selected block a fixed distance from either ; end of an arc, line, or open spline, polyline, or lwpolyline. The ; block to be inserted must be either already loaded in the current ; drawing, be in the form of a .dwg file to be found in the AutoCAD ; search path. ; ; While the block definition may contain attributes, attribute values ; will not be requested or shown, since attributes are not supported ; by the native AutoCAD Measure command. ; (defun C:PUT (/ ar ce e0 ex e1 e2 bk d1 p1) (command "_.undo" "_be") (setq ar (getvar "attreq") ce (getvar "cmdecho") os (getvar "osmode") );;setq (setvar "cmdecho" 0) (setvar "attreq" 0) (setvar "osmode" 0) (while (or (not (setq e1 (entsel "\nSelect object near reference end: "))) (and (/= (setq e2 (cdr (assoc 0 (entget (car e1))))) "ARC") (/= e2 "LINE") (/= e2 "SPLINE") (/= e2 "POLYLINE") (/= e2 "LWPOLYLINE") );;and );;or );;while (while (or (= (setq bk (getstring "\nBlock to use: ")) "") (and (not (findfile (strcat bk ".dwg"))) (not (tblsearch "block" bk)) );;and );;or (princ (strcat "\nBlock " (strcase bk) " not found; enter Block Name or ESC to cancel: ") );;strcat );;princ (while (not (setq d1 (getdist "\nDistance to Insertion Point: ")))) (command "_.insert" bk '(0 0))(command) (setq e0 (entlast) ex e0) (command "_.measure" (setq p1 (cadr e1)) "_b" bk "_y" d1) (setq px (vlax-curve-getpointatdist (car e1) d1)) (while (setq e0 (entnext e0)) (if (and (setq p2 (cdr (assoc 10 (entget e0)))) (not (equal p2 px)) );;and (progn (setq elast e0) (entdel e0) );;progn );;if );;while (if (equal ex (entlast))(entdel elast)) (setvar "attreq" ar) (setvar "cmdecho" ce) (setvar "osmode" os) (command "_.undo" "e") (princ) ) (alert (strcat "PUT.LSP (c) 1998-2005 Tee Square Graphics\n\n" "Places a user-selected block at a fixed\n" "distance along an ARC, LINE, SPLINE,\n" "POLYLINE, or LWPOLYLINE.\n\n" "Type PUT to begin.")) (princ)