Playing with Polylines, Part 314 Jan, 2005 By: Bill Fane Cadalyst
Winding up our series, we look at how to modify polylines using AutoCAD's PolylineEdit command
This is the third article in the Great Polyline Trilogy. The first article in the series covered the basic construction and characteristics of a polyline. The second showed how you can edit a polyline using the standard AutoCAD editing functions like Offset, Fillet and the Properties dialog box. (Click here for archives.)
As exhaustive -- and exhausting -- as that second article was, it by no means exhausted all the editing possibilities, so in this third installment, I'll pick up where I left off.
Anything You Can't Do...
Before the Properties dialog box came along, all polyline editing was done using the Pedit (PolylineEDIT) command. Much of its functionality has been usurped by Properties, but there are still a number of polyline editing functions that can only be performed using Pedit.
You can invoke the Pedit command by entering it at the Command prompt, or by selecting Modify / Object / Polyline, or by selecting its button (figure 1) on the Modify II toolbar. When you do, it asks you to select a polyline. If you then select a regular line or arc, AutoCAD tells you, "Object selected is not a polyline."
Figure 1. The Pedit button.
Now comes the first surprise. Usually any command that returns an error message will drop back to the Command prompt -- but not Pedit. Instead, it asks, "Do you want to turn it into one?" If you respond with a "Y," the Pedit command behaves like an "unexplode" and turns the line or arc into a one-segment 2D polyline.
Once you have a polyline selected, either by direct selection or by conversion, AutoCAD brings up a nine-choice submenu. Many of these choices have already been covered under the Properties dialog box discussion in my last article, so I will bypass them here. There are a few that are unique to Pedit, however.
Let's begin with the panic button. Selecting X (exit) returns you to AutoCAD's Command prompt and cancels the edit. It is the default if you do not enter another choice. Pressing Esc has the same effect.
Shall We Join The Objects?
The Join option is used to patch existing objects onto the selected polyline. You can use this to turn two (or more) polylines into a single, longer one, and you can turn lines or arcs into polyline segments and add them onto the selected one.
Having selected Join, you will be prompted, "Select objects:" Any of AutoCAD's object selection mechanisms, such as Window, Crossing, Previous, and so on, will work.
There is no harm in including the original polyline in your selection set, nor in picking "illegal" objects such as text or dimensions. Objects need not be picked in any particular order.
When you press Enter to terminate the selection process, AutoCAD begins sorting down through the selected objects to find one that meets both of the following conditions:
- It is a line, polyline or arc and
- one end of the object must exactly match one end of the polyline.
Note the second requirement in particular. Unlike dancing and hand grenades, "close enough" is not good enough. Objects that cross, tee, or don't touch, even by the most miniscule amount, will not be added, so the polyline will stop growing even though other objects in the set do meet properly.
Okay, I lied. There is a way to make noncoincident objects join onto the polyline. I'll come back to this topic a little later.
Go Forth And Multiple...
When you launch the Pedit command, observe its first prompt. It invites you to select a polyline or to invoke the Multiple option. If you enter an M to start Multiple mode, you will be asked to select several objects. If you do so, then press Enter, you will be offered a shorter list of edit options such as width and line type generation that will be applied globally to all selected polylines. This is no big deal, because you can accomplish the same thing by selecting multiple polylines for the Properties dialog box.
The really cunning bit occurs when you want to join several polylines or lines or arcs into a single polyline. When you invoke the Join option after a Multiple selection, you will be asked for a "fuzz" distance. You can enter a value or pick two points to show the distance to AutoCAD.
The Join operation will then proceed as before, but now the ends do not need to exactly touch before an object is joined to the line. If the gap or overlap distance is within the fuzz factor distance, the objects will be extended or trimmed as necessary to effect the join.
You can also specify a Jointype option for the fuzzy join. The Extend option will extend or trim as necessary to effect the join, whereas Add will add a new polyline segment between the ends of the objects, without changing the location of the ends. The Both mode will extend or trim if possible, or add a segment if not.
I was aware of "fuzz factor" for a long time but could never figure out how to apply it before I discovered that it only works in Multiple mode.
Now I'll Throw A Real Curve At You
The Fit and Spline options are used to turn a polyline into a smooth, flowing curved line. Fit generates a curved line that passes exactly through every vertex, including the two ends. It does this by turning each segment (whether straight or arc) into two arcs, and inserts a new vertex where the two arcs touch. All the arc segments are tangent to their neighbors, right down the length of the line.
This can produce some bizarre results when using a polyline with few segments, especially when the individual segment lengths vary considerably. Things tend to get bumpy. As a result of these shortcomings, later releases added the Spline option.
AutoCAD can also fit an approximation of a Bezier spline or b-spline curve to a polyline. B-splines originally grew out of the construction of wooden ships. Imagine if you will a long, thin, supple wooden plank. Support it at each end, then hang weights on it at various points along its length. Some of the weights can be negative -- that is, use a pulley and string so the downward force of the weight actually pulls the plank upward.
A Spline-curved polyline behaves the same way. The generated curve will start and end exactly at the ends of the original polyline, but it only gets pulled toward the intermediate vertices. The closer and the more numerous the vertices, the stronger the pull. The curve that is generated is actually a new polyline consisting of a large number of small arc segments, and the underlying defining "frame" polyline becomes invisible.
Once again, the Spline option has shortcomings, so AutoCAD added a true mathematical spline curve as a separate object type, created by its own command. In practice, curve-fitted polylines are rarely used now.
Hey, doesn't that usually go at the start of a document? I know, but I forgot. Anyway, the bottom line (pun intended) is that neither regular lines and arcs nor polylines are inherently superior to the other object type. Each has its preferred uses, and each is best in its proper application. I hope these three articles about creating and editing polylines will give you a better understanding of when to use which type of polyline editing.
And Now For Something Completely Different
We usually think of a desert as a hot place, but actually to qualify as a desert a region must simply be "without significant water." The temperature in Las Vegas at the time of Autodesk University in early December can often dip below freezing, necessitating warm clothing. Could that be one reason the event will move to Orlando, Florida, next year?