Lisp routine for inserting blocks on nodes

Chris Newman

Usenet Archive
Joined
Jan 22, 2004
Messages
12
Reaction score
0
Is there a Lisp routine for inserting blocks on nodes on their own layer? i.e. nodes on a layer called manhole, then insert a manhole block.

Thanks
Chris
 
Here's a little routine to get you started. You must supply the block name of a block already defined in the drawing. It will ask for the user to select a point on the layer to search for point nodes, if any nodes are found it will insert the block at the node location and on the same layer as the node.

So, using your example, if you have a layer called "manhole" that has point nodes on it, and the drawing has a block defined called "manhole", type the following at the command line:

Command: (ins@pt "manhole")

By doing it this way, you can have a number of different buttons to insert different blocks on different layers.

This is by no means a "final" routine, it is provided to give you something to work with. For instance, I only insert the block at a scale of 1 with no rotation. You may want to revise these which are found in this line:
'insertblock (vlax-3d-point inspt) bname 1.0 1.0 1.0 0)

x y z rot
HTH,
Jeff

(defun ins@pt (bname / ss ent lay inspt blk count)
(if (setq ent (entsel (strcat "\nSelect node on layer to insert \"" bname "\""))) (progn (setq lay (cdr (assoc 8 (entget (car ent))))) (if (setq ss (ssget "x" (list '(0 . "POINT")(cons 8 lay)))) (progn (setq count 0) (repeat (sslength ss) (setq ent (vlax-ename->vla-object (ssname ss count)) inspt (vlax-get ent 'coordinates)) (setq blk (vlax-invoke-method (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))) 'insertblock (vlax-3d-point inspt) bname 1.0
1.0 1.0 0)
)
(vla-put-layer blk lay)
(setq count (1+ count))
)
)
)
)
)
(if count
(princ (strcat "\nAdded " (itoa count) " instances of \"" bname "\"")) ) (princ)
)
 
Hi Chris,

While the Lisp solution posted in this thread should help you get started, you may want to expolore some third party tools that can do just this and much more.

Our GeoTools program (see URL below for a fully functional eval download) can convert points (nodes) ad well as nodes in lines and polylines into blocks or shapes and much more.

You may want to give this a look.

If you need any tweaks, do feel free to ask me.

Download URL:

www.4d-technologies.com/geotools

Regards
Rakesh

Chris said:
Is there a Lisp routine for inserting blocks on nodes on their own layer? i.e. nodes on a layer called manhole, then insert a manhole block.

Thanks
Chris
 
Back
Top