					;§©y lµ file tËp hîp c¸c lÖnh söa dimention

(prompt "\n************************************************************\n")
(prompt "\nStart load DIMENTION.LSP ...\n")

(DEFUN DXF (code elist)
  (cdr (assoc code elist))
) ;_ end of DEFUN

(DEFUN u_ssget (/ ssl nsset temp ed)
  (setq sset (ssget))
  (setq	ssl   (sslength sset)
	nsset (ssadd)
  ) ;_ end of setq
  (print ssl)
  (princ "entities found. ")
  (princ "\nVerifying the selected entities -- please wait. ")
  (while (> ssl 0)
    (progn
      (setq temp (ssname sset (setq ssl (1- ssl))))
      (setq ed (entget temp))
      (if (= (DXF 0 ed) "DIMENSION")
	(ssadd temp nsset)
      ) ;_ end of if
    ) ;_ end of progn
  ) ;_ end of while
  (setq	ssl  (sslength nsset)
	sset nsset
  ) ;_ end of setq
  (print ssl)
  (princ "DIMENSION entities found. ")
  (princ)
) ;_ end of DEFUN
					;****************************************************************************
(DEFUN C:XX ()
  (COMMAND "UCS" "W")
  (SETQ CMD (GETVAR "CMDECHO"))
  (SETVAR "CMDECHO" 0)
  (SETVAR "CMDECHO" 1)
  (PROMPT
    "\nSelect vertical dimension(s) extensions to be aligned"
  ) ;_ end of PROMPT
  (SETQ SET (SSGET))
  (PROMPT "\nSelect new extension position")
  (SETQ P1 (GETPOINT))
  (SETQ X3 (CAR P1))
  (SETQ QUANT (SSLENGTH SET))
  (SETQ INDEX 0)
  (WHILE (< INDEX QUANT)
    (IF	(AND (=	"DIMENSION"
		(CDR (ASSOC 0 (SETQ A (ENTGET (SSNAME SET INDEX)))))
	     ) ;_ end of =
	) ;_ end of AND
      (PROGN
	(SETQ L13 (ASSOC 13 A))
	(SETQ M13 (CDR L13))
	(SETQ L14 (ASSOC 14 A))
	(SETQ M14 (CDR L14))
	(SETQ P13 (LIST 13 X3 (CADR M13) (CADDR M13)))
	(SETQ P14 (LIST 14 X3 (CADR M14) (CADDR M14)))
	(SETQ A (SUBST P13 L13 A))
	(SETQ A (SUBST P14 L14 A))
	(ENTMOD A)
      ) ;_ end of PROGN
    ) ;_ end of IF
    (SETQ INDEX (+ INDEX 1))
  ) ;_ end of WHILE
  (SETVAR "CMDECHO" 0)
  (SETVAR "CMDECHO" CMD)
  (PRINC)
) ;_ end of DEFUN
(prompt "\n- XX: To align vertical dimentions.\n")
					;***************************************************************************
(DEFUN C:YY ()
  (SETQ CMD (GETVAR "CMDECHO"))
  (COMMAND "UCS" "W")
  (SETVAR "CMDECHO" 0)
  (SETVAR "CMDECHO" 1)
  (PROMPT "\nSelect dimension(s) to be aligned")
  (SETQ SET (SSGET))
  (PROMPT "\nSelect new dimension position")
  (SETQ P1 (GETPOINT))
  (SETQ Y3 (CADR P1))
  (SETQ QUANT (SSLENGTH SET))
  (SETQ INDEX 0)
  (WHILE (< INDEX QUANT)
    (IF	(AND (=	"DIMENSION"
		(CDR (ASSOC 0 (SETQ A (ENTGET (SSNAME SET INDEX)))))
	     ) ;_ end of =
	) ;_ end of AND
      (PROGN
	(SETQ L13 (ASSOC 13 A))
	(SETQ M13 (CDR L13))
	(SETQ L14 (ASSOC 14 A))
	(SETQ M14 (CDR L14))
	(SETQ P13 (LIST 13 (CAR M13) Y3 (CADDR M13)))
	(SETQ T13 (CDR P13))
	(SETQ P14 (LIST 14 (CAR M14) Y3 (CADDR M14)))
	(SETQ A (SUBST P13 L13 A))
	(SETQ A (SUBST P14 L14 A))
	(ENTMOD A)
      ) ;_ end of PROGN
    ) ;_ end of IF
    (SETQ INDEX (+ INDEX 1))
  ) ;_ end of WHILE
  (SETVAR "CMDECHO" 0)
  (SETVAR "CMDECHO" CMD)
) ;_ end of DEFUN
(prompt "\n- YY: To align horizontal dimentions.\n")

;****************************************************************************
(DEFUN C:XD ()
  (SETQ CMD (GETVAR "CMDECHO"))
  (COMMAND "UCS" "W")
  (SETVAR "CMDECHO" 0)
  (SETVAR "CMDECHO" 1)
  (PROMPT "\nSelect dimension(s) to be aligned")
  (SETQ SET (SSGET))
  (PROMPT "\nSelect new dimension position")
  (SETQ P1 (GETPOINT))
  (SETQ X3 (CAR P1))
  (SETQ QUANT (SSLENGTH SET))
  (SETQ INDEX 0)
  (WHILE (< INDEX QUANT)
    (IF	(AND (=	"DIMENSION"
		(CDR (ASSOC 0 (SETQ A (ENTGET (SSNAME SET INDEX)))))
	     ) ;_ end of =
	) ;_ end of AND
      (PROGN
	(SETQ L10 (ASSOC 10 A))
	(SETQ M10 (CDR L10))
	(SETQ L11 (ASSOC 11 A))
	(SETQ M11 (CDR L11))
	(SETQ P10 (LIST 10 X3 (CADR M10) (CADDR M10)))
	(SETQ A (SUBST P10 L10 A))
	(ENTMOD A)
      ) ;_ end of PROGN
    ) ;_ end of IF
    (SETQ INDEX (+ INDEX 1))
  ) ;_ end of WHILE
  (SETVAR "CMDECHO" 0)
  (SETVAR "CMDECHO" CMD)
) ;_ end of DEFUN
(prompt "\n- XD: To modify vertical dimentions insert point.\n")
					;****************************************************************************
(DEFUN C:YD ()
  (COMMAND "UCS" "W")
  (SETQ CMD (GETVAR "CMDECHO"))
  (SETVAR "CMDECHO" 0)
  (SETVAR "CMDECHO" 1)
  (PROMPT "\nSelect dimension(s) to be aligned")
  (SETQ SET (SSGET))
  (PROMPT "\nSelect new dimension position")
  (SETQ P1 (GETPOINT))
  (SETQ Y3 (CADR P1))
  (SETQ QUANT (SSLENGTH SET))
  (SETQ INDEX 0)
  (WHILE (< INDEX QUANT)
    (IF	(AND (=	"DIMENSION"
		(CDR (ASSOC 0 (SETQ A (ENTGET (SSNAME SET INDEX)))))
	     ) ;_ end of =
	) ;_ end of AND
      (PROGN
	(SETQ L10 (ASSOC 10 A))
	(SETQ M10 (CDR L10))
	(SETQ P10 (LIST 10 (CAR M10) Y3 (CADDR M10)))
	(SETQ A (SUBST P10 L10 A))
	(ENTMOD A)
      ) ;_ end of PROGN
    ) ;_ end of IF
    (SETQ INDEX (+ INDEX 1))
  ) ;_ end of WHILE
  (SETVAR "CMDECHO" 0)
  (SETVAR "CMDECHO" CMD)
) ;_ end of DEFUN
(prompt "\n- YD: To modify horizontal dimentions insert point.\n")
					;****************************************************************************
(DEFUN C:DUP (/ sset ssl temp ed old new)
  (u_ssget)
  (setq ssl (sslength sset))
  (while (> ssl 0)
    (progn
      (setq temp (ssname sset (setq ssl (1- ssl))))

      (setq ed (entget temp))
      (setq old (cons 1 (DXF 1 ed)))
      (setq new (cons 1 ""))
      (setq ed (subst new old ed))

      (setq old (cons 70 (DXF 70 ed)))
      (setq new (cons 70 0))
      (setq ed (subst new old ed))

      (entmod ed)
    ) ;_ end of progn
  ) ;_ end of while
  (princ)
) ;_ end of DEFUN
(prompt "\n- DUP: To change dimentions to its original properties.\n")
					;****************************************************************************
(DEFUN C:DCL (/ sset ssl temp ed old new)
  (u_ssget)
  (setq ssl (sslength sset))
  (while (> ssl 0)
    (progn
      (setq temp (ssname sset (setq ssl (1- ssl))))

      (setq ed (entget temp))
      (setq old (cons 8 (DXF 8 ed)))
      (setq new (cons 8 "kich_thuoc"))
      (setq ed (subst new old ed))

      (entmod ed)
    ) ;_ end of progn
  ) ;_ end of while
  (princ)
) ;_ end of DEFUN
(prompt "\n- DCL: To change dimentions to layer kich_thuoc.\n")

(prompt "\nDIMENTION.LSP successfully loaded!\n")
(prompt "\n************************************************************\n")