วันอังคารที่ 28 เมษายน พ.ศ. 2563

SSGET POINT Coordinate X,Y,Z to Excel .CVS File.

SSGET POINT Coordinate X,Y,Z to Excel .CVS File.
การเลือกตำแหน่ง (point) โดยการเลือกครอบตำแหน่งที่ต้องการทั้งหมด แล้วทำการส่งค่า (Coordinate X,Y,Z) ไปยัง Excel โดยการบันทึกเป็นไฟล์ .CVS แล้วค่อยเลือกบันทึกเป็น .xlsx เป็นไฟล์ Excel เพื่อนำค่าไปใช้ต่อไป
(defun c:P2CVS2 (/)
(setq old_cmdecho  (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq txth (getvar "TEXTSIZE"))
(if (setq fn (getfiled "Save to CSV file." "" "csv" 1))
    (progn
              (setq f (open fn "w")) ;Open the file for writing
              (write-line (strcat "Num.,X,Y,Z") f) ;Write header line to file      
              (if (setq ss (ssget '((0 . "POINT"))))
                     (progn
                           (setq is 1)
                            (repeat (setq i (sslength ss))
                                  (setq ent  (entget (ssname ss (setq i (1- i))))
                                           pt   (cdr (assoc 10 ent))
                                  )
                                  (command "_point" pt)
                                  (command "_text" "mc" pt txth "0" (rtos is 2 0))
                                  (write-line
                                         (strcat (rtos is 2 0)
                                                ","
                                                (rtos(car pt)2 3)
                                                ","
                                                (rtos(cadr pt)2 3)
                                                ","
                                                (rtos(caddr pt)2 3)
                                         );strcat
                                         f
                                  );write-line
                                  (setq is (1+ is))    
                           );repeat
                     );progn
              );if ssget
              (close f) ;Close the file
              (princ)
       );progn
       (princ "Stopped. Exit.");if don't save cvs file
);if
(setvar "cmdecho" old_cmdecho)
(princ)
);End

ไม่มีความคิดเห็น:

แสดงความคิดเห็น