Jump to content

excel to autocad


fbby

Recommended Posts

hi everyone!

 

I have coordinates in MS excel and I want to plot it in autocad 2008, is there any autolisp on this so that I cant spend a lot of time typing coordinates one by one in autocad?

 

can anyone help me on this?

thanks :)

 

 

 

___________________________

sorry for my english

Link to comment
Share on other sites

  • Replies 30
  • Created
  • Last Reply

Top Posters In This Topic

  • fbby

    7

  • Lee Mac

    7

  • wannabe

    6

  • ReMark

    4

Top Posters In This Topic

Posted Images

hi everyone!

 

I have coordinates in MS excel and I want to plot it in autocad 2008, is there any autolisp on this so that I cant spend a lot of time typing coordinates one by one in autocad?

 

can anyone help me on this?

thanks :)

 

 

 

___________________________

sorry for my english

this one works perfectly..but 1st convert excel to txt format.

 

http://www.cadtutor.net/forum/showthread.php?t=36808

 

:wink:

Link to comment
Share on other sites

Here's an application I created myself if you want to Insert blocks. User-guide attached, although the only real issue is formatting your excel spreadsheet.

 

Like standard AutoCAD pallettes, you can drag this around your screen and doesn't need to be docked at the edge of your screen.

MBP.zip

Link to comment
Share on other sites

I see no mention of the OP inserting blocks at these coordinates.

 

There is no need to use AutoLISP. Click on the link at the top of this page to Michael's Corner. Look at the May 2009 column. Page down until you get to the heading named The Odd Spot. In this month's entry, aptly named Coordinates from Excel to AutoCAD, Michael Beall explains how to get coordinates from Excel into AutoCAD using a script (scr) file.

Link to comment
Share on other sites

hi everyone!

 

I have coordinates in MS excel and I want to plot it in autocad 2008, is there any autolisp on this so that I cant spend a lot of time typing coordinates one by one in autocad?

 

* Open your Excel file.

* Save it as a CSV file.

* Close Excel.

* Find the CSV file, open it in Notepad.

* At the TOP of the file, add two lines:

MULTIPLE

POINT

* Save the file as a .SCR file.

* Run this script file in AutoCAD.

Link to comment
Share on other sites

* Open your Excel file.

* Save it as a CSV file.

* Close Excel.

* Find the CSV file, open it in Notepad.

* At the TOP of the file, add two lines:

MULTIPLE

POINT

* Save the file as a .SCR file.

* Run this script file in AutoCAD.

 

Great tip.

 

The application I've attached will insert user-selected blocks and also populate the attributes field if it's of use to anyone.

Link to comment
Share on other sites

I see no mention of the OP inserting blocks at these coordinates.

 

There is no need to use AutoLISP. Click on the link at the top of this page to Michael's Corner. Look at the May 2009 column. Page down until you get to the heading named The Odd Spot. In this month's entry, aptly named Coordinates from Excel to AutoCAD, Michael Beall explains how to get coordinates from Excel into AutoCAD using a script (scr) file.

 

There's no mention of what he does want, to be fair.

Link to comment
Share on other sites

sorry guys if I late reply

 

I want to connect the coordinates by polylines, like if I type the coordinates in excel it will automatically connect by the polylines

Link to comment
Share on other sites

sorry guys if I late reply

 

I want to connect the coordinates by polylines, like if I type the coordinates in excel it will automatically connect by the polylines

 

I think ReMark's referal wins:D

Link to comment
Share on other sites

If not, this should work (assumes 2D):

 

(defun c:ptpoly (/ doc spc file nl ptlst)
 (vl-load-com)
 
 (setq doc (vla-get-ActiveDocument
             (vlax-get-Acad-Object))
       spc (if (zerop (vla-get-activespace doc))
             (if (= (vla-get-mspace doc) :vlax-true)
               (vla-get-modelspace doc)
               (vla-get-paperspace doc))
             (vla-get-modelspace doc)))
 
 (if (setq file (getfiled "Select File" "" "txt" )
   (progn
     (setq file (open file "r"))
     (while (setq nl (read-line file))
       (setq ptlst (cons (StrBrk nl 44) ptlst)))
     (close file)
     (if ptlst
       (progn
         (setq ptlst
                (apply 'append
                       (mapcar
                         (function
                           (lambda (x)
                             (list (car x) (cadr x))))
                         (reverse
                           (mapcar
                             (function
                               (lambda (x)
                                 (mapcar 'distof x))) ptlst)))))
         (vla-addLightweightpolyline spc
           (vlax-make-variant
             (vlax-safearray-fill
               (vlax-make-safearray
                 vlax-vbdouble
                 (cons 0 (1- (length ptlst)))) ptlst))))
       (princ "\n<< No Points Found in File >>")))
   (princ "\n<< No File Selected >>"))
 (princ))
         

(defun StrBrk (str chrc / pos lst)
 (while (setq pos (vl-string-position chrc str))
   (setq lst (cons (substr str 1 pos) lst)
         str (substr str (+ pos 2))))
 (reverse (cons str lst)))

Link to comment
Share on other sites

If you do not want to go with ReMarks method - could you copy your coordinates into a Text file and tell me what separates them, whether it be a TAB, SPACE or COMMA.

Link to comment
Share on other sites

Ok, if you remove the X Y from the top of the text file, this should work:

 

(defun c:ptpoly (/ doc spc file nl ptlst)
 (vl-load-com)
 
 (setq doc (vla-get-ActiveDocument
             (vlax-get-Acad-Object))
       spc (if (zerop (vla-get-activespace doc))
             (if (= (vla-get-mspace doc) :vlax-true)
               (vla-get-modelspace doc)
               (vla-get-paperspace doc))
             (vla-get-modelspace doc)))
 
 (if (setq file (getfiled "Select File" "" "txt" )
   (progn
     (setq file (open file "r"))
     (while (setq nl (read-line file))
       (setq ptlst (cons (StrBrk nl 32) ptlst)))
     (close file)
     (if ptlst
       (progn
         (setq ptlst
                (apply 'append
                       (mapcar
                         (function
                           (lambda (x)
                             (list (car x) (cadr x))))
                         (reverse
                           (mapcar
                             (function
                               (lambda (x)
                                 (mapcar 'distof x))) ptlst)))))
         (vla-addLightweightpolyline spc
           (vlax-make-variant
             (vlax-safearray-fill
               (vlax-make-safearray
                 vlax-vbdouble
                 (cons 0 (1- (length ptlst)))) ptlst))))
       (princ "\n<< No Points Found in File >>")))
   (princ "\n<< No File Selected >>"))
 (princ))
         

(defun StrBrk (str chrc / pos lst)
 (while (setq pos (vl-string-position chrc str))
   (setq lst (cons (substr str 1 pos) lst)
         str (substr str (+ pos 2))))
 (reverse (cons str lst)))

Link to comment
Share on other sites

Ok, if you remove the X Y from the top of the text file, this should work:

 

(defun c:ptpoly (/ doc spc file nl ptlst)
 (vl-load-com)
 
 (setq doc (vla-get-ActiveDocument
             (vlax-get-Acad-Object))
       spc (if (zerop (vla-get-activespace doc))
             (if (= (vla-get-mspace doc) :vlax-true)
               (vla-get-modelspace doc)
               (vla-get-paperspace doc))
             (vla-get-modelspace doc)))
 
 (if (setq file (getfiled "Select File" "" "txt" )
   (progn
     (setq file (open file "r"))
     (while (setq nl (read-line file))
       (setq ptlst (cons (StrBrk nl 32) ptlst)))
     (close file)
     (if ptlst
       (progn
         (setq ptlst
                (apply 'append
                       (mapcar
                         (function
                           (lambda (x)
                             (list (car x) (cadr x))))
                         (reverse
                           (mapcar
                             (function
                               (lambda (x)
                                 (mapcar 'distof x))) ptlst)))))
         (vla-addLightweightpolyline spc
           (vlax-make-variant
             (vlax-safearray-fill
               (vlax-make-safearray
                 vlax-vbdouble
                 (cons 0 (1- (length ptlst)))) ptlst))))
       (princ "\n<< No Points Found in File >>")))
   (princ "\n<< No File Selected >>"))
 (princ))
         

(defun StrBrk (str chrc / pos lst)
 (while (setq pos (vl-string-position chrc str))
   (setq lst (cons (substr str 1 pos) lst)
         str (substr str (+ pos 2))))
 (reverse (cons str lst)))

 

 

can you please tell what I will do?

thanks :)

 

 

 

 

 

____________________________

sorry for my english

Link to comment
Share on other sites

can you please tell what I will do?

thanks :)

 

 

 

 

 

____________________________

sorry for my english

 

Regarding loading the routine:

 

http://www.cadtutor.net/faq/questions/28/How+do+I+use+an+AutoLISP+routine%3F

 

Once loaded, invoke it with "ptpoly" in ACAD.

 

Select your text file, and the job is done (hopefully!)

Link to comment
Share on other sites

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...