Q:
How can I restore hatch boundaries if they have been lost due to some reason?
A:
AutoCAD doesn't have a command to do that. Fortunately, we can create one with ObjectARX API.
The most complex in the task is to handle splines properly as there are various of splines in AutoCAD, fixed point spline, rational spline, not rational spline, etc. The code works quite well for lines, arcs, circles, ellipses and splines. Note that error checking is minimal for brevity. Please bear in mind that it is not possible to restore the original boundary entities exactly, because the underlying geometry objects prefixed with AcGe in AcDbHatch do not match AutoCAD database entities prefixed with AcDb one by one. For example, if there is a closed loop composed of some lines in the original hatch boundary entities, it will become a polyline in the final result restored back.
In the example, the boundaries restored are in red and put on the current layer. You can use selection filter to get them for further modification. There is a Test.dwg drawing included, for test purposes.
How To Use The Example:
1. Build the attached project with VC2010 or copy the code for “BzhRestoreHatchBoundary” to your own project
2. Startup AutoCAD
3. Load the ARX file
4. Open the drawing that you want to restore hatch boundaries
5. Issue the command with short name RHB or long name RESTOREHATCHBOUNDARY
6. Choose hatch entities that you would like to restore boundaries. You could choose multiple hatches one time