That code didn't have the "wrapping" required to
make it into an independent command. Also, if you're only
talking about one Layer, the (cond) function can be simplified into an (if)
function. Try this as the content of MBIP.LSP:
(defun C:MBIP (/ pointset ptdata ptlay
blkname)
(setq pointset (ssget "X" '((0 . "POINT"))))
; find all points in drawing
(while (> (sslength pointset) 0) ; as
long as there's something left in the set
(setq
ptdata (entget
(ssname pointset 0)); entity data for first point in the set
ptlay (cdr (assoc 8
ptdata)); layer the point is on
blkname
face=Arial size=2>(if (= ptlay "Layer1") "Block1"
nil); no block name if not one right Layer
); end setq
(if blkname ; -- set Layer and
Insert Block only if Point is on the right Layer
(command
"_.-layer" "_set" ptlay ""
"_.insert" blkname (cdr (assoc 10 ptdata)) "" "" ""
); end
command
); end if
(setq pointset (ssdel (ssname
pointset 0) pointset)); remove that point from the set, and
); end while -- go back and do it again
with the next point
); end defun
Substitute into that the Layer name you want in
place of "Layer1" [but also in double quotes like that], and the Block name
similarly in place of "Block1". Make sure the Block definition is
either already in the drawing, or available on one of the Support File Search
Paths in the Files tab of the Options dialog box.
Once it's loaded, just type MBIP at the Command:
prompt to activate it. You could also make a menu or toolbar or similar
item that you could just pick on.
If you would like the User to be able to specify
the Layer and Block names differently every time, rather than having them
"fixed" in the routine, that can also be done -- write back.
It could also use some of the usual
enhancements (turning off Osnap, saving the current Layer, etc., and restoring
those settings at the end; error handling if it involves User input; perhaps a
message to the User about how many Blocks it put in; also erasing of the Point
entities if you want that).
--
Kent Cooper
mapwoman wrote...
Okay, so I made a lisp file containing the code from
you previous post, shown at bottom. When I load the List (I named it MBIP.lsp) I
get the following message; MBIP.LSP successfully loaded. Command: ; error:
syntax error Command: What could be wrong? Also what do I type in to activate
the code? ....