Jump to content
vaidua

CAD Lisp code poly line vertex coords to txt file

Recommended Posts

vaidua

Hello,

 

I'm using Lee Mac cad lisp program "PolyInfo V 1.3." for exporting polylines vertex coordinates. But for full work joy I need some modifications.

 

URL for program: http://www.lee-mac.com/polyinfo.html

URL for code: http://www.lee-mac.com/lisp/html/PolyInfoV1-3.html

 

As you saw the program exports a lot of information about the polyline. So i want to modify the code that will export just polyline start vertex points x and y coords in two columns ( my cad version information exports to txt file ).

 

The result should look like this:

________________________________

Polyline starts points x

649542.45

649542.35

649542.28

 

Polyline starts points y

 

495232.54

495232.23

495232.41

________________________________

 

Can someone help to figure out which part of code I must to modify to get the result i want? Please.

Share this post


Link to post
Share on other sites
vaidua

Unfortunately I did, but I'm using not exact AutoCAD program. I'm using ZW CAD. I's cheaper version of cad program. So the comand line promt " ** Dialog File could not be Written ** ". Yach sometimes not all lisp programs works.

 

I just found an easier code of exporting X Y coordinates.

 

URL : http://www.eng-tips.com/viewthread.cfm?qid=195727

 

It is almost what i need. The result of code : (x coordinate) , (Y coordinate)

(x coordinate) , (Y coordinate)

 

But, can I change the code that coords print not in line, but in separated columns? for example:

(x coordinate)

(x coordinate)

 

(Y coordinate)

(Y coordinate)

Share this post


Link to post
Share on other sites
BIGAL

You can go back to 1st step basics and use the 'getcoordinates function then export what you want in the way you want. have a look at this example.

 

; pline co-ords example
; By Alan H
(defun getcoords (ent)
 (vlax-safearray->list
   (vlax-variant-value
     (vlax-get-property
   (vlax-ename->vla-object ent)
   "Coordinates"
     )
   )
 )
)

(defun co-ords2xy ()
; convert now to a list of xy as co-ords are x y x y x y if 3d x y z x y z
(setq len (length co-ords))
(setq numb (/ len 2)) ; even and odd check required
(setq I 0)
(repeat numb
(setq xy (list (nth i co-ords)(nth (+ I 1) co-ords) ))
; odd (setq xy (list (nth i co-ords)(nth (+ I 1) co-ords)(nth (+ I 2) co-ords) ))
(setq co-ordsxy (cons xy co-ordsxy))
(setq I (+ I 2))
)
)
; program starts here
(setq co-ords (getcoords (car (entsel "\nplease pick pline"))))
(co-ords2xy) ; list of 2d points making pline
(princ co-ordsxy)

Share this post


Link to post
Share on other sites
leo321

want change this

 

Labeling N,E Coordinates with Leader - David B. Stewart

 

(defun C:LP(/ PNT1 P1X P1Y STDY DY COORDN COORDE PTXT)

(setq PNT1 (getpoint

"\nPick coordinate point: "))

(setq P1X (car pnt1)) ;x coord

(setq P1Y (cadr pnt1)) ;y coord

(setq STDX (rtos P1X 2 2))

(setq STDY (rtos P1Y 2 2))

(setq COORDN (strcat "N=" STDY ))

(setq COORDE (strcat "E= " STDX ))

(setq PTXT (getpoint

"\nPick text location: "))

(command "LEADER" PNT1 PTXT "" COORDN COORDE "")

(princ)

)

 

 

come this way

 

N=8566159.79

E= 505422.47

 

 

wanted this way

 

N=8.566.159,79

E= 505.422,47

 

 

Want to know if it is possible that default

Edited by leo321

Share this post


Link to post
Share on other sites
hanhphuc

wanted this way

 

N=8.566.159,79

E= 505.422,47

 

 

never seen such number format, comma as decimal point?

 

not this?

N=8,566,159.79

E= 505,422.47

 

google "format number with thousand separator" many examples with others language as well

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×