;----------;クリックした点の座標値（X,Y)をテキストファイルに抽出する

;(R)=ARES

;<--------------2024/05/14
;<--------------2024/02/14
;<--------------2022/11/25









;******************* 点P1を指定
(Defun C:ClickP1 ( / Xp Yp Zp Pname )
;*******************
    (setq Pt (getpoint "\n点P1を指定:"))
    (Command "ID" Pt)
    (Command "Grips" "2")
    ;++++++++素地
    (setq X1 (rtos (car (GetVar "Lastpoint"))))
    (setq Y1 (rtos (cadr (GetVar "Lastpoint"))))
    ;++++++++
    (Setenv "X1" X1)
    (Setenv "Y1" Y1)
    ;++++++++
     (Command "Ucs" "w" "Leader" "@" "_non" Pause "a" 
                (Strcat "X1=" X1) (Strcat "Y1=" Y1) "")
    (Command "Grips" "2")	
    (Command "Ucs" "p")


    (princ)
);-------------------------------------------




;******************* 点P2を指定
(Defun C:ClickP2 ( / Xp Yp Zp Pname )
;*******************
    (setq Pt (getpoint "\n点P2を指定:"))
    (Command "ID" Pt)
    (Command "Grips" "2")
    ;++++++++素地
    (setq X2 (rtos (car (GetVar "Lastpoint"))))
    (setq Y2 (rtos (cadr (GetVar "Lastpoint"))))
    ;++++++++
    (Setenv "X2" X2)
    (Setenv "Y2" Y2)
    ;++++++++
     (Command "Ucs" "w" "Leader" "@" "_non" Pause "a" 
                (Strcat "X2=" X2) (Strcat "Y2=" Y2) "")
    (Command "Grips" "2")	
    (Command "Ucs" "p")



    (princ)
);-------------------------------------------



;************************クリックした点の座標値（X,Y)をテキストファイルに抽出する
(defun C:TransmitP1P2 ( / Ofile Fw MyData MyText)
;************************
    (setq Ofile "C:/MyCANAL/Supply/Text/TransUCS.txt")
    (setq Fw (open Ofile "w")) ;ファイルオープン
    (if (= Fw nil)
        (alert "\nファイルが見当たりません。")
        (progn
            ;++++++++ 1行目　X1
            (if (= (Getenv "X1") nil)
                (setq MyText "")
                (setq MyText (Getenv "X1")));if
            (setq MyText (strcat "X1=" MyText))
            (setq MyData MyText)
                                    (write-line MyData Fw) 
            ;++++++++ 2行目　Y1
            (if (= (Getenv "Y1") nil)
                (setq MyText "")
                (setq MyText (Getenv "Y1")));if
            (setq MyText (strcat "Y1=" MyText))
            (setq MyData MyText )
                                    (write-line MyData Fw) 
            ;++++++++ 3行目　X2
            (if (= (Getenv "X2") nil)
                (setq MyText "")
                (setq MyText (Getenv "X2")));if
            (setq MyText (strcat "X2=" MyText))
            (setq MyData MyText)
                                    (write-line MyData Fw) 
            ;++++++++ 4行目　Y2
            (if (= (Getenv "Y2") nil)
                (setq MyText "")
                (setq MyText (Getenv "Y2")));if
            (setq MyText (strcat "Y2=" MyText))
            (setq MyData MyText )
                                    (write-line MyData Fw) 
            ;++++++++
            (close Fw)
            (princ "\n****  座標値抽出完了  ****") 
        );progn
    );if
    
    (princ)
);-------------------------------------------



;******************* 座標系を変換
(defun C:TransUCS ( / SCRyn pt )
;*******************
    (Setenv "SCRyn" "N")
    ;+++++	
    (setq SCRyn (getstring (strcat "\n座標系を変換しますか？[ Y:はい/N:いいえ ] ")))
    (if (= "" SCRyn)
        (setq SCRyn (Getenv "SCRyn"));Enter/空打--->従前値採用
    );if
    (Setenv "SCRyn" SCRyn);<---扱いは文字列（数字は扱えない:NG）
    ;+++++
    (if (Or (equal SCRyn "Y") (equal SCRyn "y"))
        (Command "Script" "C:/MyCANAL/MyTransUCS.scr")
    );if
    ;+++++
    (Command "Grips" "2" "Filedia" "1")
    (princ)
);------------------------------------------------


