;* --- Define PAGAR function
(defun bond ()
;* Calculate angle for line segment:
   (setq xang 
      (angle sp ep))
   (setq xa2
      (angle ep sp))
   (setq ya1
      (- xa2  2.2864))
   (setq ya2
      (+ (+ ya1 3.1416) 1.0472))
; calculate each line segment
   (setq l1 (* 0.25 sc))
   (setq l2 (* 0.1773 sc))
   (setq l3 (* 0.35 sc))
   (setq l4 (* 0.30 sc))
   (setq tl (+ (+ l1 l4) l1))
;* Find reference point and calculate length of line segments:
   (setq n2
      (/ (distance sp ep) tl))
   (setq nc
      (fix n2))
;* warning
   (if
      (<= nc 1)
      (prompt " Kecilkan LTSCALE anda "))
;* initialize loop counter 
   (setq case 0)
   (while
      (< case nc)
;* find drawing points
   (setq pt1
      (polar sp xang l1))
   (setq pt2
      (polar pt1 ya1 l2))
   (setq pt3
      (polar pt2 ya2 l3))
   (setq pt4
      (polar pt1 xang l4))
   (setq pt5
      (polar pt4 xang l1))
;* loop to draw pagar and updata variables
       (command "LINE"
	    sp
	    pt1
	    ""
       )
       (command "LINE"
	    pt2
	    pt3
	    ""
       )
       (command "LINE"
	    pt4
	    pt5
	    ""
       )
;* update memory variables
      (setq case
	    (+ case 1))
      (setq sp pt5)
  )
;* end of while function
; drawing the last bit
	(command "LINE"
	    pt5
	    ep
	    ""
	)
	(setq sp1 ep)
)
;* end of c: bond function
;* GETTING MORE POINTS
(defun getmore ()
      (setq ep1
	    (getpoint ep "\n To point :"))
      (setq sp sp1)      
      (setq ep ep1))
; end of getmor function
; define pagar function
(defun c:pagar ()
;* save screen values
      (setq oldblp
	    (getvar "BLIPMODE"))
      (setq oldech
	    (getvar "CMDECHO"))
; turn off command echo
      (setvar "CMDECHO" 0)
; * get ltscale from the system
   (setq sc
      (getvar "LTSCALE"))
;* initial instruction
    (prompt "Adjust your spacing with LTSCALE")
;*-- get starting point and other points:
     (setq sp
	(getpoint "\nFirst Point :"))
     (setq ep
	(getpoint sp "\nTo Point :"))
      (setq ep1 ep)
      (while
	    (not (equal ep1 nil))
      (bond)
      (getmore))
; restore screen values
      (setvar "BLIPMODE" oldblp)
      (setvar "CMDECHO" oldech)
)
;end of pagar function
(defun c:f () (command "fillet"))
(defun c:f0 () (setvar "filletrad" 0) (command "fillet"))
(defun c:fr () (setq rad  (getdist "\nEnter Fillet Rad:"))
	      (setvar "filletrad" rad)(command "fillet"))
(defun c:m () (command "move"))
(defun C:oe () (setvar "osmode" 1))
(Defun c:nR () (command "osnap" "near"))
(defun c:od () (setvar "osmode" 8))
(defun C:oi () (setvar "osmode" 32))
(defun C:oc () (setvar "osmode" 4))
(defun C:om () (setvar "osmode" 2))
(defun C:nd () (setvar "osmode" 8))
(defun c:vp () (command "vpoint"))
(defun c:re () (command "redraw"))
(Defun C:CtO ()
(princ "\nPick the object you want to change layer : ")
(Setq A (ssget)) 
    (If A (Progn (Setq B (Getstring "\nEnter name of new layer : "))
    (If (= nil (Tblsearch "Layer" B))
    (Progn (Princ (Strcat "\nLayer " B " does not exist !  \n"))
    (Initget "Y N")
    (Setq C (Getkword "\nWould you like to create it ? "))
    (If (= "Y" C)
    (command "Layer" "N" B "" "Change" A ""  "P" "LA" B "")))
    (command "Change" A "" "P" "LA" B ""))))
    (princ)
)
