Jump to content

Recommended Posts

Posted

Hi there ifound in forum a very nice lisp for this job. But i want something different on this .The lisp is ECoor.lsp , it maked from Vladimir Azarko .

The change i want are:

1) select of circle and get the center to write the coordinates

2)write the text this format :

n,x,y and have 2 digit 000.00

1,120.12,200.54

 

thanks

  • Replies 23
  • Created
  • Last Reply

Top Posters In This Topic

  • shailujp

    7

  • nicpapa

    5

  • VVA

    4

  • Tharwat

    4

Top Posters In This Topic

Posted Images

Posted

Check this out Buddy .

 

This would write the center of the selected circles to your drive C:/My Folder/coordinates.txt so if you do not have the same name of the drive just replace

the char C: with your favorite one ..

 

(defun c:TesT (/ *error* dir fNme ss i sname c)
 (vl-load-com)
; THARWAT Oct. 07.2010
 (defun *error* (msg)
   (and fNme (close fNme))
   (if (and msg
            (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*QUIT*,"))
       )
     (princ (strcat "\nError: " msg))
   )
 )

 (setq dir "C:\\My Folder")
 (vl-mkdir dir)
 (if (and
       (setq fNme (open "C:/My Folder/coordinates.txt" "w"))
       (setq ss (ssget '((0 . "CIRCLE"))))
     )
   (progn
     (repeat (setq i (sslength ss))
       (setq sname (ssname ss (setq i (1- i))))
       (setq c (cdr (assoc 10 (entget sname))))
       (write-line
         (strcat (rtos (car c) 2 2) "\t" (rtos (cadr c) 2 2))
         fNme
       )
     )
     (close fNme)
   )
   (princ)
 )
 (princ)
)

 

Tharwat

Posted

Tharwat its good , can we add to take text nubmers near of the circle , and write to the text in this format point nubmer,x,y.

Thanks

Posted

Things like this .... ??

 

(defun c:TesT (/ *error* dir fNme ss i sname c x y)
 (vl-load-com)
; THARWAT Oct. 07.2010
 (defun *error* (msg)
   (and fNme (close fNme))
   (if (and msg
            (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*QUIT*,"))
       )
     (princ (strcat "\nError: " msg))
   )
 )

 (setq dir "C:\\My Folder")
 (vl-mkdir dir)
 (if (and
       (setq fNme (open "C:/My Folder/coordinates.txt" "w"))
       (setq ss (ssget '((0 . "CIRCLE"))))
     )
   (progn
     (repeat (setq i (sslength ss))
       (setq sname (ssname ss (setq i (1- i))))
       (setq c (cdr (assoc 10 (entget sname))))
       (write-line
         (strcat (setq x (rtos (car c) 2 2))
                 "\t"
                (setq y (rtos (cadr c) 2 2))
         )
         fNme
       )
       (entmakex (list '(0 . "MTEXT")
                       '(100 . "AcDbEntity")
                       '(100 . "AcDbMText")
                       (cons 40 (getvar 'textsize))
                       (cons 1
                             (strcat "X" "=" " " x "\\P" "Y" "=" " " y)
                       )
                       (assoc 10 (entget sname))
                       '(50 . 0.)
                       '(210 0.0 0.0 1.0)
                 )
       )

     )
     (close fNme)
   )
   (princ)
 )
 (princ)
)

Posted

sorry i write it wrong .

i have drawings that have as point a circle and near of the circle is numbered text eg 18 .

Those circle is stake out points i want if it possible to export those to text file like the first you post but with the numbers near of the circle.

eg text file

point nubmer, x,y

18,5124.24,45646.63

19,5454.26,46566.63

.....

 

look the image of attachments..

thanks

example.jpg

Posted

I am actually using the getfiled function to select the needed file which is already existed , and here in the OP's request needs to make a file and export strings (data) to it .

Posted
I am actually using the getfiled function to select the needed file which is already existed , and here in the OP's request needs to make a file and export strings (data) to it .

 

You can use getfiled in creation of a new file, read the documentation.

Posted

Thanls alot guys ...

xport coordinates (both Geodetic and Mathematical) ITs really very good, only two probllems the lisp its not working it gives an error

Command: GEO_EXPORT

; error: quit / exit abort

but the vlx is working , i check again and again the path support , i made news but nothing .

And the second is how i can change the last digit to two and not export the z

eg 1,869206.026,4034992.735,0.000

to 1,869206.03,4034992.74

 

Thanks again ..

Posted

I made ​​a small change in EcoorE.lsp (added circle). To round off to 2 decimal points, set the variable LUPREC = 2, or see command Units. To remove Z - exports and remove unnecessary Excell column. Or export to txt file, open in notepad, type Ctrl+F (find), find string: 0, replace string - nothing

Posted

οκ thanks a alot..

it working with circles now :)

  • 2 months later...
Posted

I want to calculate the area and export it to in excel file.

have any lisp routine for it.

 

I Have already lisp routine for above but in two files

one for Export coordinates and 2nd for calculting area.

 

How can I merge that both or Export Coordinate replace with Export Area.

 

 

Thanks & Regards !!

Sam

Export2DPoints-to-CSV.lsp

Area.LSP

  • 1 year later...
Posted (edited)

Hi Tharwat,

I'm using this lisp but also added arc as well.

Few questions:

How to also list diameter (or radius if its arc) with X & Y coordinates?

Does it allow to select the user defined 0,0 (or preset by UCS origin)?

 

Here is my A-BIT-MODIFIED version

 

(defun c:TesT (/ *error* dir fNme ss i sname c x y)
 (vl-load-com)
; THARWAT Oct. 07.2010
 (defun *error* (msg)
   (and fNme (close fNme))
   (if (and msg
            (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*QUIT*,"))
       )
     (princ (strcat "\nError: " msg))
   )
 )
 (setq dir "C:\\My Folder")
 (vl-mkdir dir)
 (if (and
       (setq fNme (open "C:/My Folder/coordinates.txt" "w"))
       (setq ss (ssget '((0 . "CIRCLE,ARC"))))
     )
   (progn
     (repeat (setq i (sslength ss))
       (setq sname (ssname ss (setq i (1- i))))
       (setq c (cdr (assoc 10 (entget sname))))
       (write-line
         (strcat (setq x (rtos (car c) 2 3))
                 "\t"
                (setq y (rtos (cadr c) 2 3))
         )
         fNme
       )
       (entmakex (list '(0 . "MTEXT")
                       '(100 . "AcDbEntity")
                       '(100 . "AcDbMText")
                       (cons 40 (getvar 'textsize))
                       (cons 1
                             (strcat "X" "=" " " x "[url="file://p/"]\\P[/url]" "Y" "=" " " y)
                       )
                       (assoc 10 (entget sname))
                       '(50 . 0.)
                       '(210 0.0 0.0 1.0)
                 )
       )
     )
     (close fNme)
(command "mtext" "0,0" "2,2" "0,0" "ORIGIN" "")
(command "chprop" "l" "" "c" "4" "")
   )
   (princ)
 )
 (princ)
)

Edited by SLW210
Added Code Tags!
Posted
Hi Tharwat,

I'm using this lisp but also added arc as well.

Few questions:

How to also list diameter (or radius if its arc) with X & Y coordinates?

Does it allow to select the user defined 0,0 (or preset by UCS origin)?

)

 

Hi shailujp

This ?

 

(defun c:Test (/ *error* fl f ss i sn e c r x y)
 ;;;--- Tharwat 03.06.2013---;;;
 (defun *error* (msg)
   (and f (close f))
   (princ (strcat "\nError: " msg "\n*Cancel*"))
 )
 (if (and (setq fl (getfiled "Specify the text file name :"
                             (getvar 'DWGPREFIX)
                             "txt"
                             1
                   )
          )
          (setq f (open fl "w"))
          (progn (princ "\n Select Arcs and Circles ")
                 (setq ss (ssget '((0 . "CIRCLE,ARC"))))
          )
     )
   (progn
     (write-line "X: \t Y: \t Diameter/Radius" f)
     (repeat (setq i (sslength ss))
       (setq e (entget (setq sn (ssname ss (setq i (1- i)))))
             c (cdr (assoc 10 e))
       )
       (if (eq (cdr (assoc 0 e)) "ARC")
         (setq r (cdr (assoc 40 e)))
         (setq r (* (cdr (assoc 40 e)) 2.))
       )
       (write-line
         (strcat (setq x (rtos (car c) 2 3))
                 "\t"
                 (setq y (rtos (cadr c) 2 3))
                 "\t"
                 (rtos r 2 3)
         )
         f
       )
       (entmakex
         (list '(0 . "MTEXT")
               '(100 . "AcDbEntity")
               '(100 . "AcDbMText")
               (cons 40 (getvar 'TEXTSIZE))
               (cons 1 (strcat "X" "=" " " x "\\P" "Y" "=" " " y))
               (assoc 10 e)
               '(50 . 0.)
         )
       )
     )
     (close f)
   )
   (princ)
 )
 (princ)
)

Posted

Hi Tharwat,

 

Your lisp works good. I removed arc filtering since I'm only using diameter as my output.

As and added feature to create a table, I downloaded another routine by J.Villareal. This gives me table inserted using the excel data which your utility generates.

 

Could you please help me take this one more step further, is it possible to insert serial number text (to define entity) instead of XY coordinates in the drawing. XY & Diameter details are required on the table only. This way the drawing will be clean, as smaller drawings gets messed up with too much Mtext overlapping it and becomes very hard to read.

 

I have attached lisp file as well the drawing.

 

P.S. My name is Shailesh, What is yours?

test2.lsp

Drawing1.dwg

Posted

Can anyone help me on fixing the routine?

Posted

Hi VVA

The lisp on the link works but for some reason the output coordinates do not match the actual dimensions. Not sure how it works.

 

Anyway, Here is what I could do till now with the below code (mainly from Tharwat, but I tweaked a just bit):

1) Ask for the user input to specify the origin (basically setting the UCS)

2) Export XY & Diameter detail to the excel file (converted XYto current UCS using trans function)

3) Adds a 0,0-Origin text so that user knows whether the origin is correct or not.

4) Brings back the whole table on the drawing using J. Villareal's TBL3.lisp (using datalink)

 

 

what I'm looking for is this :

1) All the entities (arc or circles) should be numbered on the drawing 1,2,3 etc....(similar to what COORN utility is doing per your link)

2) The table what it creates should have the First column for serial numbers (per item 1) and Fifth column for the type of entity (e.g. Arc or Circle) to identify the object type.

 

Can someone take a shot at this?

 

 

(defun c:XYT (/ *error* fl f ss i sn e c d x y DLName)
 ;;;--- Tharwat 03.06.2013---;;;
(SETVAR "TEXTSIZE" 2.5)
 (defun *error* (msg)
   (and f (close f))
   (princ (strcat "\nError: " msg "\n*Cancel*"))
 )
 (if (and (setq fl (getfiled "Specify the .xls file name :"
                             (getvar 'DWGPREFIX)
                             "xls"
                             1
                   )
          )
          (setq f (open fl "w"))
          (progn
   (setq orgn (getpoint "\n Specify the origin:"))
	 (command "ucs" "o" orgn)
         (princ "\n Select Ellipse, Arcs & Circles")
                 (setq ss (ssget '((0 . "ELLIPSE,CIRCLE,ARC"))))
          )
     )
   (progn
     (write-line "X: \t Y: \t Dia:" f)
     (repeat (setq i (sslength ss))
       (setq e (entget (setq sn (ssname ss (setq i (1- i)))))
            c (cdr (assoc 10 e))
       )
       ;(if (eq (cdr (assoc 0 e)) "arc")
         ;(setq r (cdr (assoc 40 e)))
         (setq d (* (cdr (assoc 40 e)) 2.))
       
       (write-line
         (strcat (setq x (rtos (car (trans c 0 1)) 2 3))
                 "\t"
                 (setq y (rtos (cadr (trans c 0 1)) 2 3))
                 "\t"
                 (setq d (rtos d 2 3))
         )
         f
 )
)
     (close f)
(command "mtext" "0,0" "j" "tr" "-2,-2" "0,0" "ORIGIN" "")
(command "chprop" "l" "" "c" "4" "")

(load "tbl3")
(tbl3)

;	(command "scale" "L" "" pause "0.6")


(princ)
)
(princ)
)
)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...