+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Full Member
    Computer Details
    enemigoman's Computer Details
    Operating System:
    Windows 7 Pro SP1 64 bits
    Using
    AutoCAD 2013
    Join Date
    Apr 2006
    Location
    Bogota, Colombia
    Posts
    65

    Default XYZ coordinate data export

    Registered forum members do not see this ad.

    How do I export the XYZ coordinate data of 3D polyline vertices into a *txt or *xls files?

  2. #2
    Super Moderator fuccaro's Avatar
    Using
    AutoCAD 2006
    Join Date
    Nov 2002
    Location
    Romania, Marosvasarhely
    Posts
    3,543

    Default

    You will need a Lisp routine. Do you have the full AutoCAD?
    It's nice to be nice, but sometimes is nicer to be evil!.
    Tip: Please do not PM or email me with CAD questions - use the forums, you'll get an answer sooner.

  3. #3
    Full Member
    Computer Details
    enemigoman's Computer Details
    Operating System:
    Windows 7 Pro SP1 64 bits
    Using
    AutoCAD 2013
    Join Date
    Apr 2006
    Location
    Bogota, Colombia
    Posts
    65

    Default

    Yes, I do have the full of AutoCAD 2007. Do you know where I can find such a routine? Thanks for the reply

  4. #4
    Super Moderator rkmcswain's Avatar
    Computer Details
    rkmcswain's Computer Details
    Operating System:
    Windows 7 Pro x64
    Motherboard:
    Intel DZ77RE-75K
    CPU:
    i7-4770K 3.50GHz
    RAM:
    32GB
    Graphics:
    Nvidia Quadro 2000
    Primary Storage:
    125GB SSD
    Secondary Storage:
    500GB SATA
    Monitor:
    ASUS 27" / ASUS 24"
    Discipline
    Civil
    Using
    Civil 3D 2015
    Join Date
    Sep 2005
    Location
    Houston
    Posts
    3,920

    Default

    Try PTEXPORT.LSP, found at http://www.dotsoft.com/freestuff.htm

  5. #5
    Senior Member
    Using
    AutoCAD 2008
    Join Date
    Nov 2005
    Location
    Bulgaria, Sofia
    Posts
    236

    Default

    You can try the following VBA application. It displays the coordinates of all 3DPolylines selected by the user in Excel.



    Sub Export3DPolylines()

    Dim objSS As AcadSelectionSet
    On Error Resume Next
    ThisDrawing.SelectionSets("MySS").Delete
    ThisDrawing.SelectionSets.Add ("MySS")
    Set objSS = ThisDrawing.SelectionSets("MySS")
    objSS.SelectOnScreen

    Dim objent As AcadEntity
    Dim MasRem() As AcadEntity
    Dim N As Integer
    N = -1

    For Each objent In objSS
    If objent.ObjectName <> "AcDb3dPolyline" Then
    N = N + 1
    If N = 0 Then
    ReDim MasRem(N)
    Else
    ReDim Preserve MasRem(N)
    End If
    Set MasRem(N) = objent
    End If
    Next

    objSS.RemoveItems MasRem

    If objSS.Count = 0 Then
    MsgBox "No 3DPolylines found!"
    Exit Sub
    End If

    Dim Excel As Object
    Set Excel = CreateObject("Excel.Application")
    Set wkb = Excel.workbooks.Add
    Set sht = wkb.sheets(1)

    Dim MasCoord As Variant
    Dim Col As Integer
    Dim Row As Integer
    Col = -3
    Row = 1

    For i = 0 To objSS.Count - 1
    Col = Col + 4
    Row = 1
    MasCoord = objSS(i).Coordinates

    sht.cells(1, Col) = "3DPolyline " & i + 1 & " coordinates"
    sht.cells(2, Col) = "X"
    sht.cells(2, Col + 1) = "Y"
    sht.cells(2, Col + 2) = "Z"
    Row = 2
    For j = 0 To (UBound(MasCoord) + 1) / 3 - 1
    Row = Row + 1
    sht.cells(Row, Col) = MasCoord(3 * j)
    sht.cells(Row, Col + 1) = MasCoord(3 * j + 1)
    sht.cells(Row, Col + 2) = MasCoord(3 * j + 2)
    Next
    Next

    Excel.Visible = True

    End Sub

  6. #6
    Super Moderator fuccaro's Avatar
    Using
    AutoCAD 2006
    Join Date
    Nov 2002
    Location
    Romania, Marosvasarhely
    Posts
    3,543

    Default

    and this is for exporting polyline points into text or csv files to open them in excel. Note thet you can edit the program text tochange the separator. You may use \t to have the items separated by a tab, \n to have them on a new line or use any other symbol.
    Code:
    ;export old style polyline vertex coords to a text file
    ;    mfuccaro@hotmail.com
    (defun c:pl2tx( / en ask i a file)
      (while (not ask)
        (setq en (car (entsel)))
        (if en (setq ask (= "POLYLINE" (cdr (assoc 0 (entget en))))))
        )
      (setq file (open (getfiled "Output file"
                     (strcat (getvar "dwgprefix")
                     (substr (getvar "DWGNAME") 1 (- (strlen (getvar "dwgname")) 4)))
                     "txt"     ;file type
                     1) "w"))
      (setq i 0 sep ";")    ;sep=separator
      (while (or (zerop i) a)
        (setq a (mapcar 'rtos (cdr (assoc 10 (entget (setq en (entnext en)))))))
        (if a (write-line (strcat (car a) sep (cadr a) sep (caddr a)) file))
        (setq i (1+ i))
        )
      (close file)
      (princ (strcat "\n" (itoa (1- i)) " points exported"))
      (princ)
      )
    And HERE you will find help on how to run Lisp routines.
    It's nice to be nice, but sometimes is nicer to be evil!.
    Tip: Please do not PM or email me with CAD questions - use the forums, you'll get an answer sooner.

  7. #7
    Forum Newbie
    Using
    AutoCAD 2008
    Join Date
    Apr 2010
    Posts
    1

    Default

    Registered forum members do not see this ad.

    Hey... a few years later I found this post.

    I ran the vba from Joro thanks it works really good except that...

    Id really like to have alle the coordinate in the first 3 row. The code does export the coordinate of each polyline in different set of 3 row.

    I tried to modified the code with no sucess. I tried to change col = col +4 to col = col but it didnt work.

    I no nothing about coding.

    If someonw can help it will save me a lot of time.

    Thanks

Bookmarks

Posting Permissions

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