Results 1 to 6 of 6

Thread: Export coordinates to Excel

  1. #1
    Member
    Join Date
    2004-09
    Posts
    9
    Login to Give a bone
    0

    Unhappy Export coordinates to Excel

    hi all,
    i have got a survey file which shows contour lines and elevation points. has there any possible way to convert these cordinates and levels in to Excel sheet? if yes please let me know.

    regards,
    refiq

  2. #2
    I could stop if I wanted to
    Join Date
    2006-01
    Location
    Land of chocolate
    Posts
    228
    Login to Give a bone
    0

    Default Re: Export coordinates to Excel

    when having an object, for example a block, you can use the ID command in the insert point to get it coordinates...

    hmmm, selecting all

    we are talking about a plain autocad right? because this sounds like LTD functionality

    i think the main problem is in selecting or defining the point your need excel file from

  3. #3
    Member
    Join Date
    2004-09
    Posts
    9
    Login to Give a bone
    0

    Default Re: Export coordinates to Excel

    Buffeldrek'
    can you make it more clear.(your previous reply)

    my other question related to this matter:

    i have a file full of survey points. the drawing contains points and texts reflects the coordinates and elevation points. i think this cad file is a converted copy from some survey softwares. because of some wrong command (my assumption) all the points are with negative values. E.g. if original point has a value of +2.5, we have this point in cad file with negative (-2.5). how can i overcome this negative to the right positive value other than moving one by one to it's +ve elevation. i am using AutoCAD 2006. I’d appreciate it if you can reply sooooooon..

    thanks & regards,
    refiq. "_"
    )(

  4. #4
    I could stop if I wanted to
    Join Date
    2006-01
    Posts
    202
    Login to Give a bone
    0

    Default Re: Export coordinates to Excel

    Put the following into a lsp file called pointco and place it in your AutcAD support folder on your c drive.
    Then in AutoCAD type (load"pointco") to load the routine. Type "pointco" to start the routine and follow the prompts on screen.

    Import the txt file that is created into excel and set the parameters accordingly so that each x,y,z value has its own column

    Disclaimer! : This is copied from a large lsp I have running and I am not sure if it relies on any other custom routines I have.

    I hope this helps.


    Code:
    ;; Routine to export point coords to TXT file
    
    (defun c:pointco ()
    (setvar "cmdecho" 0)
    (command "undo" "begin")
    (setq f nil)
    (setq pointco_index 0)
    
    (princ "\n Select the points\n" )
    
    (setq pointco_ss (ssget))
    
    (setq pointco_ss (ssget "P" (list (cons 0 "POINT")) ))
    
    (if (/= pointco_ss nil)
    (progn
    
    (setq DRAWING_NAME_pointco (getvar "dwgname"))
     (setq OLD_DWG_NAME_LENGTH_pointco (strlen DRAWING_NAME_pointco))
     (setq NEW_DWG_NAME_pointco (substr DRAWING_NAME_pointco 1 (- OLD_DWG_NAME_LENGTH_pointco 4)))
     (setq FNAME_pointco (strcat (getvar "dwgprefix") NEW_DWG_NAME_pointco ".txt"))
     (setq FILE_pointco (open FNAME_pointco "w"))
    
    (setq pointco_sl (sslength pointco_ss))
    
    (while (< pointco_index pointco_sl)
    
    (setq pointco_object (entget (ssname pointco_ss pointco_index)))
    (setq pointco_type (cdr (assoc 0 pointco_object)))
    
    (if (= pointco_type "POINT")
    (progn
    
    (setq pointco_coords (cdr (assoc 10 pointco_object)))
    (setq pointco_x (rtos (car pointco_coords) 2 5))
    (setq pointco_y (rtos (cadr pointco_coords) 2 5))
    (setq pointco_z (caddr pointco_coords))
    (if (/= pointco_z nil)
    (setq pointco_z (rtos pointco_z 2 5))
    )
    (if (= pointco_z nil)
    (setq pointco_z "0.00000")
    )
    (write-line (strcat pointco_x "," pointco_y "," pointco_z) file_pointco)
    
    ) ;progn
    ) ;if
    
    (setq pointco_index (+ 1 pointco_index))
    
    ) ;wend
    
    (close file_pointco)
    
    ) ;progn
    ) ;end
    
    (command "undo" "end")
    (setvar "cmdecho" 1)
    (princ)
    )

  5. #5
    Certified AUGI Addict jaberwok's Avatar
    Join Date
    2000-12
    Location
    0,0,0 The Origin
    Posts
    8,570
    Login to Give a bone
    0

    Default Re: Export coordinates to Excel

    Quote Originally Posted by rputhenv
    i have a file full of survey points. the drawing contains points and texts reflects the coordinates and elevation points. i think this cad file is a converted copy from some survey softwares. because of some wrong command (my assumption) all the points are with negative values. E.g. if original point has a value of +2.5, we have this point in cad file with negative (-2.5). how can i overcome this negative to the right positive value other than moving one by one to it's +ve elevation.
    How about mirroring the contours about the xy plane?
    An elevation of -2.5 becomes +2.5 ; -10 becomes +10 ; etc..

  6. #6
    Woo! Hoo! my 1st post
    Join Date
    2016-10
    Posts
    1
    Login to Give a bone
    0

    Red face Re: Export coordinates to Excel

    Could anyone change below lsp for me to export text coordinate to excel . I have used below code but coordinate point what program calculate is not text center and text base point which is left corner . So export coordinate are not right .



    ;; Main part ;;
    (defun C:tex (/ acsp adoc aexc awb axss cll
    colm com_data csht data header_list
    nwb osm pt row sht ss
    tmp tmp_data
    )

    (or (vl-load-com))
    (or adoc
    (setq adoc (vla-get-activedocument
    (vlax-get-acad-object)
    )
    )
    )
    (or acsp
    (setq acsp (if (= (getvar "TILEMODE") 0)
    (vla-get-paperspace
    adoc
    )
    (vla-get-modelspace
    adoc
    )
    )
    )
    )

    (setq ss (ssget '((0 . "*TEXT"))))
    (setq axss (vla-get-activeselectionset adoc))
    (setq com_data nil) ;for debug only

    (vlax-for a axss
    (setq pt (vlax-get a 'Insertionpoint))
    (setq tmp (list (substr (vla-get-objectname a) 5)
    (vla-get-textstring a)
    (rtos (car pt) 2 3)
    (rtos (cadr pt) 2 3)
    (rtos (caddr pt) 2 3)
    )
    )
    (setq com_data (cons tmp com_data))
    (setq tmp_data nil) ;for debug only
    )

    ;; *** Excel part *** ;;
    (alert "Save Excel manually")
    (setq aexc (vlax-get-or-create-object "Excel.Application")
    awb (vlax-get-property aexc "Workbooks")
    nwb (vlax-invoke-method awb "Add")
    sht (vlax-get-property nwb "Sheets")
    csht (vlax-get-property sht "Item" 1)
    cll (vlax-get-property csht "Cells")
    )
    (vlax-put-property csht 'Name "Specification")
    (vla-put-visible aexc :vlax-true)
    (setq row 1
    colm 1
    )
    (setq header_list
    (list "Object Name" "Content"
    "X coordinate" "Y coordinate"
    "Z coordinate"
    )
    )
    (repeat (length header_list)
    (vlax-put-property
    cll
    "Item"
    row
    colm
    (vl-princ-to-string (car header_list))
    )
    (setq colm (1+ colm)
    header_list
    (cdr header_list)
    )
    )
    (setq row 2
    colm 1
    )
    (repeat (length com_data)
    (setq data (car com_data))
    (repeat (length data)
    (vlax-put-property
    cll
    "Item"
    row
    colm
    (vl-princ-to-string (car data))
    )
    (setq colm (1+ colm))
    (setq data (cdr data))
    )
    (setq row (1+ row)
    colm 1
    )
    (setq com_data (cdr com_data))
    )
    (vlax-invoke-method
    (vlax-get-property csht "Columns")
    "AutoFit"
    )
    (vlax-release-object cll)
    (vlax-release-object csht)
    (vlax-release-object sht)
    (vlax-release-object nwb)
    (vlax-release-object awb)
    (vlax-release-object aexc)
    (setq aexc nil)
    (vla-clear axss)
    (vlax-release-object axss)
    (vla-regen adoc acactiveviewport)
    (gc)
    (gc)
    (princ)
    )
    (princ " *** Type TEX to execute ***")
    (princ)
    ;TesT:
    ;(C:tex)

Similar Threads

  1. Exporting the values of coordinates of Polyline/Line from Autocad to Excel
    By manolis_kakou391230 in forum VBA/COM Interop
    Replies: 0
    Last Post: 2013-12-05, 08:26 PM
  2. 2013: How do I export to IFC with project coordinates and not real world coordinates?
    By m.knutsson in forum Revit Architecture - General
    Replies: 2
    Last Post: 2013-10-15, 06:54 AM
  3. Civil 3D question - import points from excel, coordinates and attributes
    By Hotrod50 in forum AutoCAD Civil 3D - General
    Replies: 1
    Last Post: 2012-03-02, 05:09 PM
  4. Export Coordinates
    By Maastricht in forum AutoCAD Map 3D - General
    Replies: 3
    Last Post: 2009-08-19, 04:45 PM
  5. Excel X,Y Coordinates --> AutoCAD
    By davis in forum AutoCAD General
    Replies: 2
    Last Post: 2004-11-17, 01:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •