View Full Version : Export X Coordinates only to note pad with Space Seperator
prasadcivil
2016-06-11, 03:10 PM
Dear all Well Wishers,
Please provide a code for Exporting X coordinates only to Notepad with space separator or comma separator only. and i need Exporting Y coordinates only to Notepad with space separator. sorry for my poor English.so kindly suggest and provide Auto lisp as soon as possible.
example of X coordinates in note pad is= 0 2 3.5 6 8.2 10 13 14 17
example of Y coordinates in note pad is= 0 1.5 3.2 4 6.3 9 12.5 19
thank you for Supporting.
BlackBox
2016-06-12, 03:05 AM
Welcome to AUGI; your English is very good.
If you're not adept at coding LISP yourself, you might try DATAEXTRACTION Command.
If you'd like to try coding the LISP yourself, consider the iterations a Selection Set using FOREACH, and write the desired content to a Text File using OPEN, and WRITE-LINE Functions. Don't forget to use the CLOSE Function even if there's an *error*. :beer:
Cheers
prasadcivil
2016-06-12, 05:33 AM
Dear sir,
thank you for your kind reply. i am not expert in Auto cad. but i am using many lisp programs.if you dont mine can you provide direct auto lisp program to achieve my requirement.iam tried data extraction command but that is very lengthy task.i want generate the note pad file as mention above for x coordinates only or Y coordinates only.
Thanking you.
prasadcivil
2016-06-13, 04:46 AM
Dear all Masters,
Please respond to this simple task and provide yours valuable effort.
Bruno.Valsecchi
2016-06-13, 01:17 PM
Hi,
Try this code and see comments ;-> **** xxxxx **** <- for adapt to your convenient
(defun l-coor2l-pt (lst flag / )
(if lst
(cons
(list
(car lst)
(cadr lst)
(if flag
(+ (if (vlax-property-available-p ename 'Elevation) (vlax-get ename 'Elevation) 0.0) (caddr lst))
(if (vlax-property-available-p ename 'Elevation) (vlax-get ename 'Elevation) 0.0)
)
)
(l-coor2l-pt (if flag (cdddr lst) (cddr lst)) flag)
)
)
)
(defun c:ptdef2notepad ( / js dxf_cod mod_sel n lremov str_sep oldim ename l_pt l_pr tmp1 f_openx tmp2 f_openy)
(princ "\nSelect a model object for filtering: ")
(while
(null
(setq js
(ssget "_+.:E:S"
(list
'(0 . "*LINE,POINT,ARC,CIRCLE,ELLIPSE,INSERT")
(cons 67 (if (eq (getvar "CVPORT") 1) 1 0))
(cons 410 (if (eq (getvar "CVPORT") 1) (getvar "CTAB") "Model"))
)
)
)
)
(princ "\nIsn't an available object!")
)
(vl-load-com)
(setq dxf_cod (entget (ssname js 0)))
(foreach m (foreach n dxf_cod (if (not (member (car n) '(0 67 410 8 6 62 48 420 70))) (setq lremov (cons (car n) lremov))))
(setq dxf_cod (vl-remove (assoc m dxf_cod) dxf_cod))
)
(initget "Single All Manual")
(if (eq (setq mod_sel (getkword "\nSelect mode, [Single/All/Manual]<Manual>: ")) "Single")
(setq n -1)
(if (eq mod_sel "All")
(setq js (ssget "_X" dxf_cod) n -1)
(setq js (ssget dxf_cod) n -1)
)
)
(setq
str_sep ";" ;-> **** YOU CAN CHANGE THIS STRING BY WHAT YOU WANT ! **** <-
oldim (getvar "dimzin")
)
(setvar "dimzin" 0)
(repeat (sslength js)
(setq ename (vlax-ename->vla-object (ssname js (setq n (1+ n)))))
(setq l_pr (list 'StartPoint 'EndPoint 'Center 'InsertionPoint 'Coordinates 'FitPoints))
(foreach n l_pr
(if (vlax-property-available-p ename n)
(setq l_pt
(if (or (eq n 'Coordinates) (eq n 'FitPoints))
(append
(if (eq (vla-get-ObjectName ename) "AcDbPolyline")
(l-coor2l-pt (vlax-get ename n) nil)
(if (and (eq n 'FitPoints) (zerop (vlax-get ename 'FitTolerance)))
(l-coor2l-pt (vlax-get ename 'ControlPoints) T)
(l-coor2l-pt (vlax-get ename n) T)
)
)
l_pt
)
(cons (vlax-get ename n) l_pt)
)
)
)
)
)
(setq
tmp1 (vl-filename-mktemp "tmp_x.csv")
f_openx (open tmp1 "w")
)
(write-line (apply 'strcat (mapcar '(lambda (x) (strcat (rtos (car x) 2 3) str_sep)) l_pt)) f_openx) ;-> **** YOU CAN CHANGE UNIT AND PRECISION (rtos x unit prec) ! **** <-
(close f_openx)
(startapp "notepad" tmp1)
(setq
tmp2 (vl-filename-mktemp "tmp_y.csv")
f_openy (open tmp2 "w")
)
(write-line (apply 'strcat (mapcar '(lambda (x) (strcat (rtos (cadr x) 2 3) str_sep)) l_pt)) f_openy) ;-> **** YOU CAN CHANGE UNIT AND PRECISION (rtos x unit prec) ! **** <-
(close f_openy)
(setvar "dimzin" oldim)
(startapp "notepad" tmp2)
(prin1)
)
prasadcivil
2016-06-14, 06:58 AM
Hi,
Try this code and see comments ;-> **** xxxxx **** <- for adapt to your convenient
(defun l-coor2l-pt (lst flag / )
(if lst
(cons
(list
(car lst)
(cadr lst)
(if flag
(+ (if (vlax-property-available-p ename 'Elevation) (vlax-get ename 'Elevation) 0.0) (caddr lst))
(if (vlax-property-available-p ename 'Elevation) (vlax-get ename 'Elevation) 0.0)
)
)
(l-coor2l-pt (if flag (cdddr lst) (cddr lst)) flag)
)
)
)
(defun c:ptdef2notepad ( / js dxf_cod mod_sel n lremov str_sep oldim ename l_pt l_pr tmp1 f_openx tmp2 f_openy)
(princ "\nSelect a model object for filtering: ")
(while
(null
(setq js
(ssget "_+.:E:S"
(list
'(0 . "*LINE,POINT,ARC,CIRCLE,ELLIPSE,INSERT")
(cons 67 (if (eq (getvar "CVPORT") 1) 1 0))
(cons 410 (if (eq (getvar "CVPORT") 1) (getvar "CTAB") "Model"))
)
)
)
)
(princ "\nIsn't an available object!")
)
(vl-load-com)
(setq dxf_cod (entget (ssname js 0)))
(foreach m (foreach n dxf_cod (if (not (member (car n) '(0 67 410 8 6 62 48 420 70))) (setq lremov (cons (car n) lremov))))
(setq dxf_cod (vl-remove (assoc m dxf_cod) dxf_cod))
)
(initget "Single All Manual")
(if (eq (setq mod_sel (getkword "\nSelect mode, [Single/All/Manual]<Manual>: ")) "Single")
(setq n -1)
(if (eq mod_sel "All")
(setq js (ssget "_X" dxf_cod) n -1)
(setq js (ssget dxf_cod) n -1)
)
)
(setq
str_sep ";" ;-> **** YOU CAN CHANGE THIS STRING BY WHAT YOU WANT ! **** <-
oldim (getvar "dimzin")
)
(setvar "dimzin" 0)
(repeat (sslength js)
(setq ename (vlax-ename->vla-object (ssname js (setq n (1+ n)))))
(setq l_pr (list 'StartPoint 'EndPoint 'Center 'InsertionPoint 'Coordinates 'FitPoints))
(foreach n l_pr
(if (vlax-property-available-p ename n)
(setq l_pt
(if (or (eq n 'Coordinates) (eq n 'FitPoints))
(append
(if (eq (vla-get-ObjectName ename) "AcDbPolyline")
(l-coor2l-pt (vlax-get ename n) nil)
(if (and (eq n 'FitPoints) (zerop (vlax-get ename 'FitTolerance)))
(l-coor2l-pt (vlax-get ename 'ControlPoints) T)
(l-coor2l-pt (vlax-get ename n) T)
)
)
l_pt
)
(cons (vlax-get ename n) l_pt)
)
)
)
)
)
(setq
tmp1 (vl-filename-mktemp "tmp_x.csv")
f_openx (open tmp1 "w")
)
(write-line (apply 'strcat (mapcar '(lambda (x) (strcat (rtos (car x) 2 3) str_sep)) l_pt)) f_openx) ;-> **** YOU CAN CHANGE UNIT AND PRECISION (rtos x unit prec) ! **** <-
(close f_openx)
(startapp "notepad" tmp1)
(setq
tmp2 (vl-filename-mktemp "tmp_y.csv")
f_openy (open tmp2 "w")
)
(write-line (apply 'strcat (mapcar '(lambda (x) (strcat (rtos (cadr x) 2 3) str_sep)) l_pt)) f_openy) ;-> **** YOU CAN CHANGE UNIT AND PRECISION (rtos x unit prec) ! **** <-
(close f_openy)
(setvar "dimzin" oldim)
(startapp "notepad" tmp2)
(prin1)
)
Thank you very much amazing code sir,
with help of your code only exporting y coordinates.if i want Export X coordinates only? what is the modification in your code? kindly arrange the code for X coordinates only also.
Thanking you for your support.
Bruno.Valsecchi
2016-06-14, 09:14 AM
Thank you very much amazing code sir,
with help of your code only exporting y coordinates.if i want Export X coordinates only? what is the modification in your code? kindly arrange the code for X coordinates only also.
Thanking you for your support.
?!?!
There are two open notepad!
(startapp "notepad" tmp1) for X
(startapp "notepad" tmp2) for Y
If you don't want Y comment the line with semi-colon
;(startapp "notepad" tmp2)
prasadcivil
2016-06-14, 09:48 AM
?!?!
There are two open notepad!
(startapp "notepad" tmp1) for X
(startapp "notepad" tmp2) for Y
If you don't want Y comment the line with semi-colon
;(startapp "notepad" tmp2)
Dear sir,
really sorry for wrong observation.yes i got my super code from you. really i am appreciating your effort.thank you very much sir. you saved my time a lot.
sir kindly arrange another code from you. can i expect? my requirement as below
*I need two lisp programs in one code. one is Place lines as a stack with some minor offset see the pic-1. because some of my lines are merged and combined each other.highest length of a line should be bottom or top and remaining lines are stacked by descending order by its length of line.please find attachment for clarity.
2nd lisp for length Labeling of a Poly lines or Ordinary lines with leader based upon my units meter or feet.please find attachment for clarity.
Please provide suitable Lisp code for this lengthy task for me.
Bruno.Valsecchi
2016-06-14, 10:03 AM
Dear sir,
really sorry for wrong observation.yes i got my super code from you. really i am appreciating your effort.thank you very much sir. you saved my time a lot.
sir kindly arrange another code from you. can i expect? my requirement as below
*I need two lisp programs in one code. one is Place lines as a stack with some minor offset see the pic-1. because some of my lines are merged and combined each other.highest length of a line should be bottom or top and remaining lines are stacked by descending order by its length of line.please find attachment for clarity.
2nd lisp for length Labeling of a Poly lines or Ordinary lines with leader based upon my units meter or feet.please find attachment for clarity.
Please provide suitable Lisp code for this lengthy task for me.
I have seen your other post, but for me, the rules isn't clear and lot of time for coding this. Perhaps other one person!
And my language is french and easy answer is difficult for me!
prasadcivil
2016-06-14, 10:55 AM
?!?!
There are two open notepad!
(startapp "notepad" tmp1) for X
(startapp "notepad" tmp2) for Y
If you don't want Y comment the line with semi-colon
;(startapp "notepad" tmp2)
Dear sir after Exporting to note pad my values are showing for Y coordinates are like below
15.85 17.49 12.69 9.30 6.29 1.33 0.00
As per above out put i need ascending order like a 0.00 1.33 6.29 9.30 12.69 17.49 15.85.
But X coordinates file is ok.problem with Y coordinates file.
So please modify the code.
Thanking you sir.
Bruno.Valsecchi
2016-06-14, 11:53 AM
Dear sir after Exporting to note pad my values are showing for Y coordinates are like below
15.85 17.49 12.69 9.30 6.29 1.33 0.00
As per above out put i need ascending order like a 0.00 1.33 6.29 9.30 12.69 17.49 15.85.
But X coordinates file is ok.problem with Y coordinates file.
So please modify the code.
Thanking you sir.
Try to replace:
(write-line (apply 'strcat (mapcar '(lambda (x) (strcat (rtos (cadr x) 2 3) str_sep)) l_pt)) f_openy)
by
(write-line (apply 'strcat (mapcar '(lambda (x) (strcat (rtos (cadr x) 2 3) str_sep)) (reverse l_pt))) f_openy)
prasadcivil
2016-06-14, 01:28 PM
I have seen your other post, but for me, the rules isn't clear and lot of time for coding this. Perhaps other one person!
And my language is french and easy answer is difficult for me!
Thank you for your reply sir,
ok please make one by one.
1st one is see my embedded lines.those are merging like a single line. so separate line by line. my rule is highest length line is bottom one next highest line is with some offset like a 0.02m. and all next lines with 0.02m. so kindly try for me. see my first pic. those blue lines are combined. and see 2nd pic.this pic is after i moved manually with some gap.highest length line is near to yellow border line. next lines are ascending order, this is the rule.
thanking you sir.
prasadcivil
2016-06-14, 01:40 PM
Try to replace:
(write-line (apply 'strcat (mapcar '(lambda (x) (strcat (rtos (cadr x) 2 3) str_sep)) l_pt)) f_openy)
by
(write-line (apply 'strcat (mapcar '(lambda (x) (strcat (rtos (cadr x) 2 3) str_sep)) (reverse l_pt))) f_openy)
Dear sir thank you for modification. after modification again shows like this=50.296 46.731 43.730 39.697 35.945 33.037 29.472 25.439 22.344 19.436.
it is Highest to lowest values showing.So kindly make rule for ascending order for Y coordinates file. as well as X coordinate.
Thanking you for your kind reply.
Bruno.Valsecchi
2016-06-14, 02:37 PM
So kindly make rule for ascending order for Y coordinates file. as well as X coordinate.
If you want ascending order for Y change to:
(write-line (apply 'strcat (vl-sort (mapcar '(lambda (x) (strcat (rtos (cadr x) 2 3) str_sep)) l_pt) '<)) f_openy)
Make same with X if you want. Isn't sorted by default...
prasadcivil
2016-06-15, 07:33 AM
If you want ascending order for Y change to:
(write-line (apply 'strcat (vl-sort (mapcar '(lambda (x) (strcat (rtos (cadr x) 2 3) str_sep)) l_pt) '<)) f_openy)
Make same with X if you want. Isn't sorted by default...
Sir thank you for your kind reply..yes your modification is greatly worked for Y coordinates. and i i am tried and modified for X coordinates, but fail because i am not expert in lisp program. kindly provide the modification for X coordinates also for Ascending order sorting. becuase some times x Not working properly.
Thanking you sir.
Bruno.Valsecchi
2016-06-15, 10:09 AM
because i am not expert in lisp program
Ok, I understand why you don't mesure your ask and the task that generating...
The last one
(defun l-coor2l-pt (lst flag / )
(if lst
(cons
(list
(car lst)
(cadr lst)
(if flag
(+ (if (vlax-property-available-p ename 'Elevation) (vlax-get ename 'Elevation) 0.0) (caddr lst))
(if (vlax-property-available-p ename 'Elevation) (vlax-get ename 'Elevation) 0.0)
)
)
(l-coor2l-pt (if flag (cdddr lst) (cddr lst)) flag)
)
)
)
(defun c:ptdef2notepad ( / js dxf_cod mod_sel n lremov str_sep oldim ename l_pt l_pr tmp1 f_openx tmp2 f_openy)
(princ "\nSelect model object for filtering: ")
(while
(null
(setq js
(ssget "_+.:E:S"
(list
'(0 . "*LINE,POINT,ARC,CIRCLE,ELLIPSE,INSERT")
(cons 67 (if (eq (getvar "CVPORT") 1) 1 0))
(cons 410 (if (eq (getvar "CVPORT") 1) (getvar "CTAB") "Model"))
)
)
)
)
(princ "\nIsn't an available object!")
)
(vl-load-com)
(setq dxf_cod (entget (ssname js 0)))
(foreach m (foreach n dxf_cod (if (not (member (car n) '(0 67 410 8 6 62 48 420 70))) (setq lremov (cons (car n) lremov))))
(setq dxf_cod (vl-remove (assoc m dxf_cod) dxf_cod))
)
(initget "Single All Manual")
(if (eq (setq mod_sel (getkword "\nSelect mode, [Single/All/Manual]<Manual>: ")) "Single")
(setq n -1)
(if (eq mod_sel "All")
(setq js (ssget "_X" dxf_cod) n -1)
(setq js (ssget dxf_cod) n -1)
)
)
(setq
str_sep ";" ;-> **** YOU CAN CHANGE THIS STRING BY WHAT YOU WONT ! **** <-
oldim (getvar "dimzin")
)
(setvar "dimzin" 0)
(repeat (sslength js)
(setq ename (vlax-ename->vla-object (ssname js (setq n (1+ n)))))
(setq l_pr (list 'StartPoint 'EndPoint 'Center 'InsertionPoint 'Coordinates 'FitPoints))
(foreach n l_pr
(if (vlax-property-available-p ename n)
(setq l_pt
(if (or (eq n 'Coordinates) (eq n 'FitPoints))
(append
(if (eq (vla-get-ObjectName ename) "AcDbPolyline")
(l-coor2l-pt (vlax-get ename n) nil)
(if (and (eq n 'FitPoints) (zerop (vlax-get ename 'FitTolerance)))
(l-coor2l-pt (vlax-get ename 'ControlPoints) T)
(l-coor2l-pt (vlax-get ename n) T)
)
)
l_pt
)
)
)
)
)
)
(setq
tmp1 (vl-filename-mktemp "tmp_x.csv")
f_openx (open tmp1 "w")
)
(write-line (apply 'strcat (vl-sort (mapcar '(lambda (x) (strcat (rtos (car x) 2 3) str_sep)) l_pt) '<)) f_openx) ;-> **** YOU CAN CHANGE UNIT AND PREC (rtos x unit prec) ! **** <-
(close f_openx)
(startapp "notepad" tmp1)
(setq
tmp2 (vl-filename-mktemp "tmp_y.csv")
f_openy (open tmp2 "w")
)
(write-line (apply 'strcat (vl-sort (mapcar '(lambda (x) (strcat (rtos (cadr x) 2 3) str_sep)) l_pt) '<)) f_openy) ;-> **** YOU CAN CHANGE UNIT AND PREC (rtos x unit prec) ! **** <-
(close f_openy)
(setvar "dimzin" oldim)
(startapp "notepad" tmp2)
(prin1)
)
prasadcivil
2016-06-15, 12:05 PM
Ok, I understand why you don't mesure your ask and the task that generating...
The last one
(defun l-coor2l-pt (lst flag / )
(if lst
(cons
(list
(car lst)
(cadr lst)
(if flag
(+ (if (vlax-property-available-p ename 'Elevation) (vlax-get ename 'Elevation) 0.0) (caddr lst))
(if (vlax-property-available-p ename 'Elevation) (vlax-get ename 'Elevation) 0.0)
)
)
(l-coor2l-pt (if flag (cdddr lst) (cddr lst)) flag)
)
)
)
(defun c:ptdef2notepad ( / js dxf_cod mod_sel n lremov str_sep oldim ename l_pt l_pr tmp1 f_openx tmp2 f_openy)
(princ "\nSelect model object for filtering: ")
(while
(null
(setq js
(ssget "_+.:E:S"
(list
'(0 . "*LINE,POINT,ARC,CIRCLE,ELLIPSE,INSERT")
(cons 67 (if (eq (getvar "CVPORT") 1) 1 0))
(cons 410 (if (eq (getvar "CVPORT") 1) (getvar "CTAB") "Model"))
)
)
)
)
(princ "\nIsn't an available object!")
)
(vl-load-com)
(setq dxf_cod (entget (ssname js 0)))
(foreach m (foreach n dxf_cod (if (not (member (car n) '(0 67 410 8 6 62 48 420 70))) (setq lremov (cons (car n) lremov))))
(setq dxf_cod (vl-remove (assoc m dxf_cod) dxf_cod))
)
(initget "Single All Manual")
(if (eq (setq mod_sel (getkword "\nSelect mode, [Single/All/Manual]<Manual>: ")) "Single")
(setq n -1)
(if (eq mod_sel "All")
(setq js (ssget "_X" dxf_cod) n -1)
(setq js (ssget dxf_cod) n -1)
)
)
(setq
str_sep ";" ;-> **** YOU CAN CHANGE THIS STRING BY WHAT YOU WONT ! **** <-
oldim (getvar "dimzin")
)
(setvar "dimzin" 0)
(repeat (sslength js)
(setq ename (vlax-ename->vla-object (ssname js (setq n (1+ n)))))
(setq l_pr (list 'StartPoint 'EndPoint 'Center 'InsertionPoint 'Coordinates 'FitPoints))
(foreach n l_pr
(if (vlax-property-available-p ename n)
(setq l_pt
(if (or (eq n 'Coordinates) (eq n 'FitPoints))
(append
(if (eq (vla-get-ObjectName ename) "AcDbPolyline")
(l-coor2l-pt (vlax-get ename n) nil)
(if (and (eq n 'FitPoints) (zerop (vlax-get ename 'FitTolerance)))
(l-coor2l-pt (vlax-get ename 'ControlPoints) T)
(l-coor2l-pt (vlax-get ename n) T)
)
)
l_pt
)
)
)
)
)
)
(setq
tmp1 (vl-filename-mktemp "tmp_x.csv")
f_openx (open tmp1 "w")
)
(write-line (apply 'strcat (vl-sort (mapcar '(lambda (x) (strcat (rtos (car x) 2 3) str_sep)) l_pt) '<)) f_openx) ;-> **** YOU CAN CHANGE UNIT AND PREC (rtos x unit prec) ! **** <-
(close f_openx)
(startapp "notepad" tmp1)
(setq
tmp2 (vl-filename-mktemp "tmp_y.csv")
f_openy (open tmp2 "w")
)
(write-line (apply 'strcat (vl-sort (mapcar '(lambda (x) (strcat (rtos (cadr x) 2 3) str_sep)) l_pt) '<)) f_openy) ;-> **** YOU CAN CHANGE UNIT AND PREC (rtos x unit prec) ! **** <-
(close f_openy)
(setvar "dimzin" oldim)
(startapp "notepad" tmp2)
(prin1)
)
Dear sir, with help of your code, i hav getting like as below, please observe the output results:
X=109.329;31.573;40.830;53.084;69.129;77.592;86.937;98.221;
Y=10.092;110.198;116.178;20.784;37.869;59.796;78.021;99.947;
As per above results missing Ascending order. so kindly correct the modification to achieve required output. please find my attachment drawing also. this drawing points producing as a above mentioned values.
thanking you sir.
Bruno.Valsecchi
2016-06-15, 03:12 PM
I'am not sure to understand! you want to remove the multiple coordinate which are the same?
Try this!
prasadcivil
2016-06-16, 05:46 AM
I'am not sure to understand! you want to remove the multiple coordinate which are the same?
Try this!
Wow Amazing Now perfectly working. thank you very much sir. God bless you.
Feeling Happy.:)
Thank you sir.
prasadcivil
2016-08-10, 07:09 AM
I'am not sure to understand! you want to remove the multiple coordinate which are the same?
Try this!
Dear sir,
thank you for providing amazing code for me. still i am using your code.
I need small help from you.
Kindly make the modification to your amazing code.right now i am obtaining the results as 5630.00 5630.00 5630.00 1940.00.
So i want to produce those values to note pad as 5.63 5.63 5.63 1.94 (I.e Thousand multiples, so divide all values by 1000.) kindly make the modification.
Please find the Sample files of Cad drawing, Your lisp code, And Output Notepad files.
Bruno.Valsecchi
2016-08-10, 03:21 PM
Simply,
(strcat (rtos (car x) 2 2) str_sep)
became
(strcat (rtos (/ (car x) 1000.0) 2 2) str_sep)
prasadcivil
2016-08-11, 09:32 AM
Dear sir,
Thank you for Modification and sorry for expressing my doubt. i want for y Coordinates also.
Kindly make the modification for Y axis too.
Thanking you sir.
prasadcivil
2016-08-11, 01:38 PM
Dear sir,
One little request. that is after producing X and Y coordinates. Some coordinates are repeated. kindly fix this bug.
My condition is, if coordinates of points are repeated with same value, then produce single coordinates from those coordinates.
Example For X coordinates
1.20 1.20 1.30 1.40 1.40 to ----> 1.20 1.30 1.40 only ( Ascending order)
Example For y coordinates:
6.10 6.10 6.10 7.1 8.1 8.1 to ----> 6.10 7.10 8.1 only ( Ascending order)
Kindly make the modification.
Thanking you sir.
Bruno.Valsecchi
2016-08-11, 11:17 PM
I have posted in #18 (http://forums.augi.com/showthread.php?166480-Export-X-Coordinates-only-to-note-pad-with-Space-Seperator&p=1314512&viewfull=1#post1314512) for remove double...?!?!
For minor change try to do it your self!
;; gc:distinct (gilles chanteau)
;; Suprime tous les doublons d'une liste
;;
;; Argument
;; l : une liste
(defun gc:distinct (l)
(if l
(cons (car l) (gc:distinct (vl-remove (car l) l)))
)
)
(defun l-coor2l-pt (lst flag / )
(if lst
(cons
(list
(car lst)
(cadr lst)
(if flag
(+ (if (vlax-property-available-p ename 'Elevation) (vlax-get ename 'Elevation) 0.0) (caddr lst))
(if (vlax-property-available-p ename 'Elevation) (vlax-get ename 'Elevation) 0.0)
)
)
(l-coor2l-pt (if flag (cdddr lst) (cddr lst)) flag)
)
)
)
(defun c:ptdef2notepad ( / js dxf_cod mod_sel n lremov str_sep oldim ename l_pt l_pr pr l_x l_y tmp1 f_openx tmp2 f_openy)
(princ "\nSelect model object for filtering: ")
(while
(null
(setq js
(ssget "_+.:E:S"
(list
'(0 . "*LINE,POINT,ARC,CIRCLE,ELLIPSE,INSERT")
(cons 67 (if (eq (getvar "CVPORT") 1) 1 0))
(cons 410 (if (eq (getvar "CVPORT") 1) (getvar "CTAB") "Model"))
)
)
)
)
(princ "\nIsn't an available object!")
)
(vl-load-com)
(setq dxf_cod (entget (ssname js 0)))
(foreach m (foreach n dxf_cod (if (not (member (car n) '(0 67 410 8 6 62 48 420 70))) (setq lremov (cons (car n) lremov))))
(setq dxf_cod (vl-remove (assoc m dxf_cod) dxf_cod))
)
(initget "Single All Manual")
(if (eq (setq mod_sel (getkword "\nSelect mode, [Single/All/Manual]<Manual>: ")) "Single")
(setq n -1)
(if (eq mod_sel "All")
(setq js (ssget "_X" dxf_cod) n -1)
(setq js (ssget dxf_cod) n -1)
)
)
(setq
str_sep ";" ;-> **** YOU CAN CHANGE THIS STRING BY WHAT YOU WONT ! **** <-
oldim (getvar "dimzin")
)
(setvar "dimzin" 0)
(repeat (sslength js)
(setq ename (vlax-ename->vla-object (ssname js (setq n (1+ n)))))
(setq l_pr (list 'StartPoint 'EndPoint 'Center 'InsertionPoint 'Coordinates 'FitPoints))
(foreach pr l_pr
(if (vlax-property-available-p ename pr)
(setq l_pt
(if (or (eq pr 'Coordinates) (eq pr 'FitPoints))
(append
(if (eq (vla-get-ObjectName ename) "AcDbPolyline")
(l-coor2l-pt (vlax-get ename pr) nil)
(if (and (eq pr 'FitPoints) (zerop (vlax-get ename 'FitTolerance)))
(l-coor2l-pt (vlax-get ename 'ControlPoints) T)
(l-coor2l-pt (vlax-get ename pr) T)
)
)
l_pt
)
(append (l-coor2l-pt (vlax-get ename pr) T) l_pt)
)
)
)
)
)
(setq l_x (gc:distinct (mapcar '(lambda (x) (rtos (/ x 1000.0) 2 2)) (vl-sort (mapcar 'car l_pt) '<)))) ;-> **** YOU CAN CHANGE UNIT AND PREC (rtos x unit prec) ! **** <-
(setq l_y (gc:distinct (mapcar '(lambda (x) (rtos (/ x 1000.0) 2 2)) (vl-sort (mapcar 'cadr l_pt) '<)))) ;-> **** YOU CAN CHANGE UNIT AND PREC (rtos x unit prec) ! **** <-
(setq
tmp1 (vl-filename-mktemp "tmp_x.csv")
f_openx (open tmp1 "w")
)
(write-line (apply 'strcat (mapcar '(lambda (x) (strcat x str_sep)) l_x)) f_openx)
(close f_openx)
(startapp "notepad" tmp1)
(setq
tmp2 (vl-filename-mktemp "tmp_y.csv")
f_openy (open tmp2 "w")
)
(write-line (apply 'strcat (mapcar '(lambda (x) (strcat x str_sep)) l_y)) f_openy)
(close f_openy)
(startapp "notepad" tmp2)
(setvar "dimzin" oldim)
(prin1)
)
prasadcivil
2016-08-12, 05:53 AM
Dear sir,
Sorry for for your valuable time consuming by me. i am confused sending of correct code. your latest code is perfectly workable.
Can i Expect Excel Version Of Same Code?it is final request from me.
With help of your code producing as below to notepad:
X coordinates is ---->>0.07;1.94;4.57;5.63;8.91;11.12;15.31;16.91;20.38;
Y coordinates is ---->>1.40;3.49;4.32;4.86;7.91;12.53;
please make Excel version by your amazing code.
Please find Attachments of above input files (Auto cad) and Sample output file of Excel.
Bruno.Valsecchi
2016-08-12, 04:05 PM
For me I stay in format CSV (I don't need API)
If you want, consult for an exemple GetExcel.lsp (http://web2.airmail.net/terrycad/LISP/GetExcel.lsp) and his possibility
prasadcivil
2016-08-12, 04:15 PM
Thank you for your kind reply sir,
is it possible by CSV format instead of excel? same as excel visibility which is as Excel format? any possibility in csv
Best regards,
Thanking you sir.
prasadcivil
2016-10-17, 06:11 AM
Dear Master your code is really life saver, till date i have using this lisp program. i need small modification in your code. your code producing like this: 0.07;1.94;4.57;5.63;8.91;11.12;15.31;16.91;20.38;
i need like this in notepad file one under one value instead of ";" separator:
0.07
1.94
4.57
5.63
8.91
11.12
15.31
16.91
20.38
Kindly modify yours brilliant code.
Thanking you,
With best regards.
Bruno.Valsecchi
2016-10-18, 07:53 AM
Change in the code
(setq
str_sep ";" ;-> **** YOU CAN CHANGE THIS STRING BY WHAT YOU WONT ! **** <-
oldim (getvar "dimzin")
)
by
(setq
str_sep (strcat (chr 13) (chr 10)) ;-> **** YOU CAN CHANGE THIS STRING BY WHAT YOU WONT ! **** <-
oldim (getvar "dimzin")
)
prasadcivil
2016-10-19, 12:03 PM
Change in the code
Dear Master,
Thank you for your kind help. your code is well worked.
Thanking you,
Best regards.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.