Jump to content

Pushing data from a file to autocad, just rectangles.


Recommended Posts

Hello,

I'm busy with manipulating data in matlab, just 2D data rectangles now after a while I do like to import this data and view this in autocad R14.

Because matlab is a programming environment I can get the data in every form in a text file or excel or whatsoever but who can I display this in autocad R14?

Thereafter of course I like to do some manipulations in autocad store him back to a same file and read it in matlab.

Thanks a lot.

Link to comment
Share on other sites

Reading data from a text file, using VB(A) and hence VLisp - is a standard process. Interacting with applications like Excel is also a standard process.

 

Since I do not have r14, I can't tell the exact location, but explore the VBA help and you will get the solution you need.

Link to comment
Share on other sites

Welcome in the forum, Bert F!

How are the rectangles defined? Do you have the coordinates of the corners? Can you export them in a text file? Post a sample -a few lines from such a text file - and for sure someone will write a Lisp for you. When you say R14, you mean AutoCAD R14, and not AutoCAD R14 LT, right? LT can't handle Lisp, nor VBA

Link to comment
Share on other sites

Thanks for all answers.

When you say R14, you mean AutoCAD R14, and not AutoCAD R14 LT, right? LT can't handle Lisp, nor VBA

Yep I mean the full AutoCAD R14 not the lt version. I have also try to use some stuff from the internet, written in lisp and this work in my version of AutoCAD R14 only it didn’t do what I need.

How are the rectangles defined? Do you have the coordinates of the corners?

I ‘m work most time in matlab, this is a matrix lab so there I can define a rectangle as an array of 6 elements rec1=[-1 -2 0 1 2 0 ]

Where I mean that the first x coordinates is equal to -1 the y to 2 and the z are always equal to 0 the second x=1 y=2 z=0

Then I can do a dump of this variable and can get the folloing in a txt file:

 

-1.0000000e+000  -2.0000000e+000  0.0000000e+000 -1.0000000e+000  -2.0000000e+000  0.0000000e+000

 

Now I just want to draw a rectangle with this coordinates?

Link to comment
Share on other sites

A quick and somehow dirty routine:

(defun c:x1( / fn f line osmode nr f1 f2)
 (setq fn (getfiled "Select input file" "" "txt" 0))
 (setq f (open fn "r") line t)
 (setq line (read-line f))
 (setq osmode (getvar "osmode"))
 (setvar "osmode" 0)
 (while line
   (setq f1 1 f2 1 nr nil)
   (repeat 5
     (while (not (= " " (substr line f2 1))) (setq f2 (1+ f2)))
     (setq nr (append nr (list (read (substr line f1 f2)))))
     (setq f1 (1+ f2) f2 f1)
     )
   (command "rectangle" (list (car nr) (cadr nr)) (list (nth 3 nr) (nth 4 nr)))
   (setq line (read-line f))
   )
 (close f)
 (setvar "osmode" osmode)
 )
       
   

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