×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

text in autocad - excel

text in autocad - excel

text in autocad - excel

(OP)
I found a lovely program in the shareware to give me the x,y,z coordintes of a point. The thing is it printas themn to a table in AutoCAD in the model space. Is there anyway to copy text from AutoCAD to excel?
the program is called XYZTBL.lsp
if someone could give me a lisp routine that does it then fantastic
Thank all for help
Andrew299

RE: text in autocad - excel

Dear andrew299,
I suggest you to write a program in VBA to access data in
Excel.
The below macro is written for AutoCAD VBA. It basically
reads data from current Excel session (from active cell)and
writes it in a message box. If you know some about EXCEL and AutoCAD VBA, you can extend the code to export coordinates to EXCEL.


Sub Main()
    Dim ex As Object
    Set ex = GetObject(, "EXCEL.Application")
    MsgBox ex.ActiveCell
End Sub


You can write the program so that there is no need to run
the Excel and read data directly from a xls file.

The VLISP can do all, but it is more complicated.

:)
Farzad

RE: text in autocad - excel

andrew299

Here is a very crude lisp file that will let you create a file and then let you pick points and they will be written to that file with the point number, x-coord, y-coord, z-coord (comma delimited).  The number of decimal places depends on what you have them set to in Acad.  This was created by cutting and pasting code from various lisp files.  It works in R14 and I don't see why it would not work for other releases

Hope this helps,
SEMott

(defun C:xyz-export (/ Temp_Name Temp_File File_Name
                     Count xc yc zc Coords)
  (setvar "cmdecho" 0)
  (setq Temp_Name (getstring "Enter the file name: "))
  (setq Temp_File (open Temp_Name "r"))
  (if (/= Temp_File nil)
    (progn
      (prompt "File already exists.\n")
      (close Temp_File)
    )
    (progn
      (setq File_Name (open Temp_Name "w"))
      (prompt "\nFile now open")
      (setq Exit nil)
      (setq Count 0)
      (while (null Exit)
        (setq p1 (getpoint "\nSelect Point for Coordinate Export: "))
        (cond
          ((null P1)(setq Exit 1))
          (t (progn          
               (setq
                 count (1+ count)
                 xc (rtos (car   p1) 2)
                 yc (rtos (cadr  p1) 2)
                 zc (rtos (caddr p1) 2)
                 coords (strcat (rtos count 2 0) (chr 44) xc (chr 44) yc (chr 44) zc)
               )
               (write-line coords File_Name)
             )
          )
        )
      )
      (close File_Name)
    )
  )
)

RE: text in autocad - excel

(OP)
Thank you SEMott. I loaded the program and it opens a new file and reads all the points. The only problem is how do i stop the program when I have finished selecting my points?
The program reads the points to the command line from which I can cut and paste to excel so to all intents and purposes it is perfect.
Thanks again very much
Andrew299

RE: text in autocad - excel

Andrew299,

To stop the program just hit <spacebar> or <enter>.  I made the format for the text file that is created - comma delimited, therefore you can easily import it or open it in Excel.

SEMott

RE: text in autocad - excel

(OP)
Thanks Everyone for their help, I have a program that takes selected text and writes it to a CSV file. This can be exported into excel. I have to state here that I did not write it but if anyone would like a copy then put a post on here and I will email it to them.

RE: text in autocad - excel

Dear friends,

The below VBA code writes the coordinates of picked points directly int EXCEL. It calls EXCEL automatically.

Sub Main()
    Dim Excel As Excel.Application
    Dim ExcelWorkbook As Object
    Dim flag As Boolean
    Dim pp As Variant
    
    On Error Resume Next
    Set Excel = New Excel.Application
    Excel.Visible = True
    Set ExcelWorkbook = Excel.Workbooks.Add
    pp = False
    flag = True
    Do While flag
        pp = ThisDrawing.Utility.GetPoint _
        (, vbCrLf & "Pick a point:")
        If pp <> False Then
            Excel.ActiveCell.Value = pp(0)
            Excel.ActiveCell.Offset(0, 1).Value = pp(1)
            Excel.ActiveCell.Offset(0, 2).Value = pp(2)
            Excel.ActiveCell.Offset(1, 0).Activate
        Else
            flag = False
        End If
        pp = False
    Loop
End Sub

:)
Farzad

RE: text in autocad - excel

With a little modification to the VBA code (last reply), you pick as many points as you wish rather than one point at a time.  

RE: text in autocad - excel

Dear Jotham,
The above VBA code lets you pick as many points as you wish.
:)
Farzad

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources