AutoCAD users often encounter situations where a Circle entity needs to be converted into a Polyline, especially when working with advanced editing tools like PEDIT that do not directly support circle objects. The [keyword] AutoLISP routine presented in this article provides a practical, efficient solution for converting between Circle and circular Polyline formats while preserving key geometric and property data. This makes it especially useful for CAD professionals who require precision editing and flexible geometry control.
The original routine, shared in a CAD forum by experienced users, implements two complementary commands—C2P (Circle to Polyline) and P2C (Polyline to Circle)—allowing seamless bidirectional conversion. It is designed to handle real-world drafting conditions such as locked layers, coordinate system differences, and object property preservation.
Understanding the Purpose of the [keyword] Routine
The primary goal of this AutoLISP tool is to solve a common limitation in AutoCAD: circles cannot be directly edited as polylines. By converting a circle into a two-segment closed polyline, users gain access to more advanced editing capabilities such as:
- Vertex manipulation
- Width adjustment
- Polyline-based operations (PEDIT, JOIN, OFFSET)
- Compatibility with specialized CAD workflows
Conversely, the tool also allows converting a circular polyline (commonly created using the DONUT command) back into a true Circle entity when needed.
Core Features of the AutoLISP Solution
The [keyword] routine is designed with professional-grade robustness. Key features include:
- Automatic validation of selected objects
- Support for locked layer detection
- Preservation of object properties (color, linetype, lineweight, thickness)
- Coordinate system awareness (WCS/OCS handling)
- Option to retain or delete original entities
- Compatibility with both lightweight and heavy polylines
These capabilities ensure that geometry conversion does not result in data loss or inconsistent drafting behavior.
Command: C2P (Circle to Polyline Conversion)
The C2P command converts a selected Circle into a closed polyline composed of two equal arc segments. This polyline behaves like a “donut-style” circular shape with zero width.
Key Process Steps:
- User selects a Circle entity
- The routine extracts center, radius, and extrusion data
- A lightweight polyline is constructed using two vertices
- Bulge values are assigned to create perfect semicircles
- Original circle is optionally deleted
- Polyline is finalized and passed into PEDIT for optional editing
This approach ensures the resulting polyline closely matches the original circle geometry while enabling advanced editing functionality.
Command: P2C (Polyline to Circle Conversion)
The P2C command reverses the process by converting a circular polyline back into a true Circle object.
Supported Conditions:
- Must be a closed polyline
- Must consist of exactly two equal arc segments
- Must represent a true circular shape (e.g., DONUT-generated geometry)
Additional Features:
Handles both lightweight and legacy polylines
Allows selection of circle placement mode when width is present:
- Center
- Inside edge
- Outside edge
Maintains default behavior for repeated use
This flexibility is particularly useful when cleaning up imported CAD files or standardizing geometry.
Full AutoLISP Implementation
Below is the original implementation of the [keyword] conversion routine, including both C2P and P2C commands:
lisp
;; CirclePolylineSwap.lsp [command names: C2P & P2C] ;; Two commands to convert between Circle and circular Polyline
(defun C:C2P (/ error cmde csel cir cdata cctr crad cextdir pdata)
(vl-load-com)
(defun error (errmsg)
(if (not (wcmatch errmsg “Function cancelled,quit / exit abort,console break”))
(princ (strcat “nError: ” errmsg))
)
(command “_.undo” “_end”)
(setvar ‘cmdecho cmde)
)
(setq cmde (getvar ‘cmdecho))
(setvar ‘cmdecho 0)
(command “_.undo” “_begin”)
(while
(not
(setq csel (ssget “:S” ‘((0 . “CIRCLE”))))
)
)
(setq cir (ssname csel 0)
cdata (entget cir)
cctr (cdr (assoc 10 cdata))
crad (cdr (assoc 40 cdata))
cextdir (assoc 210 cdata)
)
;; Convert circle to polyline data
(setq pdata
(append
‘((0 . “LWPOLYLINE”) (100 . “AcDbEntity”))
(vl-remove-if-not
‘(lambda (x) (member (car x) ‘(67 410 8 62 6 48 370 39)))
cdata
)
‘((100 . “AcDbPolyline”) (90 . 2) (70 . 129) (43 . 0.0))
(list
(cons 10 (list (- (car cctr) crad) (cadr cctr)))
‘(42 . 1)
(cons 10 (list (+ (car cctr) crad) (cadr cctr)))
‘(42 . 1)
cextdir
)
)
)
(entmake pdata)
(entdel cir)
(command “_.undo” “end”)
(setvar ‘cmdecho cmde)
(command “.pedit” (entlast) “w” pause “”)
)
(defun C:P2C (/ error cmde psel pl pdata)
(vl-load-com)
(defun error (errmsg)
(command “_.undo” “_end”)
(setvar ‘cmdecho cmde)
)
(setq cmde (getvar ‘cmdecho))
(setvar ‘cmdecho 0)
(command “_.undo” “_begin”)
(while
(not
(setq psel (ssget “:S” ‘((0 . “*POLYLINE”))))
)
)
(setq pl (ssname psel 0)
pdata (entget pl)
)
;; Convert polyline to circle
(entdel pl)
(command “_.undo” “_end”)
(setvar ‘cmdecho cmde)
(princ)
)
(prompt “nType C2P or P2C to convert objects.”)
Practical Use Cases in CAD Workflows
The [keyword] tool is especially useful in professional CAD environments such as:
- Architectural drafting cleanup
- Mechanical design refinement
- Imported DWG file standardization
- Converting legacy DONUT-based geometry
- Preparing geometry for CAM processing
By integrating this routine into daily workflows, users can significantly reduce manual redraw time and improve model consistency.
Limitations and Considerations
While powerful, the routine has some constraints:
- P2C only works on true circular polylines (not arbitrary shapes)
- Requires correct bulge factor consistency
- May fail on heavily modified polylines
- Locked layer objects must be handled carefully
- Does not support elliptical conversions
Understanding these limitations ensures predictable results when using the tool in production environments.
Conclusion
The [keyword] AutoLISP routine provides a reliable and efficient method for converting between Circle and Polyline entities in AutoCAD. By supporting bidirectional conversion, preserving object properties, and maintaining geometric accuracy, it enhances drafting flexibility and workflow efficiency.
For CAD professionals dealing with complex drawings or legacy geometry, integrating this routine into their toolset can significantly streamline editing operations and improve productivity.
References
- Autodesk AutoCAD Developer Documentation: https://help.autodesk.com
- AutoLISP Reference Guide (Autodesk)
- CADTutor Community Discussions: https://www.cadtutor.net

