Community
Civil 3D Forum
Welcome to Autodesk’s Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Subdivide a rectangle

30 REPLIES 30
SOLVED
Reply
Message 1 of 31
owenmull
4224 Views, 30 Replies

Subdivide a rectangle

Greetings.

 

I am wondering, does anyone have or know of a LSP routine or some easy way to take any given rectangle and divide it into "x" number of rectangles?

 

I can run a Macro to accomplish this, but ONLY if the rectangle is of the same dimensions as set up in the Macro.

 

What I am looking for is a LSP or something else that can take a rectangle of any dimension, "array" it into 64 rectangles, all having same dimensions, and said 64 rectangles making up the original, larger rectangle. The end product will resemble a grid of sorts, but I need each interior rectangle to be a closed polyline, rather than just splitting the large rectangle with gridlines.

 

Can anyone help? I can do this manually using the array command for each one, but there are several hundred that need broken up, and no time to do it in.

 

Thanks!

-Owen
Windows 7 x 64 bit

Civil 3D 2017
______________________________________________________________
Usually, I find that the problem is between the keyboard and the chair.
30 REPLIES 30
Message 2 of 31
Joe-Bouza
in reply to: owenmull

turn the rectangle into a parcel and set the parcel settings to the size you want

Thank you

Joseph D. Bouza, P.E. (one of 'THOSE' People)

HP Z210 Workstation
Intel Xeon CPU E31240 @ 3.30 Hz
12 GB Ram


Note: Its all Resistentialism, so keep calm and carry on

64 Bit Win10 OS
Message 3 of 31
owenmull
in reply to: Joe-Bouza


@Joe-Bouza wrote:

turn the rectangle into a parcel and set the parcel settings to the size you want


I know I can use Parcels, but I do not want to use them because I have about 500 of these to do and dont want the headache of numbering them and such. Just need them to be polys, nothing more.
-Owen
Windows 7 x 64 bit

Civil 3D 2017
______________________________________________________________
Usually, I find that the problem is between the keyboard and the chair.
Message 4 of 31
troma
in reply to: owenmull

The place for Lisp questions is:
http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/bd-p/130

Mark Green

Working on Civil 3D in Canada

Message 5 of 31
mathewkol
in reply to: owenmull

Don't worry about the numbering.  just convert them to Parcels, subdivide and then explode.  It's just so fast.

Matt Kolberg
SolidCAD Professional Services
http://www.solidcad.ca /
Message 6 of 31
owenmull
in reply to: mathewkol


@mathewkol wrote:

Don't worry about the numbering.  just convert them to Parcels, subdivide and then explode.  It's just so fast.


Again, I dont want to use parcels as I would have to manually subdivide each one. I may as well just draw them at that point.

 

Ill keep looking, thanks for the ideas, guys.

-Owen
Windows 7 x 64 bit

Civil 3D 2017
______________________________________________________________
Usually, I find that the problem is between the keyboard and the chair.
Message 7 of 31
Joe-Bouza
in reply to: owenmull

If I may as; if you had a lisp would you not have to pick something, no?

I just tested and it didn't seen too painfull. 500 plus though could be anoying, but the tool is in the box if you cant find another

Thank you

Joseph D. Bouza, P.E. (one of 'THOSE' People)

HP Z210 Workstation
Intel Xeon CPU E31240 @ 3.30 Hz
12 GB Ram


Note: Its all Resistentialism, so keep calm and carry on

64 Bit Win10 OS
Message 8 of 31
owenmull
in reply to: Joe-Bouza


@Joe-Bouza wrote:
If I may as; if you had a lisp would you not have to pick something, no?

I just tested and it didn't seen too painfull. 500 plus though could be anoying, but the tool is in the box if you cant find another


What I'm searching for is a LSP to do this. Yes, you would have to still pick the rectangle, but that is just a matter of clicking on each object once, as opposed to having to divide the rectangle, draw the interior rectangle, then array it, then explode it.

 

That's what I'm looking for.

-Owen
Windows 7 x 64 bit

Civil 3D 2017
______________________________________________________________
Usually, I find that the problem is between the keyboard and the chair.
Message 9 of 31
TerryDotson
in reply to: owenmull

I believe the Polyline Divide tool in MapWorks Base will do what you're looking for.  It was produced to chop up PLSS sections into smaller parts and produces lines or sub-polygons.  Works on a selection set of source polylines so you would only need to select once.  The rectangle coordinates do not need to be ortho.

 

Dialog Example: http://www.dotsoft.com/images/mwPlnSubDiv.png

 

Try the 30-day full working evaluation to find out for yourself or email me one of your typical rectangles to dotson [at] dotsoft [dot] com.

Message 10 of 31
mw_in_okc
in reply to: owenmull

I did some research and may have come up with a viable solution for you that meets your requirements. It involves running a Python script, then copying its results to Notepad, then finally saving and running the file as a CAD script. Python is a free, open-source language typically used for automation in the GIS world, but it can be quite versatile if you think outside the box.

 

To use this custom tool, you enter:

 

- the overall rectangle width

- the overall rectangle height

- number of columns

- number of rows

 

The python script calculates the dimensions for each grid and creates coordinate lists that look like the following:

 

PLINE
0.0,0.0
80.0,0.0
80.0,80.0
0.0,80.0
C
PLINE
80.0,0.0
160.0,0.0
160.0,80.0
80.0,80.0
C
PLINE
160.0,0.0
240.0,0.0
240.0,80.0
160.0,80.0
C
PLINE
240.0,0.0
320.0,0.0
320.0,80.0
240.0,80.0
C

 

...which will result in a set of closed polylines that fill the overall area.

 

Please let me know if this works. I read that you have hundreds of these to process (which is very tedious), and just wanted to help. 🙂  Change the extension back to .py

 

-Mike

Civil 3D 2013

ArcGIS 10.1

Message 11 of 31
antoniovinci
in reply to: mw_in_okc

That sounds exciting, Mike, but... when I paste your code in Qgis Python console, I get a bunch of errors - tried with 1.8 and 1.9 releases.
However, if I try with an italian online Python service, it works brilliant.
Unfortunately the OP is lookin' for something else: he just has hundreds of rectangles already drawn...

Message 12 of 31
doni49
in reply to: owenmull

The attached lsp file will do what you've requested. 

 

  1. it does NO error checking.  It will prompt you to make a selection.  It will only allow you to select lwpolylines (not 3d polylines).
  2. it will be up to you to make sure that you only choose rectangles.  This will work as long as you ONLY choose rectangles.
  3.  if you want to keep the existing rectangles go to the bottom of the lsp file and remove the line that deletes them.

Rename the file with an LSP extension -- the web site wouldn't allow me to upload it until I saved it as txt.



Don Ireland
Engineering Design Technician




If a reply solves your issue, please remember to click on "Accept as Solution". This will help other users looking to solve a similar issue. Thank you.


Please do not send a PM asking for assistance. That's what the forums are for. This allows everyone to benefit from the question asked and the answers given.

Message 13 of 31
Joe-Bouza
in reply to: doni49

Wont run fo me
Thank you

Joseph D. Bouza, P.E. (one of 'THOSE' People)

HP Z210 Workstation
Intel Xeon CPU E31240 @ 3.30 Hz
12 GB Ram


Note: Its all Resistentialism, so keep calm and carry on

64 Bit Win10 OS
Message 14 of 31
antoniovinci
in reply to: doni49


doni49 wrote:

The attached lsp file will do what you've requested.


Are you kiddin' us, Sir..?
I only got "error: malformed list on input" : please check your code before uploading to this lordly forum, thx.

Message 15 of 31
doni49
in reply to: antoniovinci


@antoniovinci wrote:

@doni49 wrote:

The attached lsp file will do what you've requested.


Are you kiddin' us, Sir..?
I only got "error: malformed list on input" : please check your code before uploading to this lordly forum, thx.


I don't know what to say. 

 

I had copy/pasted it into acad and it worked (I had two rectangles at the start and after running it, I had 8.  But when I tried LOADING it in, it failed.

Anyway, I found the bug and fixed it.  Just to be sure, I created a new drawing, drew two rectangles and loaded the lsp file via APPLOAD.  It happily draws the rectangles.

 

And here's the dwg file that I used for testing -- it started out as two rectangles the ones you see were created by the lisp routine.



Don Ireland
Engineering Design Technician




If a reply solves your issue, please remember to click on "Accept as Solution". This will help other users looking to solve a similar issue. Thank you.


Please do not send a PM asking for assistance. That's what the forums are for. This allows everyone to benefit from the question asked and the answers given.

Message 16 of 31
Joe-Bouza
in reply to: doni49

You're getting closer Doni; the OP request the division to be 64 rectangles not 4
Thank you

Joseph D. Bouza, P.E. (one of 'THOSE' People)

HP Z210 Workstation
Intel Xeon CPU E31240 @ 3.30 Hz
12 GB Ram


Note: Its all Resistentialism, so keep calm and carry on

64 Bit Win10 OS
Message 17 of 31
doni49
in reply to: Joe-Bouza


@Joe-Bouza wrote:
You're getting closer Doni; the OP request the division to be 64 rectangles not 4


Ouch.  I truly overlooked that part.  That will take some pondering.  But I'm sure it can be done



Don Ireland
Engineering Design Technician




If a reply solves your issue, please remember to click on "Accept as Solution". This will help other users looking to solve a similar issue. Thank you.


Please do not send a PM asking for assistance. That's what the forums are for. This allows everyone to benefit from the question asked and the answers given.

Message 18 of 31
mw_in_okc
in reply to: antoniovinci

The python code as provided is version 2.7, and I have tested it several times this morning. I run the script using IDLE independent of any built-in application console. It can create an 8x8 grid or one as dense as required that fills the original rectangle. In fact, I've added it to my working library.

 

Have a great day.

 

-Mike

Message 19 of 31
doni49
in reply to: doni49

Ok.  I've updated it to put 64 separate rectangles.  It HAS been tested (using the attached dwg file).

 

 



Don Ireland
Engineering Design Technician




If a reply solves your issue, please remember to click on "Accept as Solution". This will help other users looking to solve a similar issue. Thank you.


Please do not send a PM asking for assistance. That's what the forums are for. This allows everyone to benefit from the question asked and the answers given.

Message 20 of 31
AllenJessup
in reply to: doni49

In 2012 I get a malformed lisp error.

 

Allen



Allen Jessup
Engineering Specialist / CAD Manager

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


Autodesk Design & Make Report