Control The Number Of Block Insertions In A Column

Discussion in 'AutoCAD' started by Coyote, Jan 19, 2005.

  1. Coyote

    Coyote Guest

    I've written a program, with the help of many of you, that counts all the blocks in a drawing file then sums the quantity based on attribute value and inserts a block showing the quantity. Currently the blocks are inserted into a single column regardless of how many blocks are found.

    What I'd like to know is if there's away to control the number of blocks inserted into a single column and if it exceeds that number start a 2nd, 3rd etc column.

    Example: I have 35 blocks to be inserted, I only want to have 20 in any single column so the program would insert 20 in the first column and the remain 15 in a 2nd column.

    Thanks in advance
    Coyote
     
    Coyote, Jan 19, 2005
    #1
  2. Coyote

    Jeff Mishler Guest

    Sure, just add a counter into your loop, when it reaches 21 recalc your
    column's x value and reset the counter to 0.
     
    Jeff Mishler, Jan 19, 2005
    #2
  3. Coyote

    CAB2k Guest

    Here is one way:
    Code:
    (setq pt (getpoint "\nPick Upper Left Position."))
    (setq x   (car pt)
    y   (cadr pt)
    cnt 1
    )
    (foreach blk blklist
    (command "-insert" blk (list x y) "" "" "")
    (if (< cnt 20)
    (setq x (- x 20) ; step 20 units
    cnt (1+ cnt)
    )
    (setq y (+ y 100) ; next column
    x (car pt)  ; reset x
    cnt 1
    )
    )
    )
     
    CAB2k, Jan 23, 2005
    #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.