Results 1 to 2 of 2

Thread: Count Specific Block Name and Insert Block to Coords Depending on Block Count

  1. #1
    Woo! Hoo! my 1st post
    Join Date
    2015-09
    Posts
    1
    Login to Give a bone
    0

    Default Count Specific Block Name and Insert Block to Coords Depending on Block Count

    Hi there,

    I'm looking for a Lisp routine that can count the number of one specific block (it will always have the same name) that will be within paperspace, and then automatically insert the same block again into paperspace, to differing coordinates depending on how many of that block there already is.

    For example:

    Block count = 1, insert block at 0,0,0
    Block count = 2, insert block at 0,50,0
    Block count = 3, insert block at 0,100,0
    ...and so on.

    I am having doubts to whether this would even be possible but I thought I would ask.

    I've began to explore the world of Lisp and am using a few different routines currently.
    They work great but I am nowhere near at a stage where I can write a detailed Lisp routine myself.

    [Using AutoCAD 2017 full version]

    Thanks guys,

    Kyle
    Last edited by kylaughlan; 2017-01-11 at 07:42 AM.

  2. #2
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    560
    Login to Give a bone
    0

    Default Re: Count Specific Block Name and Insert Block to Coords Depending on Block Count

    This is a start but looking at it you probably want to copy each individual block to 0,0 next block 0,50 etc if so post.

    Code:
    (defun copyblock ( xinc x y obj inspt bname ss)
    (setq xinc 50)
    (setq y 0)
    (setq x 0)
    (setq obj (entget (car (entsel "pick block"))))
    (setq bname (cdr (assoc 2 obj)))
    (setq ss (ssget "x" (list (cons 0 "insert")(cons 2 bname)(cons 410 (getvar 'ctab)))))
    (repeat (setq z (sslength ss))
    (command "insert" bname (list x y) 1 1 0 1 2 3 4)
    (setq x (+ x xinc))
    )
    )
    (copyblock)

Similar Threads

  1. block count
    By klcecity371697 in forum AutoLISP
    Replies: 8
    Last Post: 2013-05-19, 08:42 PM
  2. count block
    By lee.johnson in forum AutoLISP
    Replies: 12
    Last Post: 2009-09-30, 03:24 PM
  3. Block Count
    By markwise in forum AutoCAD General
    Replies: 2
    Last Post: 2008-09-19, 11:53 PM
  4. Block Count
    By sherflor in forum AutoCAD General
    Replies: 5
    Last Post: 2008-04-19, 04:34 PM
  5. Create BOM from Block Count
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 1
    Last Post: 2006-03-16, 09:18 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •