Jump to content

Recommended Posts

Posted

hi every body👋
is there any lisp about this issue?
: i have a excel sheet that include coordinates and a text in every row
i need to import that text to those coordinate in autocad!

excel.png

Posted
5 hours ago, mohammadreza said:

hi every body👋
is there any lisp about this issue?
: i have a excel sheet that include coordinates and a text in every row
i need to import that text to those coordinate in autocad!

excel.png

@mohammadreza. Please upload both xls and DWG to apply it. It will be easiest. if the XLS is saved as CSV,"comma separated value" 

 

Posted (edited)

Like devitg post XLS, yes can read Excel direct. Only question is there always a header line ?

 

You could do it in Excel using a Concatenate command just copy in example column E to Autocad command line.

 

image.thumb.png.52947f26ae4239fa3b0ce9786dbfa041.png

 

=CONCATENATE("(command ",CHAR(34),"TEXT",CHAR(34)," ",CHAR(34),A1,",",B1,CHAR(34)," ","2.5 0 ",CHAR(34),C1,CHAR(34),")")

 

Edited by BIGAL
  • Like 1
Posted

If all you're after is importing the text, then I'd go with what @BIGAL suggested. By forming some formulae, you can create the necessary strings that you can simply just paste into the command line:

 

image.png.9a7a5ce56884a07034f4d3446ea4e341.png

 

30000 is just an example text height that's set, and 0.0 is the rotation angle.

  • Like 1
Posted

I do agree that the "Excel" way is easier. But if you wish my Lisp solution, here you are:

(defun c:pp()
  (setq separator ";")
  (setq textHeight 0.5)
  (setq fileName (getfiled "coords text" "" "CSV" 0)
	file (open fileName "r")
	)
  (while (setq row (read-line file))
    (setq p1 (1+ (vl-string-position (ascii separator) row))
	  p2 (1+ (vl-string-position (ascii separator) row p1))
	  x (read (substr row 1 p1))
	  y (read (substr row (1+ p1) (- p2 p1)))
	  txt (substr row (1+ p2))
	  )
    (entmake (list (cons 0 "TEXT") (list 10 x y 0) (cons 1 txt)(cons 40 textHeight)))
    )
  (close file)
  )

Save the Excel sheet in CSV format. Because the "comma" sometimes is not comma, open the file in notepad and examine the separator. Change the second line in this Lisp accordingly.

Also you may wish to change the text height -in the third line.

Enjoy!

  • Like 1
Posted

You can say open an excel, then in CAD get current range eg A1:C100 skip row 1 as its a header, then just read the 3 cells in the row.

 

Need a sample XLS then can do code.

Posted

Thats a good Excel example may add to my add line, circle, pline, macro example. 

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