The PLINE command and the polyline entity

William Forty
William Forty

The PLINE command creates an entity known as the polyline, which is basically a series of connected lines or arcs. There are some interesting tips for using polylines and the PLINE command, and many system variables that govern its use. There are also a few ways that you can customise AutoCAD® to utilise the polyline to better advantage.

Normal Usage

After invoking the PLINE command the user can pick points to define the path. The ‘A’ key can be pressed to switch to arc mode whereby arcs are created instead or lines. There are several modifiers once in arc mode, such as pressing ‘D’ to reorient the start direction of the arc.

Types of Polyline

Confusingly there are three types of polyline – polylines, 3D polylines and LW polylines (light weight polylines). The difference between them is that a LW polyline truly is two dimensional – it only stores X and Y coordinates, but it must be associated with a UCS plane. When drawing a LW polyline it inherits the current UCS as the plane for that LW polyline. Points added must reside on this plane, which can sometimes cause confusion when there is also three dimensional data in the drawing.

You don’t get any points for guessing what a 3D polyline is I’m afraid… Yes, it captures the coordinates in three dimensional space rather than on a two dimensional plane. This one isn’t creatable using the PLINE command – it has a command of it’s own called 3DPOLY.

So what is the last type… the one that isn’t a LW polyline or a 3D polyline… the one simply called a “polyline”? It is the type of polyline that was originally available before AutoCAD® R14. It too captures all the three dimensional coordinates for every point, so in this sense it is the same as the 3D polyline, but this type only allows 2D geometry. You can only draw shapes that would be possible to draw on a two dimensional plane. So in terms of what you can do with it, its the same as the LW polyline. It does the same job, just much less efficiently, hence why the newer version is called a light weight polyline. It is only really provided for backwards compatability and generally it is use is depreciated.

This brings me on to my next point – what type of polyline is created by the PLINE command? This is controlled by the system variable PLINETYPE. By default PLINETYPE is set to 2, which tells AutoCAD® to use LW polylines instead of polylines. Additionally, all old format polylines are automatically upgraded to LW polylines when the drawing is opened. You can change this setting to 0 or 1 to stop AutoCAD® upgrading polylines and to force AutoCAD® to produce old-format polylines from the PLINE command, but I’d strongly advise against it.

Special Usage

Polylines are versatile little things, and I’d recommend using them instead of lines in pretty much all cases. In addition to being able to have a line-thickness property much like any other entity, polylines are given the option of a width too. Most AutoCAD® users don’t realise that polylines can vary in width along the length of the line. Polylines do not have to be a uniform width. The global width option under properties is what people tend to go to when they want to change polyline width which is perhaps where the perception comes from. But all this does is override all width properties along the whole line. You can specify individual widths at any segment of the polyline by iterating through the points of the polyline in the properties window. This allows you to edit the start and end widths of the segment. This can be done on the fly when creating the polyline using the ‘width’ option during the command.

Because of their continuous nature, polylines make excellent boundaries for specifying a hatch boundary. I’m sure nearly every person that has ever used AutoCAD® has selected the ‘pick points’ option under the HATCH command, only to receive the message “a closed boundary could not be determined”. Infuriating as this can sometimes be, it is usually due to a gap or ambiguity somewhere in boundary. Get into the habit of drawing your objects using polylines and this will become less of an issue. Your boundaries for hatching will already be defined – you’ll just have to use the ‘select objects’ option instead.

Other Information

Third party software can sometimes generate polylines in the ways that we do not expect. For instance, have you ever had a polyline that you just couldn’t join other lines to? This is usually down to one of two things: the UCS of the polyline, or its elevation. Sometimes you can get polylines where the UCS is looking in a completely different direction, even though the drawing is say in plan. There is a quick fix for this however, simply explode the polyline to convert it into its constituent parts, and rejoin them into a polyline in the UCS you want. This may require also selecting all of the exploded lines and changing their Z coordinate to 0. The second common reason for polylines that won’t join is due to elevation. Make sure that the elevation of the polyline and what you’re joining it to is what you expect, and this should then allow you to join them.

Editing Polylines

The PEDIT command allows you to edit polylines. This is a useful feature, expecially when used on objects that aren’t polylines in the first place. This will convert the entity to a polyline, however there is a somewhat annoying popup asking you to confirm the action. Fortunately as with most things in AutoCAD®, this can be customised. Set the PEDITACCEPT system variable to 1 to suppress this prompt.

There is also an extension to this idea which I personally like to use. A little known trick is that under the CUI editor, users can customise the default double click action on specific entities. The default action when double clicking on a line for example, is to open the properties palette. Try changing the default action of lines and arcs to the PEDIT command instead, and you will be able to convert to polylines with a simple double click.

Some users may experience the problem of linetypes being irregular along polylines. This problem is caused by a display property of the polyline, namely the ‘linetype generation’ property. This should be set to ‘enabled’. The default property when polylines are created can be customised with the PLINEGEN.


There are many other commands that produce polylines as their ultimate output, including RECT, BOUNDARY, POLYGON, DONUT, and SKETCH.

Please do subscribe to this blog - you won’t regret it!


Comments

prakash
2012-04-28 22:15:54

I am finding your article very useful. The documentation is excellent. Thank you so much.

Prakash B Bajaj