Lisp routine for inserting blocks on nodes

Discussion in 'AutoCAD' started by Chris Newman, Jan 22, 2004.

  1. Chris Newman

    Chris Newman Guest

    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
     
    Chris Newman, Jan 22, 2004
    #1
  2. Chris Newman

    Jeff Mishler Guest

    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)
    )
     
    Jeff Mishler, Jan 22, 2004
    #2
  3. Chris Newman

    Rakesh Rao Guest

    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


    --

    AutoCAD customization for Engineering/Mapping/GIS
    Get GeoTools @ http://www.4d-technologies.com/geotools
    Build MyGeoTools @ http://www.4d-technologies.com/geotools/my_geotools.htm
    FREE downloads : http://www.4d-technologies.com/techcenter
    </PRE>
     
    Rakesh Rao, Jan 22, 2004
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.