AutoCAD Civil 3D General Discussion

AutoCAD Civil 3D General Discussion

Reply
*Expert Elite*
antoniovinci
Posts: 1,701
Registered: ‎06-03-2011
Message 11 of 31 (1,025 Views)

Re: Subdivide a rectangle

10-11-2013 05:47 AM 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...

*Expert Elite*
doni49
Posts: 1,803
Registered: ‎12-22-2012
Message 12 of 31 (1,013 Views)

Re: Subdivide a rectangle

10-11-2013 07:33 AM 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



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.






Forum links:
AutoCAD 2013/2014/2015
AutoCAD 2010/2011/2012

AutoLISP, VB and other AutoCAD customization


Civil 3D General
Civil 3d Customization


Other Helpful links:
My File is too large to post!
*Expert Elite*
Joe-Bouza
Posts: 5,044
Registered: ‎12-15-2008
Message 13 of 31 (1,003 Views)

Re: Subdivide a rectangle

10-11-2013 07:59 AM in reply to: doni49
Wont run fo me
Thank you

Joseph D. Bouza, P.E. (one of 'THOSE' People) Civil 3D 2012 & 2013
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 Win7 OS
*Expert Elite*
antoniovinci
Posts: 1,701
Registered: ‎06-03-2011
Message 14 of 31 (998 Views)

Re: Subdivide a rectangle

10-11-2013 08:06 AM 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.

*Expert Elite*
doni49
Posts: 1,803
Registered: ‎12-22-2012
Message 15 of 31 (989 Views)

Re: Subdivide a rectangle

10-11-2013 08:16 AM 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



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.






Forum links:
AutoCAD 2013/2014/2015
AutoCAD 2010/2011/2012

AutoLISP, VB and other AutoCAD customization


Civil 3D General
Civil 3d Customization


Other Helpful links:
My File is too large to post!
*Expert Elite*
Joe-Bouza
Posts: 5,044
Registered: ‎12-15-2008
Message 16 of 31 (984 Views)

Re: Subdivide a rectangle

10-11-2013 08:20 AM 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) Civil 3D 2012 & 2013
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 Win7 OS
*Expert Elite*
doni49
Posts: 1,803
Registered: ‎12-22-2012
Message 17 of 31 (977 Views)

Re: Subdivide a rectangle

10-11-2013 08:28 AM 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



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.






Forum links:
AutoCAD 2013/2014/2015
AutoCAD 2010/2011/2012

AutoLISP, VB and other AutoCAD customization


Civil 3D General
Civil 3d Customization


Other Helpful links:
My File is too large to post!
Member
mw_in_okc
Posts: 3
Registered: ‎10-10-2013
Message 18 of 31 (970 Views)

Re: Subdivide a rectangle

10-11-2013 08:43 AM 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

*Expert Elite*
doni49
Posts: 1,803
Registered: ‎12-22-2012
Message 19 of 31 (956 Views)

Re: Subdivide a rectangle

10-11-2013 10:41 AM 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



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.






Forum links:
AutoCAD 2013/2014/2015
AutoCAD 2010/2011/2012

AutoLISP, VB and other AutoCAD customization


Civil 3D General
Civil 3d Customization


Other Helpful links:
My File is too large to post!
*Expert Elite*
AllenJessup
Posts: 6,004
Registered: ‎05-21-2003
Message 20 of 31 (950 Views)

Re: Subdivide a rectangle

10-11-2013 10:50 AM in reply to: doni49

In 2012 I get a malformed lisp error.

 

Allen

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.