Jump to content

Import points in a .csv file to AutoCad .dwg file


NEXTMARCUS

Recommended Posts

Hi everyone,

I'm loking for a code to import a serie of points in the xyz axis to a dwg file, i used the Lee Mac's program PtManagerV2-4 and it has solved my problem in part , each point in the .csv file has an information , this information should apear in autocad as a text close to the point it was linked in excel.

 

can anyone help me?

Thanks everyone!

follows format below of the .csv file

 

 

2.7149,4.5177,0, point 1

5.6981,5.1197,0, point 2

5.9822,7.6342,0, point 3

6.8346,3.5969,0, point 4

9.2496,4.2698,0, point 5

9.5337,6.9613,0, point 6

11.8777,6.4655,0,point 7

 

 

Sorry about my very bad english :oops:

imagem.JPG

Link to comment
Share on other sites

  • Replies 31
  • Created
  • Last Reply

Top Posters In This Topic

  • NEXTMARCUS

    8

  • Tharwat

    7

  • Lee Mac

    5

  • ReMark

    4

Top Posters In This Topic

Posted Images

Thanks for de reply, but this program writes only the points in the .dwg file not the text close to the point.

am i right? Or i'am doing something wrong?

Link to comment
Share on other sites

If you create an attributed block for your point, you can use my existing Point Manager program to import the attributed block and populate the block attribute value with the data that follows the point coordinates.

Link to comment
Share on other sites

But in this case should i create an attribute block for each point that i've imported using the point manager?

 

Thanks for the reply.

Link to comment
Share on other sites

Try this routine and let me know how it goes ....

 

(defun c:Test (/ Deconstruct_String _att file st p pt)
 ;;; Tharwat 04. 01 2013 ;;;
 (defun Deconstruct_String (st delimiter / p l)
   (while (setq p (vl-string-search delimiter st 0))
     (setq l  (cons (substr st 1 p) l)
           st (substr st (+ p 2) (strlen st))
     )
   )
   (if st
     (setq l (cons st l))
   )
   (setq l (reverse l))
 )
 (defun _att (pt string)
   (entmakex (list '(0 . "ATTDEF")
                   (cons 10 pt)
                   '(40 . 0.2)
                   '(1 . "Pt")
                   (cons 2 string)
                   '(3 . "point")
                   '(70 . 0)
             )
   )
 )
 (if (setq file (getfiled "Select Excel file ..." "" "csv" 16))
   (progn
     (setq file (open file "r"))
     (while (setq st (read-line file))
       (setq st (Deconstruct_String st ";"))
       (setq p (Deconstruct_String (car st) ","))
       (_att
         (setq
           pt (list (read (car p)) (read (cadr p)) (read (caddr p)))
         )
         (vl-list->string (vl-remove 32 (vl-string->list (last st))))
       )
       (entmakex (list '(0 . "POINT") (cons 10 pt)))
     )
     (close file)
   )
   (princ)
 )
 (princ)
)

Link to comment
Share on other sites

But in this case should i create an attribute block for each point that i've imported using the point manager?

 

I believe all you need is one attributed block.

 

Correct, only one attributed block is required; this block may be defined in the active drawing or in an external drawing file.

Link to comment
Share on other sites

Is that an efficient way of doing it?

 

For me , I did the routine according to the sample drawing that I asked the OP to upload and I wrote the code as it's been all

requested from them . nothing's more .

Link to comment
Share on other sites

That was according to the sample attached drawing .

 

I just can't see why anyone would want ATTDEFs at every imported point in a drawing - it seems to me as though the OP doesn't understand attributed blocks too well.

Link to comment
Share on other sites

I too question the reasoning behind the OP's approach and not the programming provided by Tharwat. Sorry for any confusion. No offense was meant.

Link to comment
Share on other sites

I am entirely agree with that ,

 

but I am also sometimes receive drawings from contractors that contain lots of ATTDEFs instead of TEXTs and I can't see one reason that encourage people to use ATTDEFs in place of TEXTs other than ATTDEFs don't accept spaces and nothing's more than that . - STILL A GUESS .

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