;Tip1374.LSP: OFCTR.LSP Offset Line to Center (Dean Saadallah)

(defun C:OFCTR (/ OS CL CD LAYR PT1 PT2 PT3 DST1
DST2)
(setq OS (getvar "OSMODE"))
(setq CL (getvar "CLAYER"))
(setq CD (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(princ "\nTarget Layer? :"))
(if (equal LAYR "")
(setq LAYR (getvar "CLAYER"))
) ;_ end of if
(setvar "OSMODE" 512)
(setq PT1 (getpoint "\nPick First Line "))
(setq PT2 PT1)
(setvar "OSMODE" 128)
(setq PT3 (getpoint PT1 "\nPick Second Line "))
(setvar "OSMODE" 0)
(setq DST1 (distance PT1 PT3))
(setq DST2 (/ DST1 2))
(command "OFFSET" DST2 PT1 PT3 "")
(command "CHPROP" "L" "" "LA" LAYR
"LT" "BYLAYER" "C" "BYLAYER" ""
) ;_ end of command
(setvar "OSMODE" OS)
(setvar "CMDECHO" CD)
) ;_ end of defun
(C:OFCTR)

Advertisements