;;By Dereje Kitaw
(defun C:trtr (/ eset
MULTILEADER_ERM_L80n MULTILEADER_ERM_L90n
MULTILEADER_ERM_L140A
) ;define a program name
(vl-load-com)
(or station (setq station "F00"))
(if (/= ""
(setq
strdia (getstring
(strcat "\nEnter Station Code <" station "> ")
)
)
)
(setq station strdia)
)
(or file_name (setq file_name "mydata"))
(if (/= ""
(setq
file_name_new
(getstring
(strcat "\nEnter File Name <" file_name "> ")
)
)
)
(setq file_name file_name_new)
)
(if (setq eset (ssget)) ;use the ssget function to select entities
(progn ;use progn since there will be more than 1 statement
(setq cntr 0) ;set the cntr to the first item in the set
(setq MTexT_Set (ssadd))
(setq MULTILEADER_Set (ssadd))
(setq TEXT_Set (ssadd))
;;; (setq wf (open "D:\mydata.txt" "w"))
(setq file_1 "D:/")
(setq wf (open (strcat file_1 file_name ".txt") "w"))
(while (< cntr (sslength eset)) ;while cntr is less than the length of the set
;;; Note: the length is one more than the index of items since the first item is zero. In other words, to
;;; get to the first item in a selection set consisting of one item you would use (ssname eset 0) not
;;; (ssname eset 1).
(setq en (ssname eset cntr)) ;get the entity name of the item indexed with cntr
(setq enlist (entget en)) ;get the dxf group codes of the enitity
(setq entity_name (cdr (assoc 0 enlist))) ;get the layer name
;;; (princ "\n ") ;print "\n " will cause a new line to be printed
;;; (princ entity_name) ;print the layer name to the command line
(cond
((= entity_name "MTEXT")
(progn
(setq
content (cdr (assoc 1 (entget en)))
)
(setq val (strcat station "," content))
(write-line val wf)
)
)
((= entity_name "MULTILEADER")
(progn
(setq
content
(cdr (assoc 304 enlist))
)
(setq val (strcat station "," content))
(write-line val wf)
)
)
((= entity_name "TEXT")
(progn
(setq content (cdr (assoc 1 (entget en))))
;;; (setq
;;; content
;;; (cdr (assoc 2 (entget (cdr (assoc 304 enlist)))))
;;; )
(setq val (strcat station "," content))
(write-line val wf)
)
)
)
(setq cntr (+ cntr 1)) ;increment the counter
) ;close the while statement
(close wf)
) ;close the progn on the if statement
(princ "\n Error - No entities selected.")
;print a message on the else statement
; note: the if statement can be a " if then " statement or a " if then else" statement
) ;close the if statement
)
(defun C:trtr (/ eset
MULTILEADER_ERM_L80n MULTILEADER_ERM_L90n
MULTILEADER_ERM_L140A
) ;define a program name
(vl-load-com)
(or station (setq station "F00"))
(if (/= ""
(setq
strdia (getstring
(strcat "\nEnter Station Code <" station "> ")
)
)
)
(setq station strdia)
)
(or file_name (setq file_name "mydata"))
(if (/= ""
(setq
file_name_new
(getstring
(strcat "\nEnter File Name <" file_name "> ")
)
)
)
(setq file_name file_name_new)
)
(if (setq eset (ssget)) ;use the ssget function to select entities
(progn ;use progn since there will be more than 1 statement
(setq cntr 0) ;set the cntr to the first item in the set
(setq MTexT_Set (ssadd))
(setq MULTILEADER_Set (ssadd))
(setq TEXT_Set (ssadd))
;;; (setq wf (open "D:\mydata.txt" "w"))
(setq file_1 "D:/")
(setq wf (open (strcat file_1 file_name ".txt") "w"))
(while (< cntr (sslength eset)) ;while cntr is less than the length of the set
;;; Note: the length is one more than the index of items since the first item is zero. In other words, to
;;; get to the first item in a selection set consisting of one item you would use (ssname eset 0) not
;;; (ssname eset 1).
(setq en (ssname eset cntr)) ;get the entity name of the item indexed with cntr
(setq enlist (entget en)) ;get the dxf group codes of the enitity
(setq entity_name (cdr (assoc 0 enlist))) ;get the layer name
;;; (princ "\n ") ;print "\n " will cause a new line to be printed
;;; (princ entity_name) ;print the layer name to the command line
(cond
((= entity_name "MTEXT")
(progn
(setq
content (cdr (assoc 1 (entget en)))
)
(setq val (strcat station "," content))
(write-line val wf)
)
)
((= entity_name "MULTILEADER")
(progn
(setq
content
(cdr (assoc 304 enlist))
)
(setq val (strcat station "," content))
(write-line val wf)
)
)
((= entity_name "TEXT")
(progn
(setq content (cdr (assoc 1 (entget en))))
;;; (setq
;;; content
;;; (cdr (assoc 2 (entget (cdr (assoc 304 enlist)))))
;;; )
(setq val (strcat station "," content))
(write-line val wf)
)
)
)
(setq cntr (+ cntr 1)) ;increment the counter
) ;close the while statement
(close wf)
) ;close the progn on the if statement
(princ "\n Error - No entities selected.")
;print a message on the else statement
; note: the if statement can be a " if then " statement or a " if then else" statement
) ;close the if statement
)