Display full version of the post: AutoCAD Programming

darkness.throne
05.08.2013, 17:14
I'm new to AutoCAD programming and I have some questions about it. I want to create an app or pluging (or somethings else - I'm not sure) in AutoCAD that can get a plan of a buildings then tell me where in the plan I can put bed rooms (with specific size) to get more rooms in the plan-- the program should recognize free spaces automatically. I'm not sure if it's possible or not, but I'm glad if anyone can guide me for answering that or tell what to do or where to start. I heard Visual Lisp can do that, I it correct?With Thanks.

Kent Cooper
05.08.2013, 21:09
Wow....  I expect that would be very challenging.  It's easy to get a Lisp routine to find where things are, but to find all the places where things are not is another matter altogether.
 
One possible approach would be to have it look at a rectangular area (i.e. a Crossing-type selection) the size of the room you want to fit in, starting at a corner of the drawing or of some designated more-limited area, and move along by some increment (a foot? an inch? some fraction of the room size?) looking at the same size area again, and when it gets to the opposite edge, go back and do another row or column of checks, stepped up or over by the same increment from the last row or column, until it covers the whole drawing/area.  It could limit the entity types it looks for to only those with which you might draw building elements, and ignore other things like Text that might be floating out in open areas but that wouldn't be considered to make those areas unavailable.  Anywhere it didn't find anything of the applicable kind(s) within such an area, it could either place a Block, or put the location of the middle of the area into a list, or something.  With a small stepping increment, that could be a lot of indicators, or a very long list, though ways could probably be found to weed out intermediate ones and leave only those defining overall areas, somehow.
 
That much may be tedious for it to plow through, but perhaps not too difficult.  Complications arise with other considerations.  If you want, for example, 10' x 12' rooms, you would presumably need to do the same kind of search twice, once with the more horizontal orientation and once with the more vertical, or you could well miss some possibilities.  If the perimeters of potentially available areas are not always drawn orthogonally, or if the rooms could be oriented diagonally if necessary to fit them in, it would need more sophisticated methods, or you'd just miss a lot of possible areas.  If the area matters but not the proportions (within limits), even when limited to rectangular areas, it would need to run a bunch of searches at different proportions.  If the rooms could be non-rectangular, that would add further challenges to finding some of the available areas, e.g. if an L-shaped room is allowable, you would want it to look for a Fence-type selection, and would need to run it four times with a symmetrical L, or eight times with an asymmetrical one, to cover all the possibilities just for orthogonal orientations of a defined-shape L.  If the proportions of the legs of an L could be varied as long as the total area is right, I'm not sure how it could account for all the possibilities.  If you need it to account for corridors to access the rooms....
 
Some definition or limitation of the range of parameters would at least be a place to start.