AutoLISP: Divide Polyline Segment

If youve ever tried the DIVIDE command on a Poly Line, You know the frustration that usually follows that adventure. Here is a great Routine that allows you to easily do this task.

Note that places “Points” as the division markers like the Divide command. So set your Point size and style with the command DDPTYPE prior to running this routine. It does not actually divide the polyline but rather marks the divisions with points. Also Note that this routine asks you to pick 2 points along the poly line, so this routine only works on straight segments of polylines. Then Specify the number of segments, not the number of points.

Here’s how:

  • DIVSIDE <enter>
  • Specify first point along poly line
  • Specify second point along poly line
  • Specify number of segments between the 2 picked points.


;divide a side of a polyline into segments

;by Thawart found at autocad forums.

(defun c:divside (/ p1 p2 v l pt)



(setq p1 (getpoint "\n Specify first point :"))

(setq p2 (getpoint p1 "\n Specify Second point :"))

(setq v (getint "\n Specify number of segments :")); changed "division points" to "segments"



(if (eq (getvar 'pdmode) 0)

(setvar 'pdmode 3)


(setq l (/ (distance p1 p2) v))

(repeat (- v 1)

(setq pt (polar p1 (angle p1 p2) l))

(entmakex (list (cons 0 "POINT") (cons 10 pt)))

(setq p1 pt)







About AutoCAD Tips

This blog serves as a knowledge base for myself (and anyone else) so that I can reference tips & tricks that I have learned and also refer others to it as well. I hope that this blog helps you learn at least one tip to make your drafting/design experience better.
This entry was posted in AutoLISP, Modifying, TIPS. Bookmark the permalink.

3 Responses to AutoLISP: Divide Polyline Segment

  1. Obaid says:

    How to divide multiple lines/poly lines at once. Is there any LISP that can do as I ahve to deal with thousands of lines

    • AutoCAD Tips says:

      Try the below LISP routine. It doesn’t actually divide or break the objects. It does place points along the objects.
      Adjust the size and shape of the points to be more easily seen by using the DDPTYPE command.

      ;; Paul Turvill
      ;; Divides multiple obects at once by placing Points along the object
      ;; TIP: Adjust the DDPTYPE to see the points better
      (defun C:MDIV (/ ss n segs)
      (setq ss (ssget ‘((0 . “LINE,POLYLINE,LWPOLYLINE,ARC,CIRCLE”)))
      n (1- (sslength ss))
      segs (getint “\Number of segments per object: “)
      (while (>= n 0)
      (command “_.divide” (ssname ss n) segs)
      (setq n (1- n))

  2. rafiq says:

    I need the lisp program for the rectangle with a slot cut

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s