Jump to content

Recommended Posts

Posted

Hi, I have an excel file which looks like this example:

x y length angle

208919.46 378003.48 0.0482 13.8851

I found out how to draw a line with this information. Add these columns in Excel.

line208919.46,378003.48@0.0482

then paste in the command line.

But what I really want is an arrow on the x,y which is scaled and angled accordingly.

I've tried substituting the line command with -insert c:\arrow.dwg but Cad needs an enter (space doesn't work) to continue.

How do you give a Cad enter in Excel ???

Any help would be greatly appreciated.

David.

Posted

Hi David,

 

You need to be in the VBA area with this kind of question- I'll ask a mod if they can move it for you...

 

Gary

Posted

ok, I wasn't sure where to put place my question

Posted

No problem- welcome to the forum! :)

Posted

You dont need to have a space. I would just do "saveas" on the excel document and save it as a text file (tab delimited) and have it be "filename.scr" then in autocad type "script" load the file and it should work like a champ.

Posted

A saveas in Excel doesn't work. But if I copy the cells to Wordpad and then do a saveas, then it works like a charm with a bit of tweaking. Only thing is, the file has roughly 5000 rows, so it takes about 15 min for the script to run.

Thanks for the help.

David.

Posted

thats odd. my excel has saveas...

Posted
A saveas in Excel doesn't work. But if I copy the cells to Wordpad and then do a saveas, then it works like a charm with a bit of tweaking. Only thing is, the file has roughly 5000 rows, so it takes about 15 min for the script to run.

Thanks for the help.

David.

 

If you have a txt file with the information you quoted above, "x y length angle", then a simple LISP would make this task a 2 min procedure :thumbsup:

Posted

How do you give a Cad enter in Excel ???

 

 

go the the cell below it,

 

eg

'A1' = stuff the before enter

'A2' = the things after enter can be done as much as possible

Posted
If you have a txt file with the information you quoted above, "x y length angle", then a simple LISP would make this task a 2 min procedure :thumbsup:

 

Of course one would have to know how to do this ??:oops:

 

 

I do have a Saveas in Excel, just not the option to save as a text (tab delimited).

Posted

not sure if something like this would work:

 

(defun c:txt2blk (/ file nl lst)
 (vl-load-com)
 (if (and (or (tblsearch "BLOCK" "arrow")
              (findfile "arrow.dwg"))
          (setq file
            (getfiled "Select Text File"
              (if *load *load "") "txt" ))
   (progn
     (setq *load file file (open file "r"))
     (while (setq nl (read-line file))
       (setq lst (cons (StrBrk nl 9) lst)))
     (close file)
     (foreach x lst
       (command "_.-insert" "arrow" "_non"
         (mapcar 'distof (list (car x) (cadr x)))
           "1" "1" (distof (last x))))))
 (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)))

 

I have only taken into account the x,y and the angle as I am not of the orignal length of the arrow, to know how much to scale it by.

 

This assumes a text file with the data TAB delimited.

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