Author Topic: Array blocks within a boudary  (Read 2262 times)

0 Members and 1 Guest are viewing this topic.

jpcadconsulting

  • Newt
  • Posts: 56
Array blocks within a boudary
« on: August 12, 2015, 04:59:04 PM »
Hi folks,

I'm looking for a routine similar to superhatch that will:

1. Let me select a block
2. Enter a spacing
3. Select a polyline and/or select an internal point
4. Fill that area with instances of that block

Superhatch was my first thought, and it's close... but when you explode the hatch, you get lines and arcs and I need the individual blocks to remain intact so I can extract data from them.

Anyone know of anything?  I'm coming up empty.

Thanks in advance for your help.

-JP


« Last Edit: August 25, 2015, 04:49:44 PM by jpcadconsulting »
Technology will save us all! *eyeroll*

Rod

  • Newt
  • Posts: 185
Re: Array blocks within a boudary
« Reply #1 on: August 13, 2015, 12:04:03 AM »
Highflyingbird created a great routine called supercopy.

See http://www.theswamp.org/index.php?topic=48113.msg531626#msg531626
"All models are wrong, some models are useful" - George Box

jvillarreal

  • Bull Frog
  • Posts: 332
Re: Array blocks within a boudary
« Reply #2 on: August 13, 2015, 01:03:39 PM »
Just create an array and erase outside of the boundary.

jpcadconsulting

  • Newt
  • Posts: 56
Re: Array blocks within a boudary
« Reply #3 on: August 20, 2015, 02:28:35 PM »
Ausrod (and highflyingbird of course),

Supercopy is a pretty awesome bit of code, and I'll make use of it i'm sure, but it does not do the one thing I'm really trying to achieve...  which is to automate the process outlined in jvillarreal's comment.

I'll keep looking.  If you find something, let me know.

Thanks,

-JP

Technology will save us all! *eyeroll*

jpcadconsulting

  • Newt
  • Posts: 56
Re: Array blocks within a boudary
« Reply #4 on: August 20, 2015, 02:34:07 PM »
Ha! You know, I searched again and just changed the wording a bit and this came up:

http://cadtips.cadalyst.com/content/filling

Works perfectly...

Hope you all find it useful, I know I will.

-JP
Technology will save us all! *eyeroll*

jpcadconsulting

  • Newt
  • Posts: 56
Re: Array blocks within a boudary
« Reply #5 on: August 25, 2015, 11:57:58 AM »
Ok so... this does work but it's an old routine and it does have some limitations.  I'm too much a novice at coding to really be able to sort this out.  I assume since 2007, there is a better, leaner, and/or more elegant way to do this.

It works like this (abbreviated):

1. You select a block
2. You enter the Row and Column spacing
3. You pick an internal point
4. It creates a hatch (ANSI31 - scaled so that the distance between the lines equals your desired row spacing)
5. It explodes that hatch
6. It uses the "array along path" (I think) to array the chosen block along the resulting lines at your given column spacing)
7. Deletes the lines leaving the blocks
8. Explodes the remaining arrays

Issues:

1. There are times when the setting of values regarding display of hatches (or your row spacing) can cause this routine to fail because it can (I assume) come up against the "Hatch too dense to display" error.
2. You cannot "select object(s)" to select the boundary, only "select internal point" which in large drawings can have issues.
3. It's "finicky" about how you enter the row and column distances (sometimes it just doesn't "take")
4. There is no undo "mark" (if that's what you call it) so if you need to undo, it steps through each block, one at a time, then the hatch elements... etc.

Although the DCL aspect of this is nice, it's not strictly necessary.  There are only a few things to input, and the block could be picked on screen or it's name entered manually.

Thanks in advance for any help.

-JP

« Last Edit: August 25, 2015, 12:06:52 PM by jpcadconsulting »
Technology will save us all! *eyeroll*

jvillarreal

  • Bull Frog
  • Posts: 332
Re: Array blocks within a boudary
« Reply #6 on: August 26, 2015, 10:51:31 AM »
If anybody wants to code this:

1. Start Undo Mark
2. Create a selection set of all objects in drawing prior to running this code.
3. Select "Object to array"
4. Select "Boundary to fill"
5. Get Distance between Columns and Rows for array
6. Get bounding box of "object to array" and "Boundary to fill".
7. Move "object to array" to lower left of "boundary to fill".
8. Array object using the width, height, and column/row spacing to determine number of rows and columns.
9. Zoom Window to bounding box of "boundary to fill".
10. Create a new selection set of all objects
11. Remove selection set created in step 2.
12. Use tracepolyline function to remove objects within "boundary to fill".
13. Erase new selection set.
14. End Undo Mark

ChrisCarlson

  • Guest
Re: Array blocks within a boudary
« Reply #7 on: August 26, 2015, 03:16:57 PM »

jpcadconsulting

  • Newt
  • Posts: 56
Re: Array blocks within a boudary
« Reply #8 on: September 08, 2015, 05:04:10 PM »
Alright...

I have cobbled (and I mean cobbled) this together and it almost works...


-Prompts for Row and Column distances (enter value or pick points)
-Prompts to select a block to use
-Prompts for an internal point
-It creates the array within the boundary as expected, but the blocks it inserts do not seem to have the attribute tag like the selected block does (see attached drawing).

As always, any help is appreciated.

Code: [Select]
(defun c:TESTadarray  (/ ent STR lyr ss rowdist coldist point0)

(setq rowdist (getdist "\n Distance Between rows :"))
(setq coldist (getdist "\n Distance Between columns :"))

     (cond
           ((and
                  (setq ent (car (entsel "\nSelect Block Entity: ")))
                  (eq (cdr (assoc 0 (entget ent))) "INSERT")
                  (setq STR (vla-get-effectivename
                                        (vlax-ename->vla-object ent)))
            )))

  (setq lyr "L-PL PERENNIAL")
  (vl-cmdf "Layer" "M" lyr "C" "yellow" "" "")
  (vl-cmdf "-Hatch" (getpoint "\nPick a point: ") "P" "U" "0.0" rowdist "N" "")
  (vl-cmdf "Explode" (entlast))
  (setq ss     (ssget "X"
      (list '(0 . "LINE")
    (cons 8 lyr)
      ) ;_ end of list
       ) ;_ end of ssget
num    (sslength ss)
i      -1
  ) ;_ end of setq
  (repeat num
    (setq en (ssname ss (setq i (1+ i))))
    (vl-cmdf "Measure" en "B" STR "Y" coldist)
    (entdel en)
  ) ;_ end of repeat
)
Technology will save us all! *eyeroll*

jpcadconsulting

  • Newt
  • Posts: 56
Re: Array blocks within a boudary
« Reply #9 on: September 08, 2015, 05:28:32 PM »
This seems to be an issue with the MEASURE command and blocks with attributes.  Added the following line and seems to be working now.  Still, I'm sure it could be cleaned up, error handling added, etc.

Code: [Select]
(vl-cmdf "attsync" "Name" STR)
Technology will save us all! *eyeroll*