 ; Amazing automatic plant constructor
 ; Copyright 1991, 2011 by Rocket Software Ltd.  
 ; Could probably be modified into a wiring diagram generator.
 (DEFUN C:PLANT (/ col incrp p1 pa pts pts2 len num angg pb)
  (setvar "cmdecho" 0)
  (setq col 1)
  (command "color" "2")
  (setq p1 (getpoint "\nStart point: "))
  (setq len (getdist p1 "\nSegment length: "))
  (if (null incr) (setq incr 0.8))
  (setq incrp (getreal (strcat "\nLength increment <:" (rtos incr 2 2) ">: ")))
  (if incrp (setq incr incrp))
  (setq nn (getint "\nNumber of iterations: "))
  (setq branch (getint "\nNumber of sub-branches: "))
  (command "line" p1 (setq pa (polar p1 1.57 len)) "")
  (setq pts (list (list pa 1.57)))
  (repeat nn
          (setq col (1+ col))
          (command "color" col)
          (setq num 0)
          (while (nth num pts)
                 (setq pa (car (nth num pts)))
                 (repeat branch
                         (setq angg (* (getvar "cdate") 10000000.0))
                         (setq angg (* pi (- angg (fix angg))))
                         (if (= angg 0) (setq angg 1.5))
                         (setq pb (polar pa angg len))
                         (setq pts2 (cons (list pb angg) pts2))
                         (command "line" pa pb ""))
                 (setq num (1+ num)))
          (setq pts pts2)
          (setq len (* len incr))
          (setq pts2 ()))
  (setq num 0)
  (while (setq pa (nth num pts))
         (setq angg (* (/ 180 pi) (cadr pa)))
         (setq pa (car pa))
         (command "insert" "leaf" pa "1" "" angg)
         (setq num (1+ num)))
 (princ))