Rami Mann e-mailed a request to draw a polyline between two existing polylines representing terrain contours. His project is missing some contours, and he wants to form an intermediate contour assuming a linear interpolation between the contour heights.
The AutoLISP solution is CONTOURS.LSP, which allows the user to select any two polylines (lightweight or 2D) and enter a precision number (default 100) for the number of segments in the resulting polyline. If the terrain changes height rapidly in some places and is flatter in others, then the contours will be close together in parts and may be far apart in other sections (figure 1). A bonus file I wrote, RPL.LSP, will come in handy to reverse the direction of any selected polyline.The lengths of the polylines in figure 1 are about 6,500 units and 5,300 units for the outer and inner contours, respectively. Applying CONTOURS.LSP to the parts of the contours that are somewhat parallel shows better results than those that vary wildly (figure 2). The precision (number of segments) gave good results for anything over 200 but did not improve much between 300 and 2,000. It took about 1 second for 200 points and about 5 seconds for 1,000 points to generate the curve.
Get the Code Download the CONTOURS.LSP and the RPL.LSP files from our Get the Code area and save them in AutoCAD's Support directory. Use the Appload facility by selecting Tools / Load Application. Then select the CONTOURS.LSP and RPL.LSP programs from where you stored them.
|